A few things that always that always put me in this condition are dairy products (especially cold), hamburgers (especially fast food type) and other deep fried foods. If I indulge, I pay, when I stop it goes away (hey, that's kind of catchy).
Things that help me minimize this are Betaine hydrochloride capsules (I don't produce sufficient stomach acid for good digestion of difficult fats) and certain oils (which improves my stool consistancy and movement). All prescribed by a professional natural care physician, so I'm not suggesting self diagnosis.
It is almost automatic for me anymore whenever I experience a change in stool to immediately consider what has changed in my routine; food, physical activity, weather, stress. I can usually can identify it.
Hope it's a simple fix.