Google Analytics Ecommerce

Using the new version of Google Tag Manager? Read the updated version of this article.

Add a “Google Analytics” tag and choose the “Track Type” of Transaction. All the transaction information should be passed via 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

TransactionProduct Data

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 this would look:

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”:



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: 

Bitesize Training Video  

Watch this clip to learn:

  • How to create a Google Analytics ecommerce tag in GTM
  • How add ecommerce macros and values to the dataLayer
  • How to fire the tag on your Purchase page
Implementation varies for Google Analytics Enhanced Ecommerce. Please refer to our developer's guide for implementation instructions.

Additional Information

Google Analytics ecommerce tracking documentation:

How helpful is this article:

Feedback recorded. Thanks!
  • Not at all helpful
  • Not very helpful
  • Somewhat helpful
  • Very helpful
  • Extremely helpful