An electrocardiogram, or ECG, is a test that records the electrical activity of the heart. The ECG measures and records the timing and strength of the electrical signals that travel through the heart as it contracts and relaxes. An ECG can help detect abnormal heart rhythms or activity and help diagnose conditions like heart attacks, damaged heart muscle, or heart disease.