Important distinction:
Likely electrolyte-related (supplement and monitor): Occasional skipped beats, brief fluttering, palpitations that come and go and correlate with dehydration/fasting periods.
See your doctor soon: Frequent palpitations (multiple times daily), palpitations that last more than a few seconds, associated lightheadedness or near-fainting.
Go to ER: Sustained rapid heartbeat, chest pain, actual fainting, shortness of breath with palpitations.
If your palpitations resolve with electrolyte supplementation within a week or two, it was very likely an electrolyte issue. If they persist despite adequate supplementation, get an ECG to rule out other causes. Don't mess around with cardiac symptoms.