Skip to content

Case study · In development

Edition – DataLayer & Tracking

A Shopify app that gives a store one complete data layer across storefront and checkout, and delivers every event to the ad and analytics platforms it uses, from the browser and from the server, and only after the visitor has consented.

Tracking platform · Shopify appIn development

13

ad & analytics platforms

Edition – DataLayer & Tracking

2026 · Built at Edition

Year
2026
Role
Solo developer
Built at
Edition
Type
Tracking platform · Shopify app
Status
In development
  • Next.js
  • TypeScript
  • Polaris
  • PostgreSQL
  • Prisma
  • Redis
  • BullMQ
  • Shopify Web Pixels
  • Google Tag Manager
  • Docker

The challenge

Ad platforms run on conversion data, but browser tracking keeps losing it to ad blockers, Safari's cookie limits and bots. Setting up Google Tag Manager by hand for every store and every market is slow and easy to get wrong. And all of it has to respect the visitor's consent.

The approach

  1. 01

    One data layer for storefront and checkout

    23 events, from page views and searches to every checkout step and the purchase, each one switchable per store.

  2. 02

    Google Tag Manager in one click

    The app generates an import-ready container for the store, with every platform's IDs filled in per market and unconfigured tags paused, so nothing fires half set up.

  3. 03

    Server-side delivery

    Events also go from the server to Meta, GA4, TikTok, Pinterest, Snapchat, Microsoft Advertising, Reddit, X and Klaviyo, carrying the same event ID as the browser copy so each conversion is counted once. GA4, which can't deduplicate, gets its events from the server only.

  4. 04

    Consent first

    Events wait in the browser until the visitor consents, and the server checks consent again per platform before forwarding anything. Customer details go to the platforms as SHA-256 hashes.

  5. 05

    A safety net for purchases

    If the checkout pixel never fires, the order webhook rebuilds the purchase event from the order, with the same ID, so the conversion still arrives and is never counted twice.

  6. 06

    Power-ups for data quality

    First-party Tag Manager loading, bot and crawler filtering, staff exclusion, a PII guard that scrubs personal data from URLs, and ad click IDs kept for up to 90 days. A status page shows delivery health per platform and how many orders were tracked.

The outcome

Built on Edition's app template and nearly ready for the Shopify App Store. Visitor events are never stored in a database: they are processed as they arrive and forwarded only to the platforms the merchant has connected.

The collect endpoint is a plain Node service rather than Next.js. It validates a batch, runs the consent and bot checks in the request and queues one job per platform, at about 4 ms of CPU per request.

How it works

Life of an event

What happens between a visitor doing something in the store and that event reaching each ad and analytics platform.

  1. 01

    Off for bots and staff

    The data layer never starts for known bots or for excluded staff. Personal data is scrubbed from the address bar before anything can read it.

  2. 02

    Given an ID at birth

    Only the events the merchant has switched on get through, and each one gets a unique event ID that its browser and server copies share.

  3. 03

    Held until consent

    An event waits in the visitor's session until they consent. Their last choice is remembered, so a new page doesn't start out as "denied".

  4. 04

    Sent in small batches

    Events leave after ten have gathered or three seconds have passed, and when the visitor leaves the page, in a beacon that needs no extra preflight request.

  5. 05

    Checked at the door

    The server checks the batch's size, shop and settings, filters bots by user agent and datacenter IP ranges, then checks consent and market per platform. Each platform that passes gets one job.

  6. 06

    Forwarded per platform

    Every platform has a queue of its own. Consent and settings are checked once more before sending, and customer details only ever travel as SHA-256 hashes.

  7. 07

    Retried patiently, then recorded

    A failed delivery is retried four times over a few minutes, since the platforms accept late events; a configuration error is not retried at all. Results per platform and per order feed the status page.

Key decisions

Why it's built this way

  1. 01

    A plain Node service

    over Next.js for the collect endpoint

    Next.js added about 2 ms of CPU to every request and topped out at 40–50 requests a second. The Node service handles 60 a second with a quarter of its CPU to spare.

  2. 02

    Checks inside the request

    over a separate ingest queue

    The checks are cheap and every queue hop costs round trips to Redis. Running them in the request cut CPU per request from 4.55 ms to about 4.

  3. 03

    No event table

    over storing every event

    Only order facts and per-platform delivery results are kept, and they are deleted after 35 and 90 days. Visitor events pass through and are gone.

  4. 04

    One queue per platform

    over one shared queue

    Meta being down must never hold up delivery to GA4 or anyone else.

  5. 05

    GA4 from the server only

    over sending it from both sides

    GA4 can't deduplicate a browser and a server copy. The generated container blocks GA4's browser event tags, and only page views stay in the browser.

  6. 06

    Rescuing missed purchases

    over trusting the checkout pixel

    Five minutes after an order, the order webhook sends the purchase to every platform that never got it, with the order ID as event ID, and only if the visitor's consent was recorded.

  7. 07

    Tags paused until configured

    over shipping every tag live

    A base pixel with no ID set sends errors on every page, as seen live with Pinterest. Unconfigured tags ship paused instead.

  8. 08

    Tag Manager from the store's own domain

    over loading it from Google

    Ad blockers that block by domain can't strip the whole container. Only the shop's own container is served, stored pre-compressed, with Google as the fallback.

  9. 09

    Neutral endpoint names

    over descriptive ones

    Paths like "collect", "gtm" and "pixel" are on ad-blocker filter lists, so the public endpoints are named /batch, /loader and /checkout-loader.

Next case study

Shopify App Template

Read it →

Have a problem worth solving?