When using shaving foam to clean carpets, it is best to leave it on the stain for around 10 minutes to give the product an adequate amount of time to soak into the stain and break down the particles. You can scrub the foam into the stain a little before allowing it to sit, too, helping to work it in between the fibers before blotting it away with a damp towel and drying.