Try mixing about 1 cup of lukewarm water with 1/4 cup of ammonia.
Use a spray bottle and spray it onto your carpet. Leave this in for about 8-10 minutes.
Then you’re going to blot the stained carpet with a paper towel or a light color cotton towel.
If you can’t stand the ammonia, you can replace it with white vinegar