Configure analytics and consent
Use this when marketing needs analytics or conversion tracking in the online shop.
Before you start
Get legal approval for the consent behavior and confirm which tool owns tracking, such as a consent manager, analytics platform, or tag manager.
Steps
- Open Shops and select the shop.
- Open Checkout and set the Mode in the Analytics section. Privacy-preserving is the default and sends no events to your tag manager; select Consent-managed when conversion and e-commerce events should reach the data layer after the customer grants consent.
- Open Code snippets.
- Add approved consent or analytics code under Custom HTML.
- Add approved styling only under Custom CSS.
- Save the shop.
- Test a full checkout with consent accepted and rejected.
- Confirm the analytics tool receives only the approved events.
Choose the snippet position
The online shop loads custom HTML differently depending on its configured position:
- Head snippets are part of the initial page response. Use this position only for small scripts that must run before the visible page, such as a consent manager that blocks tracking until the visitor makes a choice.
- Body snippets wait until the initial page load has finished. They then start when the browser is idle, with a finite maximum wait. Browsers without idle scheduling use a task after page load instead. Use this position for analytics, tag managers, badges, and optional widgets so they do not compete with the initial shop content.
- Body scripts that depend on one another keep their configured order unless a script is explicitly asynchronous. An ordered external body script that does not load within 10 seconds is skipped so later snippets can continue.
- A `<noscript>` fallback remains available when the visitor has disabled JavaScript.
Loading a script during idle time after page load keeps it off the initial loading path, but third-party code can still use significant processing time afterwards. Remove duplicate tags, use asynchronous loading when execution order is not required, and load interactive widgets only when the visitor needs them.
What to test
| Test | Why it matters |
|---|---|
| Consent accepted | Conversion tracking should fire when allowed. |
| Consent rejected | Non-essential tracking should stay blocked. |
| Checkout completed | Conversion event should match a real order. |
| Payment failed | Failed checkout should not count as a purchase. |
| Mobile browser | Consent banners can hide checkout controls on small screens. |
| Initial page load | Optional body snippets should not delay the visible shop. |
Expected result
Tracking follows the approved consent rule and does not interfere with checkout, payment, or customer documents.
Troubleshooting
| Problem | What to check |
|---|---|
| Conversion is missing | The Analytics Mode (must be Consent-managed), granted consent, snippet position, blocked scripts, and thank-you page behavior. |
| Duplicate conversions | Tag manager triggers, repeated page loads, and payment retry flow. |
| Checkout layout breaks | Custom CSS, banner size, mobile viewport, and snippet errors. |
| A later snippet is missing | Whether an earlier ordered body script failed or exceeded the 10-second loading limit. |