First, clean up messes quickly. Choose a pet-friendly cleaner that is specially formulated to take care of tough stains. Clean up after potty accidents, muddy messes, and anything else that stains or causes unpleasant odors.
Vacuuming regularly is also a great way to keep your carpets in tip-top shape. It can pull hair up out of the carpet, but it can also cut back on allergens if you use a HEPA filter.
Even if your carpets look pretty good, you should still plan on having them professionally cleaned once or twice a year.