You probably use butter. Butter melts at a low temperature and that allows the dough to spread out flat in the oven before it has a chance to set up.
The solution is to refrigerate the batter to chill the butter before putting it onto cookie sheets. Also, keep the batter in the fridge between batches and chill the cookie sheets between batches as well. All this keeps the butter from softening too soon. Works great.
Another option is to change to shortening from butter.