Enhanced ecommerce tracking in Google Tag Manager

Google Tag Manager (GTM) loads Google Analytics 4 (GA4) and any other arbitrary JavaScript or HTML tags in the same “container." Google Analytics 4 also provides ecommerce tracking designed to support a system where items are added to a cart and then the cart is checked out. We have configured ActionTag to fire purchase events on successful contribution and event form submissions. These are currently the only events sent by ActionTag; you may suggest additional events through our product feedback channels.

EveryAction will update ecommerce event tracking for GA4 in May 2023. If you use custom JavaScript code for enhanced ecommerce tracking, you will need to update it using the snippets below as a model. GA4 is more open and flexible than Universal Analytics, and so requires intentional configuration of the DataLayer to fit your analytics goals.

Examples of Ecommerce Events in Google Tag Manager

The following code snippet is an example of data that can be passed into the GTM DataLayer upon successful client-side form submission of a single contribution.

{  
  ecommerce: {  
    /* Automatically generated transaction id */
    transaction_id: "ch_3N84kyKqA9iiEX4Z03xw7HRO",  
    /* Total value of the transaction */
    value: "25.00",  
    currency: "USD",  
      
    /* Item array (only one item/contributio in this example) */
    items: [  
      { 
        /* ID or SKU for the product */
        item_id: "382",
        /* Name of the selected product (contribution) */
        item_name: "Contribution",  
        /* Unit price (contribution amount) */
        price: "25.00", 
        /* Organization name */
        item_brand: "People for Good",  
        item_category: "Contribution",  
        quantity: 1,
        /* Denoting a transaction from ActionTag */
        affiliation: "NGPVAN",  
        item_variant: "One-Time"  
      }  
    ]  
  }, 
 /*Google event type */
  event: "purchase",  
}

The following code snippet is an example of data that could be passed into the GTM DataLayer upon successful client-side form submission for an event with multiple tickets.

{
  ecommerce: {
    /* Automatically generated transaction id */
    transaction_id: "DTG-w1bSmurt1Og",
    /* Total value of the transaction */
    value: "600.00",
    
    items: [
      {
        /* First item with a quantity of 1 (single ticket) */
        item_id: "383",
        item_name: "Gala Ticket",
        price: "100.00",
        item_brand: "People for Good",
        item_category: "TicketedEvent",
        quantity: 1,
        affiliation: "NGPVAN",
        item_variant: "Gala Silver Ticket"
      },
      {
        /* Second item with a quantity of 2 (different ticket level) */
        item_id: "387",
        item_name: "Gala Ticket",
        price: "150.00",
        item_brand: "People for Good",
        item_category: "TicketedEvent",
        quantity: 2,
        affiliation: "NGPVAN",
        item_variant: "Gala Gold Ticket"
      }
    ]
  },
  event: "purchase"
}

Legacy Examples for GTM in Universal Analytics

The following code snippets were provided as examples for use with Universal Analytics. You may continue to use them but won't see as complete data as with the examples updated for Google Analytics 4. The first is an example of a contribution form submission

dataLayer = [{

  /* Triggering Event */
  'event': 'transaction',

  'ecommerce': {
    'purchase': {
      'actionField': {
        /* Online Ref # (can be used to search for transaction) */
        'id': '25970195',

        /* Denoting a Transaction from ActionTag */
        'affiliation': 'NGPVAN',

        /* Total Transaction Revenue */
        'revenue': '2600.00'
      },

      'products': [
        {
        /**
         * ID based upon unique session ID, combined with the
         * individual product transaction.
         * This value does not remain staticly assigned to the item for 
         * future purchases or for purchases by other users;
         * it is unique to the session)
         */
          'id': 'People for Good_4_713_2600.00',

          /* Unit Price (Contribution Amount) */
          'price': '2600.00',

          /* Organization Name */
          'brand': 'People for Good',

          /* Form Type */
          'category': 'ContributionForm',

          /* Count of Items */
          'quantity': 1,

          /* Selected Product */
          'name': 'People for Good_4_713_2600.00'
        }
      ]
    }
  }]
}];

The following code snippet is an example of data that could be passed into the GTM DataLayer upon successful client-side form submission for an event with multiple tickets.

dataLayer = [{

  /* Triggering Event */
  'event': 'transaction',

  'ecommerce': {
    'purchase': {
      'actionField': {
        /* Online Ref # (can be used to search for transaction) */
        'id': '25970195',

        /* Denoting a Transaction from ActionTag */
        'affiliation': 'NGPVAN',

        /* Total Transaction Revenue */
        'revenue': '200.00'
      },

      'products': [
        {
        /**
         * ID based upon unique session ID, combined with the
         * individual product transaction.
         * This value does not remain staticly assigned to the item for 
         * future purchases or for purchases by other users;
         * it is unique to the session)
         */
          'id': 'People for Good_4_713_40.00',

          /* Unit Price  */
          'price': '40.00',

          /* Organization Name as it Appears */
          'brand': 'People for Good',

          /* Form Type */
          'category': 'EventForm',

          /* Number of Tickets of this Type Purchased */
          'quantity': 1,

          /* Selected Value or Ticket Name */
          'name': 'Gala Silver Ticket'
        },
        {
            'id': 'People for Good_4_713_80.00',

            /* Unit Price */
            'price': '80.00',

            /* Organization Name as it Appears */
            'brand': 'People for Good',

            /* Form Type */
            'category': 'EventForm',

            /* Number of Tickets of this Type Purchased */
            'quantity': 2,

            /* Selected Value or Ticket Name */
            'name': 'Gala Gold Ticket'
        }
        ]
      }
    }]
  }];

For more information on Google Tag Manager usage: