Colored sodas, juices, red wine, coffee will dye your carpet. They can be faded, but in most cases are almost impossible to remove - especially stains that have set in.
Your standard automotive carpet/upholstery cleaner will help to a certain extent, especially for smaller spills.
For larger spills you may need to heavily saturate the stain with a product, agitate with a brush, let it soak for 5-10 minutes, and extract with an extractor or wet/dry vac. Repeat if desired.
Some things to try:
1:1 water:distilled white vineger
5:1 water:ammonia
hydrogen peroxide
Oxiclean
HTH