Copied dataLayer code breaking on Shopify and Magento

Learn why copying a Google Tag Manager recipe from a blog post breaks revenue tracking on Shopify and Magento, and how to fix mismatched data variables.

Does your Google Analytics 4 property show active traffic and checkout clicks, but completely empty revenue figures and missing item details?

Copying a Google Tag Manager configuration from a popular blog post usually breaks revenue tracking on a custom ecommerce theme. The tracking tags are designed to read a very specific structured data format. If your Magento extension or Shopify app outputs the data using a different naming convention, the tracking tags find nothing but empty space.

Analytics platforms record what you tell them to record. The tags expect the data to be wrapped in a standardised format called the ecommerce schema. When the actual website delivers the data using proprietary variable names, the connection fails entirely.

The mechanism of data layer variables

Google Tag Manager acts as a translator between your website and your analytics platforms. It uses data layer variables to pick up dynamic information, such as the total order value, the transaction identifier, and the list of purchased products.

The standard schema expects the total revenue to be located under a variable named exactly ecommerce.value. It expects the purchased items to sit inside an array called ecommerce.items. If you import a pre-built container from an online guide, the container assumes your website perfectly matches this exact standard.

However, different platforms and third-party extensions build their data layers differently. A legacy Magento extension might output the revenue under ecommerce.purchase.actionField.revenue. A dedicated Shopify tracking app might use a custom prefix like dl_purchase.value to avoid conflicting with native events.

When the standard tag looks for ecommerce.value and the website provides dl_purchase.value, the tag captures a blank value. The analytics dashboard gets a conversion event, but you get absolutely zero financial data attached to it.

The commercial consequence of missing revenue

Missing revenue data breaks your ability to calculate return on ad spend. If a campaign drove thousands of pounds in sales, but the analytics platform records the revenue as zero, every marketing report will claim the campaign was a complete failure.

This matters when those numbers influence where your money goes. If your paid media algorithms rely on conversion values to optimise their bidding strategies, feeding them empty revenue data forces them to optimise for low-value traffic. The algorithm assumes all conversions are worthless and stops bidding competitively for high-value customers.

You cannot grow online sales if the numbers are not accurate. You end up pausing profitable campaigns simply because the tracking tags were looking in the wrong place for the purchase total.

Tracing the signal failure

We follow the journey from the successful checkout page to the final report in your analytics platform. We check what the website actually pushes into the data layer at the moment of purchase. We inspect the structure, the nesting, and the exact spelling of every variable.

Theme or AppVariable expectedVariable providedPurchase tracking statusRevenue gap
Default Standard Schemaecommerce.valueecommerce.valueWorking perfectlyNone
Legacy Magento Setupecommerce.valueecommerce.purchase.actionField.revenueFails completely£2,400 lost today
Custom Shopify Appecommerce.valuedl_purchase.valueFails completely£1,800 lost today
Custom Store Themeecommerce.valuetransaction_totalFails completely£3,200 lost today
Combined daily checkGA4 standardMixed schemasFailing to record£7,400 total gap

(The numbers above are illustrative figures to demonstrate the reporting gap.)

Diagnosing the variable mismatch

We evaluate the impact of the mismatched variables by looking at the specific data layer events. If the revenue is missing, or if the item array is completely blank, we investigate the exact payload the website generates.

Developer actionWhat GTM looks forWhat the site providesOutcome in analytics
Pasted generic purchase tagecommerce.transaction_idincrement_idMissing transaction identifiers
Pasted generic revenue tagecommerce.valuedl_purchase.valueRevenue reports as zero
Pasted generic items tagecommerce.itemsecommerce.purchase.productsProduct details report as blank

How we resolve the gap

We investigate your configuration, follow the journeys your customers take and check what the analytics platform actually records. If revenue is missing or product details are being dropped, we investigate what is happening and explain what needs changing.

We map your specific data layer structure to the corresponding Google Tag Manager variables. If your Magento extension outputs the revenue in a deeply nested object, we configure the variable to extract it from that exact location. We then update the tracking tags to consume the correct, custom-mapped variables instead of relying on default assumptions.

We verify the fix by running test purchases and confirming the full financial value reaches the analytics platform. The aim is straightforward. When your dashboard says you have had an enquiry or a sale, there should be an accurate financial record attached to it.

To read more about related tracking requirements, review our articles on GA4 ecommerce tracking and Shopify checkout extensibility. If you need help aligning your data layer with your tags, see our Google Tag Manager services.

Frequently asked questions

Why does my GA4 purchase tag show zero revenue?

Your purchase tag shows zero revenue when the tracking configuration looks for the transaction total in the wrong place. The standard tag expects a variable named exactly ecommerce.value. If your website uses a different naming convention, the tag captures a blank space, resulting in zero reported revenue.

What is the standard analytics ecommerce schema?

The standard ecommerce schema is a structured data format defined by Google to standardise online shopping tracking. It specifies exact names for variables, such as ecommerce.items for products and ecommerce.transaction_id for order numbers. Following this schema allows tags to automatically recognise and process shopping data.

How does a custom platform handle data variables?

Custom platforms and third-party extensions often generate variables using their own proprietary naming structures. They might nest the purchase details deeply inside action fields or add unique prefixes to prevent conflicts with other applications. These custom structures require manual mapping inside your tag management system.

Can I use the same tracking container for multiple sites?

You can only use the same tracking container across multiple sites if every site shares the exact same data layer architecture. If one site uses a modern standard schema and another uses a legacy extension, a copied container will fail to read the variables on the older site. You must adapt the configuration for each environment.

How do I inspect the data layer on my site?

You inspect the data layer by enabling the preview and debug mode in your tag management tool. When you complete a test purchase, the debug interface displays the exact data layer payload generated by the website. You can then review this payload to identify the specific variable names your site is using.