Storefront pixel and consent

How the Marginful pixel respects your visitors' privacy choices, and how to connect it to a consent banner.

Updated 11 October 2026Open in Marginful

On this page

The Marginful pixel is for stores outside Shopify (WooCommerce and custom sites). Shopify stores don't need it: Marginful attributes their orders from the landing page and UTM parameters Shopify saves with each order, and never adds code to a Shopify theme.

The pixel records visits to your store so attribution can credit sales to the right ads. It sets no cookies and stores no personal data: only random ids that can't identify a person. Still, in the EU and the UK an analytics script may need the visitor's consent before it runs. This page shows how the pixel handles that.

How to install it

Copy the <script> line from Integrations → Tracking and add it to every page of your site, before </head>. It follows the consent rules below.

How the snippet decides whether to run

The snippet checks, in this order:

  1. The visitor opted out in the browser. With Global Privacy Control or Do Not Track turned on, the pixel never runs.
  2. Opt-in mode. If you turned it on (below), it waits for your banner.
  3. Otherwise it runs.

Use this on a site with a cookie banner, for visitors in the EU or the UK.

  1. Add data-consent to the snippet

    Add data-consent="required" to the script tag:

    <script async src="https://YOUR-MARGINFUL-ADDRESS/pixel.js" data-store="YOUR-STORE-ID" data-consent="required"></script>
    

    Until consent is given the pixel stays completely silent: it stores nothing in the browser and sends nothing.

  2. Call Marginful when the visitor accepts analytics

    In your banner's "accept" callback, call:

    window.marginful && window.marginful.consent(true);
    

    If your banner already knows the answer before the pixel loads (for example on a returning visit), set window.marginfulConsent = true before the script tag instead.

  3. Call it again when the visitor withdraws consent

    window.marginful && window.marginful.consent(false);
    

    The pixel stops at once, drops anything not yet sent, and deletes its ids from the browser (_mf_vid in local storage; _mf_sid, _mf_last and _mf_tk in session storage).

Tip

Put Marginful in the "analytics" or "statistics" category of your banner. It is not used for advertising and shares nothing with ad platforms.

What the pixel stores in the browser

NameWhereWhatHow long
_mf_vidLocal storageA random visitor idUntil the visitor clears site data or withdraws consent
_mf_sid, _mf_lastSession storageA random session id and the time of the last event (a session ends after 30 minutes without activity)Until the tab closes
_mf_tkSession storageThe campaign the session started from, to start a new session when it changesUntil the tab closes

No cookies are set.

What the pixel sends

  • The event: page view, product view, add to cart, checkout started.
  • The random visitor and session ids, and the time.
  • The page path with only the campaign parameters (UTM) and ad click ids. The rest of the address is never sent, so e-mails or tokens in a link can't leak.
  • The referring site, without its query string.
  • Product and variant ids.

IP addresses and browser details are used only in memory to block abuse, and are never stored. When a customer asks to be forgotten, their pixel events are deleted with the rest of their data (privacy requests).

Was this page helpful?

Need help?
Storefront pixel and consent · Marginful Docs