Choux pastry recipe spreading and deflating
A successful pâte à choux / choux pastry depends on a combination of


Gluten development
Water content
Baking environment


Let me show you how they work together:


The gluten, which helps to trap steam during baking and create the large holes, is developed during the phase where the water-fat-flour mixture is stirred in the pot on the stove. (There is a reason it is called "burned dough" in German, for example.) It needs to be cooked until it forms a smooth ball and a white layer is visible on the bottom of the pot. During that roasting step, some water evaporates as well.
The eggs add protein and liquid to the flour ball. It is essential that you add them to the slightly cooled flour mix slowly, one by one (or a bit at a time), always stirring well, until the dough is completely smooth before adding the next. Do not add the last bit of egg without checking the dough first. For your recipe, add the beaten eggs in about four portions. There will be a stage when the dough becomes stretchy and gets a glossy sheen, that's when you have reached the right spot. It can be piped or spooned easily, but won't be runny. Depending on how much water evaporated in step 1 and the size of the eggs, you might have to leave out the last bit of egg or use all of it.
The consistency of an eclair or cream puff depends on a balance of steam "blowing up" the batter and the flour-egg mix solidifying in the oven heat. With choux pastry, steam is an important factor. You need good heat to generate steam quickly, yet not too hot or the outer crust solidifies before the steam does its job. Some swear by generating extra steam by adding a bowl of water or spritzing the oven walls. And that is the reason why opening the oven door is so fatal. Piercing or cutting the baked puffs to release excess steam helps preventing sogginess. 


So to improve your flat puffs:


Meassure your ingredients, especially the liquid carefully. 
Bring the water-butter mix to a rolling boil, cook the dough ball well.
Add only eggs until the right consistency.
Choose the right baking temperature.
Do not open the door before the baking time is (almost) over.


And finally: Don't use sugar in the dough, even for sweet fillings. The sugar could influence the texture negatively. Choux pastry is neutral and can be used with sweet or savoury fillings.