of my pototy training books it says that if you feed them where they are going to the bathroom they will stop, as they don't potty where they eat - so try feeding her where she is going on the carpet.
But by no means do not hit her please, do this by their on nature and positive reinforcement.