Data Foundations · Data Layer Engineering

eCommerce Data Layer Engineering

We design and implement one documented data layer for your store, so GA4, Google Ads, Meta and Klaviyo all receive the same products, prices, orders and customer context, from the same source, on every page.

  • One schema, every tool
  • Written spec your developers can use
  • Margin-ready for POAS

In plain terms

The data layer is the contract between your store and your marketing

A data layer is a structured message your store publishes whenever something happens: a product viewed, an item added to cart, an order placed. Tags read from it instead of scraping the page. When it's well built, a theme redesign doesn't break tracking, every tool sees the same order value, and adding a new ad platform takes hours instead of a project.

When it's missing or inconsistent, each tag guesses from page content, and each tool ends up with a slightly different version of the truth.

Design rules

Six rules every data layer we build follows

01

One schema across platforms

We use the GA4 ecommerce structure as the base, with an items array on every product event, so one spec serves every tag.

02

IDs that match your catalog

item_id matches the SKU or variant ID in your product feed, so ads, remarketing and reports join on the same key.

03

Clear before you push

The previous ecommerce object is cleared before each new event, so values from one event never leak into the next.

04

One revenue definition

Order value is defined once (for example, after discounts, before tax and shipping) and every tool receives the same number.

05

No personal data by accident

No raw emails or phone numbers in URLs or event parameters. Hashed identifiers go only to tags that need them, and only with consent.

06

Costs stay off the browser

Product cost and margin are added server-side for profit bidding, never exposed in page code where anyone can read them.

From the spec

What a purchase event should carry

An excerpt from a typical spec. Your version adapts to your platform, apps and reporting needs.

FieldExampleCommon mistake
eventpurchaseDifferent names in different tools for the same order
transaction_idStore order numberMissing, or a checkout token that changes on reload
valueOrder subtotal after discountsTax and shipping included in one tool, excluded in another
currencyUSDStore default sent for orders paid in another currency
couponWELCOME10Not sent, so discount-driven orders can't be separated
items[]item_id, item_name, price, quantity, item_categoryParent product ID sent instead of the variant ID in the feed
customer_typenew or returningNot sent, so first and repeat orders look the same

customer_type is a custom parameter we add because first-to-second order rate is the retention metric that matters most.

Platform specifics

How we build it on your platform

Theme events plus customer events

Storefront events come from the theme. Checkout and purchase come from Shopify's customer events, which provide standard event payloads to app and custom pixels. Custom storefront events can be published to the same system with Shopify's analytics publish method.

  • Map Shopify's checkout payloads to your schema
  • Variant IDs aligned with your Merchant Center feed
  • New vs. returning flag from customer order count
Shopify & Shopify Plus

Why margin belongs here

The data layer is where profit-based bidding starts

Bidding on revenue treats a $60 order with 20% margin the same as a $60 order with 60% margin. To bid on profit, the conversion value has to reflect margin. We design the data layer so each order can be enriched with product cost on the server, then sent to Google Ads and Meta as a profit value. It's the same structure that powers your event tracking.

  • Item-level IDs that join cleanly to your cost data
  • Profit values calculated server-side, not exposed in the browser
  • The same order structure feeding GA4 events and ad platform conversions

Related services

The layer under GA4, GTM and server-side

The data layer feeds your Google Tag Manager container and your GA4 ecommerce events, and it's what a server-side setup forwards to ad platforms. It's also how Klaviyo gets reliable product and cart data for browse and cart recovery flows on Klaviyo. Part of Data Foundations.

FAQ

Data layer questions

What is an ecommerce data layer?

It's a structured object your store updates when shoppers act: viewing a product, adding to cart, starting checkout, purchasing. Tag Manager and other tools read product, price, order and customer details from it, instead of scraping text from the page. That makes tracking consistent across tools and much harder to break with a theme change.

Doesn't Shopify already provide a data layer?

Shopify's customer events give pixels standard payloads for checkout and purchase, which is a strong base. It doesn't publish a storefront data layer for GTM by default, and it won't add custom fields such as new vs. returning or bundle details. We map Shopify's events to one schema and fill the gaps from the theme.

Who writes the code, you or our developers?

Either. We write the specification and, on most stores, the implementation too. If your developers prefer to own the theme or platform code, we hand over a written spec with examples and acceptance tests, then validate their build in GTM preview and with test orders.

Should the data layer include customer emails?

Not in plain text, and never in URLs. Enhanced conversions and Conversions API can use hashed email or phone to match conversions, but only for visitors who allow it under your consent setup. We send identifiers only to the tags that need them and document where they go.

Give every tool the same version of the truth

Start with the free audit to see how your tracking looks today, or book a call to scope a data layer for your store.

Free Profit Audit