Healthy anal glands express, or empty, this fluid when the dog has a bowel movement.
Impacted anal glands can often be relieved by manually expressing, or squeezing out, the fluid they contain.
This is a very smelly process, but if you're game you can have your vet or groomer teach you how to do it.