Logo of TAGGRS, written in blue and with a small favicon
HomeServer-side TrackingMeta CAPI Gateway
Introduction
Get started
Get started with TAGGRSSet up Google Tag ManagerAdd the GTM Data LayerConfigure GTM transformationsTest the setupDebuggingAnalytics dashboard
Migrate from Google CloudMigrate from hosting
Shortcuts
GTM Copy PasteReady-made templates
GA4 Server-side Tracking
Setup in GTMCreate GA4 Event TagsGA4 tag setup in server containerE-commerce events in GTM
Google Ads Server-side Tracking
Install Conversion LinkerSet up Conversion TrackingConfigure Enhanced ConversionsDeploy Remarketing Tags
Facebook Server-side Tracking
Set Meta PixelImprove your EMQ ScoreInstall Meta CAPIMeta Events Deduplication
LinkedIn Server-side Tracking
Install LinkedIn Insight TagSet up LinkedIn CAPILinkedIn Events Deduplication
TikTok Server-side Tracking
Set up TikTok PixelInstall TikTok Events APITikTok Events Deduplication
Pinterest Server-side Tracking
Set up Pinterest TagConfigure Pinterest Conversions APIPinterest Events Deduplication
Snapchat Server-side Tracking
Set up Snap PixelSnapchat Conversions APISnapchat Events Deduplication
TAGGRS Tracking Tags and Tools
Tracking TagsGoogle Service Account integrationsGTM LogsProfit TrackingData Enricher ToolWebhooks TesterEnhanced Tracking ScriptMulti Domain ToolClick ID RecoveryConsent Tool
Configurations
Billy Grace Server-side TrackingLeadPages Server-side TrackingPiwik PRO Server-side TrackingCDN Server-side TrackingShopify Server-side TrackingActiveCampaign Server-side TrackingKlaviyo Server-side TrackingSpectacle Server-side Tracking
Server-side Tracking for e-commerce
Shopify Data LayerShopware Data LayerMagento Data LayerWooCommerce Data LayerPrestashop Data LayerLightspeed Data Layer
Consent Management server-side
Activate Consent ModeConfigure TAGGRS with Axeptio

Set up Google Tag Manager Data Layer

This guide explains two methods for implementing and using the Google Tag Manager (GTM) Data Layer for Server-side Tracking with TAGGRS. It covers the Data Layer’s definitions, syntax, practical examples, use cases, and best practices.

When should you use a Data Layer?

Configuring a data layer is not mandatory to finalize the server-side tracking setup. When it comes to basic event tracking, such as pageviews, Data Layers are usually not needed, built-in GTM variables may suffice. Is this your case? Go straight to our GTM transformations guide.
Implementing the Data Layer is highly recommended for e-commerce stores:
  • To enhance data completeness and reliability in case of advanced or custom events, such as purchases, multi-step forms, or custom event tracking.
  • To achieve accurate event forwarding and data integrity in your Server-side Tracking.

What is a Data Layer in Google Tag Manager?

A Data Layer is a JavaScript array that acts as the main data transport mechanism between your website (or app) and Google Tag Manager. It collects, organizes, and passes information from your website to analytics and marketing platforms.
For Server-side Tracking, the Data Layer ensures that all the key events and parameters are consistently captured and transmitted from the client (web container) to the server container for tracking, analysis, and optimization.
Screenshot from Google Tag Manager showing the built-in variables that can be configured

What is a standard e-commerce Data Layer?

Strictly speaking, there is no universal “standard” Data Layer. Each CMS or platform often has its own variation. However, the Google Analytics 4 (GA4) Data Layer structure is widely considered the standard because it is most commonly used and directly supported by Google’s official documentation. You can find Google’s recommended e-commerce data layer here: GA4 e-commerce developer documentation.

When implementing GA4, follow Google’s standard events and structure as much as possible. Instead of using GTAG, always send events to GTM with a dataLayer.push. For example:

Logo of TAGGRS Server-side Tracking: a light blue circle with two blue angle brackets
<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'e-commerce event',
'data': 'e-commerce data'});
</script>

Data Layer structure example: purchased event

Here’s an enhanced purchase data layer example with multiple variables, including customer information and product details:

Logo of TAGGRS Server-side Tracking: a light blue circle with two blue angle brackets
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "purchase",
transaction_id: "T_12345",
value: 72.05,
tax: 3.60,
shipping: 5.99,
currency: "USD",
coupon: "SUMMER_SALE",  customer_type: "new",
user_data: {
email: "jane.doe@example.com",
phone_number: "+14155552671",
first_name: "Jane",
last_name: "Doe",
street: "123 Main Street",
city: "San Francisco",
region: "CA",
country: "US",
postal_code: "94105"
},
items: [
{
item_id: "SKU_12345",
item_name: "Stan and Friends Tee",
affiliation: "Google Merchandise Store",
coupon: "SUMMER_FUN",
discount: 2.22,
index: 0,
item_brand: "Google",
item_category: "Apparel",
item_category2: "Adult",
item_category3: "Shirts",
item_category4: "Crew",
item_category5: "Short sleeve",
item_list_id: "related_products",
item_list_name: "Related Products",
item_variant: "green",
location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
price: 10.01,
quantity: 3
},
{
item_id: "SKU_12346",
item_name: "Google Grey Women's Tee",
affiliation: "Google Merchandise Store",
coupon: "SUMMER_FUN",
discount: 3.33,
index: 1,
item_brand: "Google",
item_category: "Apparel",
item_category2: "Adult",
item_category3: "Shirts",
item_category4: "Crew",
item_category5: "Short sleeve",
item_list_id: "related_products",
item_list_name: "Related Products",
item_variant: "gray",
location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
price: 21.01,
promotion_id: "P_12345",
promotion_name: "Summer Sale",
quantity: 2
}
]
});

How does the Data Layer work?

The Data Layer work client to server, acting as a communication bridge between your website (or app) and Google Tag Manager. It stores information in a structured array so that GTM can easily read it and pass it on to connected platforms such as Google Analytics, Google Ads, or other third-party tools. The typical data flow is:

  1. Event occurs on the website (e.g., purchase completed).
  2. The event is pushed into the Data Layer.
  3. GTM web container reads the Data Layer and triggers tags or variables as configured.
  4. GTM triggers tags based on configured variables and event rules.
  5. Event data is sent to the GTM server container via the server_container_url parameter in your GA4 tag configuration.
  6. Server container processes the event and forwards or transforms data as needed for analytics, marketing, or custom endpoints.

You can then pick up these values in GTM using Data Layer Variables. For example:

  • To capture the transaction value, you would use ecommerce.value.
  • To capture the first item’s ID in a purchase, you would use items.0.item_id.

These variables can then be used as parameters in your GTM tags for analytics or advertising.

This Data Layer structure ensures not only the purchase event itself is tracked but also rich details about the customer and the items purchased, maximizing server-side insights.

Example of data layer in Google Tag Manager

How to configure GTM Data Layer

There are two primary methods to send information into the data layer: declaration and push.

1. Data Layer declaration

Logo of TAGGRS Server-side Tracking: a light blue circle with two blue angle brackets
<script>
window.dataLayer = [{
event: "pageView",
value: "content"
}];
</script>

When declaring the data layer, it should always be placed above the Google Tag Manager container snippet in the <head> section. By loading it early, GTM has immediate access to the information and can trigger tags accurately without delay.
This setup works particularly well for static information such as page titles, content categories, or user IDs, which provide valuable context for event tracking and analytics.
At the same time, it is essential to initialize the data layer correctly. An improper declaration may overwrite the existing data layer object, which can cause loss of previously defined values and lead to inconsistencies in your tracking setup.

Pro and cons

✔ Provides initial page and user info before GTM loads
✔ Ensures consistent availability of static data
✘ Cannot handle dynamic events after page load
✘ Risk of overwriting data layer

2. Data Layer push

Logo of TAGGRS Server-side Tracking: a light blue circle with two blue angle brackets
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "purchase",
value: 100
});

Using a dataLayer.push() call allows you to dynamically send new information into the existing data layer after the page has loaded. This method is ideal for recording multiple events in sequence (like add to cart, checkout, or purchase) which are essential milestones in e-commerce tracking and conversion analytics.
By pushing interaction data in real time, you can capture how users behave on your site beyond static page information.
However, it is important to initialize the data layer correctly; if the push occurs too early or too late, it can lead to timing issues where events are missed or not processed properly by Google Tag Manager. This makes careful setup critical for ensuring accurate and reliable event tracking.

Pro and cons

✔ Supports dynamic, real-time events
✔ Ideal for e-commerce actions like add-to-cart and purchase
✔ Multiple events can be recorded sequentially
✘ Requires initialization before use
✘ Order of execution must be managed carefully

Data layer for the most popular e-commerce stores by TAGGRS

You can develop a Data Layers manually, but we developed 5 plugins for the most used e-commerce platforms to help you save time: Shopify, Magento, WooCommerce, Lightspeed, and Magento.

Shopify logo in white and transparent background
Shopify Data Layer
icon of a white upward arrow
Magento logo in white and transparent background
Magento Data Layer
icon of a white upward arrow
WooCommerce logo in white and transparent background
WooCommerce Data Layer
icon of a white upward arrow
Lightspeed logo in white and transparent background
Lightspeed Data Layer
icon of a white upward arrow
Prestashop logo in white and transparent background
Prestashop Data Layer
icon of a white upward arrow

Best practices

  • Use clear, consistent naming for events and parameters.
  • Align your structure with the requirements of your analytics or marketing platforms (e.g. GA4 Enhanced Ecommerce).
  • Use GTM’s Preview Mode and server-side Preview tools to verify that events and parameters are captured and processed as expected before going live.

Useful resources

icon of a white thunder used by TAGGRS to visually introduce Server-side Tracking
Start for free with Server-side Tracking
icon of a white upward arrow
White silhouette of a person used as icon for the support call to action
Get expert support
icon of a white upward arrow
Previous
Set up GTM
Next
Transformations in GTM
DOCUMENTATION V1.3
Copyright © 2025 TAGGRS. All right reserved.
TABLE OF CONTENTS
When to use the Data Layer?What is a Data Layer?Standard e-commerce Data LayerData Layer structureHow does the Data Layer workGTM Data Layer configurationE-commerce Data Layer by TAGGRSBest practicesUseful resources