Before you make a solution to clean the carpet, blot the mess up as soon as it happens to avoid bacteria formation. Use paper towels to absorb as much as possible. Repeat the process multiple times to soak up as much of the wetness as possible.
Neutralize the Ammonia
Mix equal parts of water and vinegar to neutralize the ammonia in the dog urine. Don't lightly spray the area with the solution, pour it directly on the stain, and use plenty of it so it can penetrate the fibers of the carpet and reach where the urine has soaked in.
Sprinkle baking soda directly on the spot until it covers the area. Mix one half cup of hydrogen peroxide with a teaspoon of plain dish detergent. Blot the stain up to soak up the liquid and remaining urine.
Vacuum up the remaining baking soda after you're done scrubbing to eliminate the odor. Avoid using any cleaners with ammonia when you clean up since one of the ingredients of urine is ammonia, which is the primary reason it smells.