My dog did the same thing. He kept getting infected anal glands. Finally, after several visits to the vets, and paying quite a bit of money, I asked what could be done . Long story short, I had his anal glands removed, and there hasn't been a problem since!