Nothing jolts pet owners out of a sound sleep like that heaving sound dogs and cats make right before they are about to vomit. There's an unspoken rule that says they must do it on carpet, not on the easily cleaned kitchen floor. Getting pet-barf stains out of carpet can take some extra attention so it doesn't stain.
Scrape up the vomit with the side of a butter knife. If there is a lot of it, use paper towels and get as much of the solid waste up as you can.
Sprinkle baking powder over the entire stain. Baking soda will neutralize the bile that causes the yellowish stain to appear. It will absorb most of the vomitus. Allow the soda to dry completely. It could take a few hours, so use a blow-dryer or small fan to speed the drying process.
Vacuum up the residue, which hopefully has absorbed the stain. If there is still a mark remaining, use one of the commercial pet-stain removers or hydrogen peroxide. It is always a good idea to test these products in an out-of the way area first in case it bleaches your carpet.
When using any liquid cleaner, pour or spray it on. Then use light-colored towels, rags or paper towels to blot up the residue. Never rub it into the carpet fibers. Use the cleaner generously, and stand on the towels to press down as hard as you can, repeating until the towels come up clean.