These cookies might flatten for a couple reasons, if they are over mixed, or if you didn't add enough flour. If your cookies flatten you can try adding a couple more Tablespoons of flour at a time - or try chilling your cookie dough for 1 hour in the fridge then try baking them again.