Have been several other threads on same issue. I was having same problems and took advice of others to up potassium & Magnesium intake. After trial and error ended up with a Hammer product called Endurolytes. Ingredients area: Sodium, Chloride, Calcium, Magnesium, potassium, Vit B, Manganese and L-tyrosine.
I dont know what all these are but can say for sure that I rarely cramp up in legs or back anymore!