For fruit juice or washable ink, try plain water first. For kitchen grease or butter try soapy water first. If you use soapy water you must rinse at least twice. Here is a better procedure. If coffee, juice, or other liquid was freshly spilled, sop up as much as you can first.
Toilet paper works best.
Soak up as much of the cleaning fluid as you can using toilet paper. Let it dry. If you use soapy water, you must rinse at least twice. Each time you soak up cleaning fluid, some of the dirt is taken away from the carpet and put onto the toilet paper. Now that is progress in getting the carpet clean.