An ECG records the electrical activity of the heart. The heart produces tiny electrical impulses which spread through the heart muscle to make the heart contract. These impulses can be detected by the ECG machine. You may have an ECG to help find the cause of symptoms such as the feeling of a 'thumping heart' (palpitations) or chest pain. Sometimes it is done as part of routine tests - for example, before you have an operation. The ECG test is painless and harmless.