Spraying is marking behavior, not a litter box problem. It is an important part of nonverbal communication among cats, helping to establish and define boundaries and reassure cats whose area is whose.
Sprayed cat urine contains pheromones, a substance produced by animals that is used for communication. Combinations of pheromones work like fingerprints: they identify the cat.
