What tracking codes do
- Record page views, clicks, scrolling, form submissions and purchases as events.
- Tell ad platforms which clicks led to conversions, so they can report results and optimize bidding.
- Build audiences for remarketing.
How to add them
- Google Tag Manager: one container on the site that loads and manages all your tags, without editing the code for every change.
- Directly in the site’s code: usually in the
<head>, as each platform’s instructions describe. - Plugins or built-in integrations in your CMS or shop platform.
Good practice
- Only load tracking codes after visitors consent where the law requires it, for example with a consent banner and Google Consent Mode in the EU and UK.
- Test with Tag Assistant and each platform’s debugging tools after every change.
- Remove codes for tools you no longer use; each one slows the site down.
- Don’t send personal data, such as email addresses, in page URLs or events.
“Tracking code” can also mean a UTM code: parameters added to a link to show which campaign a visitor came from.