1. If it is occurring for the last 1 week, hopefully you should check with your blood sugar level and blood pressure.
2. but since it is coming just before Bowel movement, it can be " autonomic dysreflexia", and generally this happens at times when bowels are full of stool and when one is severly constipated! and on straining, Vagus Nerve
is stimulated and causing above said symptoms. [vasovagal problem]
3. Consult or See a gastroenterologist that specializes in rectal manometry and pelvic floor dysfunction
Or see a Neurologist[If it occurs sporadically and is spontaneous]