Storefront pixel and consent
How the Marginful pixel respects your visitors' privacy choices, and how to connect it to a consent banner.
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:
- The visitor opted out in the browser. With Global Privacy Control or Do Not Track turned on, the pixel never runs.
- Opt-in mode. If you turned it on (below), it waits for your banner.
- Otherwise it runs.
Opt-in mode for your own consent banner
Use this on a site with a cookie banner, for visitors in the EU or the UK.
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.
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 = truebefore the script tag instead.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_vidin local storage;_mf_sid,_mf_lastand_mf_tkin 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
| Name | Where | What | How long |
|---|---|---|---|
_mf_vid | Local storage | A random visitor id | Until the visitor clears site data or withdraws consent |
_mf_sid, _mf_last | Session storage | A random session id and the time of the last event (a session ends after 30 minutes without activity) | Until the tab closes |
_mf_tk | Session storage | The campaign the session started from, to start a new session when it changes | Until 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?