Dogs have two glands located around their anus at five and seven o'clock positions. Aside from urination, a dog's scent is spread from their anal glands, a high wagging tail helps to spread their scent while a still, tucked tail helps to hide it. Anal glands are naturally expressed from the stretching of the sphincter during bowel movements however they can become blocked resulting in a buildup of fluid.
Anal glands can become impacted if the duct is obstructed or has suffered physical trauma. Dogs will try to alleviate discomfort or pain caused from irritated anal sacs by scooting their bum across the floor as well as licking or biting near the anus and around the base of the tail.
Inflammation can affect anal glands if they have been expressed incorrectly or too frequently. Avoid manually draining your dog's anal sacs if it is not required as this may inhibit the dog's ability to express the fluid naturally. Increasing stool firmness by feeding a high fibre diet can help as it increases pressure on the sphincter's muscles to trigger fluid elimination.