Skip to main content
Skip table of contents

The Data Layer

The data layer is an object used by websites to transmit information to tags. It allows events or variables to be passed, and triggers can be set up based on variable values.

For instance, you can configure the data layer to make certain data accessible to your tags. This could include firing a tag when the value of "purchase total" exceeds $100 or triggering events when specific actions occur, like clicking a button. The data layer is structured as JSON, as shown in the example below:

JS
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'ecommerce': {
    'purchase': {
      'actionField': {
        'id': 'P67890',                         // Transaction ID. Required for purchases and refunds.
        'affiliation': 'Pet Food Store',
        'revenue': '42.99',                     // Total transaction value (incl. tax and shipping)
        'tax':'5.20',
        'shipping': '6.99',
        'coupon': 'PETS10OFF'
      },
      'products': [{                            // List of productFieldObjects.
        'name': 'Premium Dog Food',             // Name or ID is required.
        'id': '12345',
        'price': '24.99',
        'brand': 'Acme Pet Foods',
        'category': 'Pet Supplies',
        'variant': 'Chicken Flavor',
        'quantity': 2,
        'coupon': ''                            // Optional fields may be omitted or set to empty string.
       },
       {
        'name': 'Cat Treats',
        'id': '67890',
        'price': '9.50',
        'brand': 'Meow Treats',
        'category': 'Pet Supplies',
        'variant': 'Salmon Flavor',
        'quantity': 3
       }]
    }
  }
});

By organizing and storing information in the data layer, Atrilyx tags can easily access the data they need in a structured and predictable manner. This avoids the need to parse variables, transaction details, page categories, or scattered signals across the webpage. Implementing a data layer with populated variables and associated values ensures that relevant data is readily available when tags require it.

For more information, check out https://developers.google.com/analytics/devguides/collection/ua/gtm/enhanced-ecommerce

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.