An electrocardiogram is a test that is used to monitor your heart. Each heartbeat is triggered by an electrical impulse generated by special cells in your heart's upper right chamber. An electrocardiogram, records these electrical impulses as they travel through your heart. ECG is used by your doctor to look for patterns in these heartbeats and rhythms in order to diagnose various heart conditions. An electrocardiogram is a painless, noninvasive test.