Buy a welcome mat
This will act as a receptacle for large particles and dirt stuck on shoes. Preventing an ounce of dirt takes less stress then curing a pound of dirt.  Also, put a rug or small carpet in front of heavily trafficked area to avoid the carpet from being worn prematurely.
Vacuum or sweep to remove superficial dirt and dust
Make sure to vacuum thoroughly using back and forth movements.  Make sure to adjust furniture placement by an inch or so to allow the spots crushed by furniture legs to recover.

Treat spills as soon as possible

Treat spills as soon as possible, or it’s likely to set and become a hassle to remove. Avoid using chemical treatments which may be damaging, start with cold water first. For more guides for treating spills visit Stain Guide

Have carpets professionally cleaned

Have carpets professionally cleaned at least once every three to six months , more often for high-use areas. Having them professionally cleaned once every three to six months is a matter of health and lengthening the life of your investment.