Skip to content
Menu
Skip to Content
CookieROAS

Placing the tracking code

How to put the CookieROAS snippet in your store's head, with your cookie banner, your CSP and the purchase on the thank-you page.

The tracking code (snippet) records what happens in the browser: the visitor's consent, the click ids of ads and the purchase on the thank-you page. The snippet is on Tracking › Setup › Snippet & consent.

What you need

  • Access to the <head> of your theme or template
  • A chosen tracking domain: the snippet uses it

Steps

Choose your tracking domain

Step 1 on Snippet & consent is the tracking domain. The snippet only appears once the domain is saved. Read Own tracking domain.

Paste the snippet into the head of every page

In step 2, click Copy snippet and paste it into the <head> of every page, as high as you can: above the cookie banner and the tag manager.

Don't place the snippet through Google Tag Manager only. It loads too late for the checks before consent.

The browser token is in the snippet and is shown in full only once. If you lose it, create a new one under Browser token; existing tokens keep working.

The snippet on Snippet & consent, with the Copy snippet button

Make sure the purchase is on the thank-you page

CookieROAS reads the purchase from the dataLayer of your thank-you page. If your store already sends a GA4 ecommerce purchase event, that is enough.

The transaction_id of that purchase must equal the order number your order connection sends. Only then do order and purchase belong together.

Check the installation

In step 3, click Check the installation. CookieROAS opens your store and checks that the script, the settings and the events arrive. In Getting started, Snippet on the shop turns green once the snippet reports in.

Check the installation, with a passed check

Where do you paste the snippet?

Shopify: Online Store › Themes › Edit code › theme.liquid, right after <head>.

WooCommerce, Magento, PrestaShop, Odoo, JTL-Shop, Gambio, OXID, plentymarkets and OpenCart: enter the snippet in the tracking code field of the CookieROAS module. You then don't need to change your theme.

Other systems: in the header template, so it is on every page, including the checkout and the thank-you page.

Does your cookie banner block scripts automatically (autoblock)? Then put both scripts from the snippet on its exception list, so they load before consent. The snippet respects the visitor's choice itself.

Does your site have a Content Security Policy? Add your tracking domain to script-src and connect-src. The dashboard shows the exact address under Cookie banner blocks scripts or the site has a CSP?. If your CSP asks for a nonce, put it on both scripts.

Under Consent on the same page you choose which cookie banner your store uses, and you see whether each ad platform gets the visitor's choice.

Consent for order delivery, with the cookie banner and platforms chosen

Check that it works

  • Check the installation succeeded.
  • Snippet on the shop in Getting started is green, with the time of the last report.
  • After a test order, the purchase shows with the order on the Orders page.

If it doesn't work

Read more