Installing carpeting in a room or multiple rooms is a major investment. However, unlike hard woods, carpets can stain due to spills and dirt accumulation. Weekly vacuuming and a yearly steam cleaning is usually enough to keep carpets looking good for years and years. However if you do spill something onto your carpet, you will achieve your best cleaning results if you treat a spill immediately (before it has a chance to dry).
Before using any cleaning product on your carpet, test it first in an inconspicuous spot on the carpet. Also note that synthetic carpets may require different cleaning solutions so be sure to know the type of carpet you have and check the label of the cleaning product to ensure that you can use it on your type of carpet.
For soda, food and cosmetics first clean the area with a sponge and a small amount of dry-cleaning solution. You want to blot the area to avoid rubbing in the stain. If you have a steam cleaner, use this first being sure not to push the stain in deeper by using the scrubbing pads of the cleaner.
You also want to take care to avoid getting the carpet too wet.
If the stain remains, try use one teaspoon of a mild detergent (no bleach) with a cup of warm water. Blot the area then clean with warm water.
Repeat as necessary.
If dry cleaning solution or mild detergent does not get the job done, try a product specifically designed to clean carpets.
Once the stain has been cleaned, steam clean the entire carpet to remove any residue that is under the carpet. When dry, brush the pile to match the rest of the carpet.
Some stains such as red wine can be very hard to remove. Multiple applications may be required to clean the area.
Unfortunately some stains are permanent and cannot be cleaned. In this case you will need to swap a piece of the carpet from a more inconspicuous area such as a closet. This type of job is best handled by a carpet installer.