Google Analytics Ecommerce

To set up a Google Analytics Ecommerce tag:

  1. Create a new tag of type Google Analytics.
  2. Specify when the tag will fire.
  3. Configure your tag with the required fields, such as Tag Name, Tag Type, and the relevant Tracking ID.
  4. Set the Track Type to “Transaction.”

All the transaction information should be passed via the data layer. The following table describes the variables that can be included with the data layer:

Variable Name Description Type
transactionId (Required) Unique transaction identifier string
transactionAffiliation (Optional) Partner or store string
transactionTotal (Required) Total value of the transaction numeric
transactionShipping (Optional) Shipping charge for the transaction numeric
transactionTax (Optional) Tax amount for the transaction numeric
transactionProducts (Optional) List of items purchased in the transaction array of TransactionProduct objects

TransactionProducts Data

The TransactionProducts data is a list of objects describing products that are included in an online transaction. This table describes the data types that are available to it:

Variable Name Description Type
name (Required) Product name string
sku (Required) Product SKU string
category (Optional) Product category string
price (Required) Unit price numeric
quantity (Required) Number of items numeric

Here's an example of how the data layer code might be implemented:

dataLayer = [{
    'transactionId': '1234',
    'transactionAffiliation': 'Acme Clothing',
    'transactionTotal': 38.26,
    'transactionTax': 1.29,
    'transactionShipping': 5,
    'transactionProducts': [{
        'sku': 'DD44',
        'name': 'T-Shirt',
        'category': 'Apparel',
        'price': 11.99,
        'quantity': 1
        'sku': 'AA1243544',
        'name': 'Socks',
        'category': 'Apparel',
        'price': 9.99,
        'quantity': 2

Place this code before the Google Tag Manager container snippet so that the dataLayer is ready when Google Tag Manager fires the Google Analytics tag asynchronously.

If you can’t do this and your data layer is placed below the Google Tag Manager code on the page, add a condition to your rule to wait until the page (DOM) is fully loaded, with the built-in event “gtm.dom”:

Add new pageview trigger with filter URL contains thankyou.html, trigger type is "DOM Ready"

If you opt to have the tag fired based on a custom event, you can combine the data and the event push as described in the developer documentation.

Additional Information

See the Google Analytics ecommerce tracking developer documentation to learn more.

Was this article helpful?