An electrocardiogram (ECG or EKG) is a medical test that measures the electrical activity of the heart over a period of time. It detects the heart's rhythm, electrical impulses, and overall health by recording the electrical signals that trigger heartbeats. Electrodes are placed on the skin to capture the electrical signals as they move through the heart, producing a visual representation of the heart's activity. An ECG can help diagnose various heart conditions, including arrhythmias, heart attacks, and other cardiac abnormalities, by analyzing the timing and strength of these electrical impulses.