Dirt is bound to get ground in to a carpet that is walked on regularly, even if you take your shoes off before doing so. Vacuuming your carpet regularly, at least the highest traffic areas, will delay the inevitable, but once dirt is pressed into the carpet's fibers, it's time to do more than vacuum.
Vacuum the carpet to remove any loose dirt particles.
Purchase a commercial carpet cleaning solution (or spot remover) or make your own by mixing ¼ teaspoon of clear liquid dishwashing liquid per one cup of water.
Test whatever cleaning solution you use on an inconspicuous area of your carpet to make sure the carpet's color is not affected.
Put a small amount of the cleaner on a clean, white cloth, and work it into the carpet fibers from the edges of the ground-in dirt to the center. This will help prevent the stain from spreading. Keep the solution on the carpet for a few minutes, and blot with a dry, white cloth. Repeat this step as long as the ground-in dirt stain is transferring from the carpet to the cloth—it may take several applications for the stain to completely transfer.
Rinse the previously stained area with lukewarm water and blot dry with a dry cloth. Then place one more dry cloths on the damp area and place a heavy object (like a book or door jam) on the towel to pull the remaining moisture from the carpet into the towel. Leave the object on the towel overnight.
Remove the towel and heavy objects; then vacuum the area one more time to remove any dried cleaning solution that may be residing in the carpet fibers. This residual solution can attract dirt and create a new stain if allowed to remain.
Consider using an extractor if the area of ground-in dirt is large. Also known as steam cleaning, extraction relies on heat to loosen and pull dirt particles from carpet fibers. Some extractors also inject a cleaning solution into the fibers and immediately pull it out for extra cleaning power.
Call a professional to rid your carpet of ground-in dirt if you cannot do so yourself. They have more powerful equipment and cleaning solutions than what is available for purchase or rent to the general public.