This is called scent marking. The dog's urine contains a chemical that makes an odour. The odour shows where the dog has travelled. All mammals have several scent glands that they use to mark objects in their habitat. In the animal world, the sense of smell is very important.
Animals have a very well-developed sense of smell that is much superior to that of humans.
Scent markings are used for a number of different purposes. One of the most important purposes is communication between members of the same species. For example, the female red squirrel uses her scent markings to let the male know that she is ready for mating. She produces a smell that she rubs on trees and branches. Animals also use scent markings to mark off their home range or territory to members of the same species.