When you take your dog for a walk around the neighborhood, he will sniff at certain points to check the amount of traffic in his territory. Dogs mark their territory with urine and leave behind information about their identity and rank. It is their way of saying "I was here." A dominant or higher-ranking dog will always urinate over a lower-ranking dog's mark. Females mark using urine to inform other dogs when they are about to come into season. Scent marking with urine, and sometimes feces, is mainly undertaken by males, but many females also mark this way. Many male dogs and some dominant female dogs will urinate in multiple places to establish their scent on their territory.
A male dog lifts his leg so he can urinate on vertical surfaces. Some researchers believe scenting on a vertical surface will generally last longer than on a horizontal surface. The scent is also more at a dog's nose level, so the next dog that comes along will be less likely to miss it. Male dogs do this in response to earlier marks left by unfamiliar males, rather than females or themselves.