Boost Your Business
Web Analytics
1656919201

How To Set Up Advanced E-commerce With Google Tag Manager

Standard ecommerce only collects data on completed transactions, while enhanced ecommerce provides significantly more data collection options. They can be used to set up the data transfer on product card impressions, order placement steps, and other user actions on the site.

I'll break down the nuances of setting up advanced e-commerce with Google Tag Manager.

Why do you need to set up advanced e-commerce?

Advanced eCommerce allows you to set up the users actions data transmission:

  1. Product Impressions.
  2. Product Clicks.
  3. Product Details Impressions.
  4. Adding a Product to a Product Cart.
  5. Removing a Product from a Product Cart.
  6. Checkout Steps.
  7. Checkout Options.
  8. Purchases.
  9. Refunds.
  10. Promotion Impressions / Indoor advertising shows.
  11. Promotion Clicks / Clicks on internal advertising.

Tracking any of these user actions can also be set up as part of standard Google Analytics reports, but it won't be as convenient to work with this data later.

Advanced e-commerce allows:

  1. Get data on the full sales cycle, from browsing products in the catalog to checkout.
  2. Track the in-house advertising effectiveness.
  3. Store this data in a single, convenient group of reports for further processing.

Google Analytics has a limit on the maximum data amount sent at once (~8000 bytes). That's why in all the codes you need to write data to Data Layer for no more than 15 products at once. If you need to send data on more items — break it into blocks of 15 products and send them in separate events.

Setting up Google Analytics and Google Tag Manager

You need to activate the extended e-commerce reports in Google Analytics. To do this, in the “Administrator” section of the e-commerce settings, enable “Enhanced Ecommerce Reporting” option:

Setting up Google Analytics and Google Tag Manager
Next, configure GTM to read data from the Data Layer. To do this, we create three custom variables “Data Layer Variable”.

1. GTM EE Event Category

Variable name: GTM EE Event Category, variable name in dataLayer: gtm-ee-event-category.

GTM EE Event Category

2. GTM EE Event Action

Variable name: GTM EE Event Action, variable name in dataLayer: gtm-ee-event-action:

GTM EE Event Action

3. GTM EE Event Non-Interaction

Variable name: GTM EE Event Non-Interaction, variable name in dataLayer: gtm-ee-event-non-interaction.

GTM EE Event Non-Interaction

The values of the first two variables will be used as the category and action of the event sent to Google Analytics. The third one indicates whether the sent event will affect the bounce rate.

Create a trigger, which will activate the data sending

Trigger name: GTM EE Event, type: custom event. Event name: gtm-ee-event.

Create a trigger, which will activate the sending of data

Create a tag that will send the data

Tag name: Enhanced Ecommerce, type: Universal Analytics. Tracking ID: Specify the Google Analytics ID for the resource to which the data will be sent.

To simplify GTM configuration, you can create a custom variable constant in which you specify the resource ID:

Create a tag that will send the data

Adding settings:

  • tracking type: event;
  • category: "GTM EE Event Category" variable;
  • Action: "GTM EE Event Action" variable;
  • Non-Interaction: "GTM EE Event Non-Interaction" variable.

Under "Advanced Settings" — "E-Commerce" check "Enable Advanced E-Commerce Functions" and "Use Data Level". As an activation trigger — specify "GTM EE Event".

GTM EE Event

Let's break down code examples for each of the extended e-commerce events.

1. Product Impressions

Track product impressions in any lists on the site: both product listings on the category page and cross-sell blocks ("Recommended Products", "Promotional Offers" and so on).

There are two options in this case:

  1. Simple — to send data about all products that are on the page.
  2. Sophisticated — send data only for those items that are in the visible area. When the user moves around the page, constantly check when new items are in the visible area and send data about them to Google Analytics.

Read how to see if an element is in the visible area.

Possible scenarios:

  1. The user went to the category page, there are 6 products in the visible area (two rows with 3 products in each), — we send data about the viewing of these 6 products.
  2. The user scrolled down the page; as a result the first row of items went out of the visible area, and instead the third row of items was visible.
  3. The user scrolled up the page, the third row of products disappeared, and the first row appeared again — no data is sent.

Example code in GTM:

<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'ecommerce': {
    'currencyCode': 'USD',
    'impressions': [
     {
       'name': 'Product 1',
       'id': 'ID1',
       'price': '23.5',
       'brand': 'Brand 1',
       'category': 'Category 1/Subcategory 11',
       'variant': 'Variant 1',
       'list': 'List 1',
       'position': 1
     },
     {
       'name': 'Product 2',
       'id': 'ID2',
       'price': '14',
       'brand': 'Brand 2',
       'category': 'Category 2/Subcategory 21',
       'variant': 'Variant 3',
       'list': 'List 1',
       'position': 2
     }]
  },
  'event': 'gtm-ee-event',
  'gtm-ee-event-category': 'Enhanced Ecommerce',
  'gtm-ee-event-action': 'Product Impressions',
  'gtm-ee-event-non-interaction': 'True',
});
</script>

Example code in GTag:

<script>
gtag('event', 'view_item_list', {
  'items': [
    {
      'name': 'Product 1',
      'id': 'ID1',
      'price': 23.5,
      'brand': 'Brand 1',
      'category': 'Category 1/Subcategory 11',
      'variant': 'Variant 1',
      'list_name': 'List 1',
      'list_position': 1
    },
    {
      'name': 'Product 2',
      'id': 'ID2',
      'price': 14,
      'brand': 'Brand 2',
      'category': 'Category 2/Subcategory 21',
      'variant': 'Variant 3',
      'list_name': 'List 1',
      'list_position': 2
    }
  ]
});
</script>

Code description and variables

  1. currencyCode (string optional variable) — specifies the local currency according to ISO 4217.
  2. Supported currencies list. If the local currency differs from the one specified in the view settings, the conversion will be performed at the previous day rate.
  3. name (string mandatory variable) — product name.
  4. id (strict required variable) — product's identifier (SKU).
  5. price (optional string variable) — the price of one unit of the product. A dot is used as a decimal separator.
  6. brand (optional string variable) is the product brand.
  7. category (optional string variable) — category the product belongs to. You can specify a category hierarchy (up to 5 levels), separating levels with a slash: "Clothing/Menswear/Shirts".
  8. variant (optional string variable) — product's variant: any product parameter, which is changed without changing product's identifier (color, size, etc.).
  9. list (a string optional variable) — the list where the product was shown ("Promo items", "Top seller").
  10. position (optional variable, always an integer) — product position in the list. The left top position is number one.
  11. event (string variable) — the event which will trigger the enhanced ecommerce tag in GTM.
  12. gtm-ee-event-category (string variable) — Specifies the event category that will be sent to Google Analytics.
  13. gtm-ee-event-action (string variable) — Specifies the event action to be sent to Google Analytics.
  14. gtm-ee-event-non-interaction (string variable) — Specifies whether the sent event will affect the session failure rate. In this case it won't, because the user didn't perform the target action, but only viewed the products.

In the case of string mandatory variables, you must specify at least one of two values: the product name or its identifier. To send data on returns of certain products, their identifiers must be used.

Result

By submitting this data, the Product List Performance report will show these results:

By submitting this data, the Product List Performance report will show these results

If you click on the list name and the additional parameter with the the first level category, we get:

If you click on the name of the list and the additional parameter enable the category of the first level, we get

2. Product Clicks

Tracking clicks on links to product cards. Data about the product that interested the user and the product list name in which it was shown are sent to Google Analytics. Here are the most common product lists examples:

  1. A products listing in the category.
  2. Site search results.
  3. Cross-sales blocks.
  4. Promotional goods lists.

Example code in GTM:

<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'ecommerce': {
    'currencyCode': 'USD',
    'click': {
      'actionField': {'list': 'List 1'},
      'products': [{
       'name': 'Product 1',
       'id': 'ID1',
       'price': '23.5',
       'brand': 'Brand 1',
       'category': 'Category 1/Subcategory 11',
       'variant': 'Variant 1',
       'position': 1
      }]
    }
  },
  'event': 'gtm-ee-event',
  'gtm-ee-event-category': 'Enhanced Ecommerce',
  'gtm-ee-event-action': 'Product Clicks',
  'gtm-ee-event-non-interaction': 'False',
});
</script>

Example code in GTag:

<script>
gtag('event', 'select_content', {
  'content_type': 'product',
  'items': [
    {
      'name': 'Product 1',
      'id': 'ID1',
      'price': 23.5,
      'brand': 'Brand 1',
      'category': 'Category 1/Subcategory 11',
      'variant': 'Variant 1',
      'list_name': 'List 1',
      'position': 1
    }
  ]
});
</script>

Code description and variables

  1. list (string optional variable) — the product list name where the product the user clicked on is located. If the product doesn't belong to any list, you should send an empty string (in this case the reports will contain not set instead of the list name).
  2. All other variables are the same as before.
  3. In this case the event that affects the bounce rate is sent: the variable gtm-ee-event-non-interaction takes the value False.

Result

After sending this data in the “Product List Performance” report, there will be changes in the "Products List Clicks" and "Product List CTR" metrics:

Product Clicks

If you click on the products list name, we get information on which product you clicked:

If you click on the name of the list of products, we get information on which product you clicked

3. Product Detail Impressions

Tracking product card impressions. The same product data is sent to Google Analytics as in the "Product Clicks" event, but without the product position in the list.

The main card product data can be sent along with additional product data (e.g., products in cross-sell blocks) in the same event.

The example shows how to send data about a product card view (detail array), and about two products in an additional List 2 block (impressions array).

Example code in GTM:

<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'ecommerce': {
    'currencyCode': 'USD',
    'detail': {
      'actionField': {'list': 'List 1'},
      'products': [{
        'name': 'Product 1',
        'id': 'ID1',
        'price': '23.5',
        'brand': 'Brand 1',
        'category': 'Category 1/Subcategory 11',
        'variant': 'Variant 1'
      }]
    },
    'impressions': [
     {
       'name': 'Product 3',
       'id': 'ID3',
       'price': '17.75',
       'brand': 'Brand 2',
       'category': 'Category 1/Subcategory 12',
       'variant': 'Variant 1',
       'list': 'List 2',
       'position': 1
     },
     {
       'name': 'Product 4',
       'id': 'ID4',
       'price': '12.5',
       'brand': 'Brand 3',
       'category': 'Category 1/Subcategory 13',
       'variant': 'Variant 1',
       'list': 'List 2',
       'position': 2
     }]
  },
  'event': 'gtm-ee-event',
  'gtm-ee-event-category': 'Enhanced Ecommerce',
  'gtm-ee-event-action': 'Product Details',
  'gtm-ee-event-non-interaction': 'True',
});
</script>

Example code in GTag:

<script>
gtag('event', 'view_item', {
  'items': [
    {
      'name': 'Product 1',
      'id': 'ID1',
      'price': 23.5,
      'brand': 'Brand 1',
      'category': 'Category 1/Subcategory 11',
      'variant': 'Variant 1',
      'list_name': 'List 1',
      'list_position': 2
    }
  ]
});
gtag('event', 'view_item_list', {
  'items': [
    {
      'name': 'Product 3',
      'id': 'ID3',
      'price': 17.75,
      'brand': 'Brand 2',
      'category': 'Category 1/Subcategory 12',
      'variant': 'Variant 1',
      'list_name': 'List 2',
      'list_position': 1
    },
    {
      'name': 'Product 4',
      'id': 'ID4',
      'price': 12.5,
      'brand': 'Brand 3',
      'category': 'Category 1/Subcategory 13',
      'variant': 'Variant 1',
      'list_name': 'List 2',
      'list_position': 2
    }
  ]
});
</script>

Code description and variables

  1. All variables are the same as before.
  2. The sent event will not affect the bounce rate: the variable gtm-ee-event-non-interaction takes the value True.
  3. If the user gets to the product card from an external source, an empty value must be passed to the list variable.

Result

After sending this data, the "Product List Performance" report will show data on the second list:

After sending this data, the Product List Performance report will show data on the second list

And to the goods on this list:

And to the goods on this list

Also in the "Purchase Analysis" — "Shopping Behavior" report will appear a session with product card impressions:

a session with the viewing of goods will appear

At the time the screenshot was taken, the session had already ended, so the value of "No item added to cart" equals one.

4. Adding a Product to a Product Cart

Tracking of additions to cart by users regardless of where the action was performed: on the category page, on the product card or from the cart itself (for example, from the "Add-ons and Services" block).

Adding a Product to a Product Cart

Example code in GTM:

<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'ecommerce': {
    'currencyCode': 'USD',
    'add': {
      'products': [{
        'name': 'Product 1',
        'id': 'ID1',
        'price': '23.5',
        'brand': 'Brand 1',
        'category': 'Category 1/Subcategory 11',
        'variant': 'Variant 1',
        'quantity': 3
       }]
    }
  },
  'event': 'gtm-ee-event',
  'gtm-ee-event-category': 'Enhanced Ecommerce',
  'gtm-ee-event-action': 'Adding a Product to a Shopping Cart',
  'gtm-ee-event-non-interaction': 'False',
});
</script>

Example code in GTag:

<script>
gtag('event', 'add_to_cart', {
  'items': [
    {
      'name': 'Product 1',
      'id': 'ID1',
      'price': 23.5,
      'brand': 'Brand 1',
      'category': 'Category 1/Subcategory 11',
      'variant': 'Variant 1',
      'quantity': 3
    }
  ]
});
</script>

Code description and variables

  1. quantity (optional variable, always an integer) — the number of items added to the cart.
  2. All other variables are the same as before.
  3. The sent event affects the bounce rate.

Result

After sending the data, the value of the indicator "Number of additions to cart" in the "Product List Performance" report changes:

Product List Performance 

If you click on the list name, you will get information about which of the items in the list was added to the cart:

If you click on the name of the list, you will get information about which of the items in the list was added to the cart

A session with an item added to cart will appear in the Purchasing Analysis — Buying Behavior report:

A session with an item added to cart will appear in the Purchasing Analysis — Buying Behavior report

5. Removing a Product from a Product Cart

Tracking items deleted from the cart. In the products array you should list all the items that the user removed from the cart. If the cart is completely cleared, all the items that were in it should be listed.

Example code in GTM:

<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'ecommerce': {
    'currencyCode': 'USD',
    'remove': {
      'products': [{
        'name': 'Product 1',
        'id': 'ID1',
        'price': '23.5',
        'brand': 'Brand 1',
        'category': 'Category 1/Subcategory 11',
        'variant': 'Variant 1',
        'quantity': 1
      }]
    }
  },
  'event': 'gtm-ee-event',
  'gtm-ee-event-category': 'Enhanced Ecommerce',
  'gtm-ee-event-action': 'Removing a Product from a Shopping Cart',
  'gtm-ee-event-non-interaction': 'False',
});
</script>

Example code in GTag:

<script>
gtag('event', 'remove_from_cart', {
  'items': [
    {
      'name': 'Product 1',
      'id': 'ID1',
      'price': 23.5,
      'brand': 'Brand 1',
      'category': 'Category 1/Subcategory 11',
      'variant': 'Variant 1',
      'quantity': 1
    }
  ]
});
</script>

Code description and variables

  1. quantity (an integer optional variable) — the number of items removed from the cart.
  2. All other variables are the same as before.
  3. The sent event affects the bounce rate.

Result

Standard reports do not display data on items removed from the cart, but you can create your own report with the following settings:

  1. Parameter.
  2. Product.
  3. Metric.
  4. Product list impressions.
  5. Product list click.
  6. Product Adds To Cart.
  7. Quantity Added To Cart.
  8. Product Removes From Cart.
  9. Quantity Removed From Cart.

Report settings:

Report settings 

Result:

Number of items removed from cart

The parameters "Number of items added to cart" and "Number of items removed from cart" show the numbers specified in the quantity variable of the corresponding events. And "Number of items added to cart" and "Number of items removed from cart" show the number of their corresponding events.

6. Checkout Steps

It's about tracking a user's movement through predefined checkout steps.

As an example, let's set up the following checkout funnel in Google Analytics (each step doesn't have to be a real page):

Checkout Steps

Step 1. Go to cart.

Step 2. Entering contact information.

Step 3. Selecting delivery option.

Step 4. Selecting payment option.

Step 5. Order confirmation.

Step 6. Thank You Page.

After the user performs the actions required at each step, data about this action should be sent to the Data Layer.

The actions for this funnel are:

  1. The user goes to the cart page.
  2. Successful sending the completed form with contact data.
  3. Successful sending data about the delivery method.
  4. Successful sending data on the payment method.
  5. Click on the "Confirm Order" button.
  6. The user is redirected to Thank You Page.

Example code in GTM:

<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'ecommerce': {
    'currencyCode': 'USD',
    'checkout': {
      'actionField': {'step': 1},
      'products': [{
        'name': 'Product 1',
        'id': 'ID1',
        'price': '23.5',
        'brand': 'Brand 1',
        'category': 'Category 1/Subcategory 11',
        'variant': 'Variant 1',
        'quantity': 2
      }]
    }
  },
  'event': 'gtm-ee-event',
  'gtm-ee-event-category': 'Enhanced Ecommerce',
  'gtm-ee-event-action': 'Checkout Step 1',
  'gtm-ee-event-non-interaction': 'False',
});
</script>

Example code in GTag. First step:

<script>
gtag('event', 'begin_checkout', {
  'items': [
    {
      'name': 'Product 1',
      'id': 'ID1',
      'price': 23.5,
      'brand': 'Brand 1',
      'category': 'Category 1/Subcategory 11',
      'variant': 'Variant 1',
      'quantity': 2
    }
  ]
});
</script>

Next steps:

<script>
gtag('event', 'checkout_progress', {
  "checkout_step": 2,
  'items': [
    {
      'name': 'Product 1',
      'id': 'ID1',
      'price': 23.5,
      'brand': 'Brand 1',
      'category': 'Category 1/Subcategory 11',
      'variant': 'Variant 1',
      'quantity': 2
    }
  ]
});
</script>

Code description and variables

  1. step (integer optional variable) — step number in the funnel. At each step, you should assign a corresponding value to this variable, the same value should also be specified in the gtm-ee-event-action variable.
  2. The sent event affects the bounce rate.

Result

When sending an event about the order placement beginning (in this example — when the user gets to the cart page, step 1):

  1. A checkout session will appear in the "Purchase Analysis" — "Customer Behavior" report:

A checkout session will appear

  1. The Product List Performance report will display data on the product list from which the ordering process was initiated (the indicator is the number of completed product purchases):

  The Product List Performance report will display data on the product list from which the ordering process was initiated (the indicator is the number of completed product purchases)

Clicking on the name, we get the same data, but in the goods section from this list:

Clicking on the name, we get the same data, but in the section of goods from this list

If the user has successfully completed all steps of the funnel and placed an order, we get the following data in the "Purchase Analysis" — "Shopping behavior" report:

we get the following data

Step one-five

The sixth step and data on processed transactions

The sixth step and data on processed transactions

Transactions will appear after you send the data on purchases made.

If there were gaps at any of the stages, the "Purchase Analysis" — "Checkout Behavior" report will be like this (a gap at the delivery method selection stage):

a gap at the delivery method selection stage

If the checkout was started from the second step, there will be no data on that checkout in the report:

If the checkout was started from the second step, there will be no data on that checkout in the report

The "Product Checkouts" parameter value is zero. At the same time, the event sent in the second step is in the reports:

At the same time, the event sent in the second step is in the reports

7. Checkout Options

It's about tracking the choice of one of the options for placing an order at each step of the funnel.

For example, the site has the following delivery methods:

  1. Self-delivery.
  2. Delivery by "DHL".
  3. Delivery service InTme.

Example code in GTM for the "DHL" delivery scenario in step 3:

<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'ecommerce': {
    'currencyCode': 'USD',
    'checkout': {
      'actionField': {'step': 3, 'option': 'DHL'},
      'products': [{
        'name': 'Product 1',
        'id': 'ID1',
        'price': '23.5',
        'brand': 'Brand 1',
        'category': 'Category 1/Subcategory 11',
        'variant': 'Variant 1',
        'quantity': 2
      }]
    }
  },
  'event': 'gtm-ee-event',
  'gtm-ee-event-category': 'Enhanced Ecommerce',
  'gtm-ee-event-action': 'Checkout Step 3',
  'gtm-ee-event-non-interaction': 'False',
});
</script>

<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'ecommerce': {
    'currencyCode': 'USD',
    'checkout': {
      'actionField': {'step': 4, 'option': 'Bank card'},
      'products': [{
        'name': 'Product 1',
        'id': 'ID1',
        'price': '23.5',
        'brand': 'Brand 1',
        'category': 'Category 1/Subcategory 11',
        'variant': 'Variant 1',
        'quantity': 2
      }]
    }
  },
  'event': 'gtm-ee-event',
  'gtm-ee-event-category': 'Enhanced Ecommerce',
  'gtm-ee-event-action': 'Checkout Step 4',
  'gtm-ee-event-non-interaction': 'False',
});
</script>

And payment methods:

  1. By bank card.
  2. Cash.
  3. Cash on delivery.

Example code in GTag:

<script>
gtag('event', 'checkout_progress', {
  'checkout_step': 3,
  'checkout_option': 'DHL',
  'items': [
    {
      'name': 'Product 1',
      'id': 'ID1',
      'price': 23.5,
      'brand': 'Brand 1',
      'category': 'Category 1/Subcategory 11',
      'variant': 'Variant 1',
      'quantity': 2
    }
  ]
});
</script>

Example code for the bank card payment scenario in step 4:

<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'ecommerce': {
    'currencyCode': 'USD',
    'checkout': {
      'actionField': {'step': 4, 'option': 'Bank card'},
      'products': [{
        'name': 'Product 1',
        'id': 'ID1',
        'price': '23.5',
        'brand': 'Brand 1',
        'category': 'Category 1/Subcategory 11',
        'variant': 'Variant 1',
        'quantity': 2
      }]
    }
  },
  'event': 'gtm-ee-event',
  'gtm-ee-event-category': 'Enhanced Ecommerce',
  'gtm-ee-event-action': 'Checkout Step 4',
  'gtm-ee-event-non-interaction': 'False',
});
</script>

Example code in GTag:

<script>
gtag('event', 'checkout_progress', {
  'checkout_step': 4,
  'checkout_option': 'Bank card',
  'items': [
    {
      'name': 'Product 1',
      'id': 'ID1',
      'price': 23.5,
      'brand': 'Brand 1',
      'category': 'Category 1/Subcategory 11',
      'variant': 'Variant 1',
      'quantity': 2
    }
  ]
});
</script>

Code description and variables

  1. option (string optional variable) — the option selected by the user at this or that step.
  2. The sent events will affect the bounce rate.

Result

The data on the selected scenarios are displayed in the "Purchase Analysis" — "Checkout Behavior" report:

The data on the selected scenarios

Purchase Analysis

If an option has not been set, a "not set" will be displayed:

If an option has not been set

8. Purchases

Tracking transactions made through the site. Data is sent when the user reaches the "Thank you for your purchase" page.

Example code in GTM:

<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'ecommerce': {
    'currencyCode': 'USD',
    'purchase': {
      'actionField': {
        'id': 'TID1',
        'affiliation': 'Online Store',
        'revenue': '91.4',
        'tax': '9.4',
        'shipping': '35',
        'coupon': 'Coupon 1'
      },
      'products': [{  
        'name': 'Product 1',
        'id': 'ID1',
        'price': '23.5',
        'brand': 'Brand 1',
        'category': 'Category 1/Subcategory 11',
        'variant': 'Variant 1',
        'quantity': 2,
        'coupon': ''
       }]
    }
  },
  'event': 'gtm-ee-event',
  'gtm-ee-event-category': 'Enhanced Ecommerce',
  'gtm-ee-event-action': 'Purchase',
  'gtm-ee-event-non-interaction': 'False',
});
</script>

Example code in GTag:

<script>
gtag('event', 'purchase', {
  'transaction_id': 'TID1',
  'affiliation': 'Online Store',
  'value': 91.4,
  'currency': 'USD',
  'tax': 9.4,
  'shipping': 35,
  'coupon': 'Coupon 1',
  'items': [
    {  
      'name': 'Product 1',
      'id': 'ID1',
      'price': 23.5,
      'brand': 'Brand 1',
      'category': 'Category 1/Subcategory 11',
      'variant': 'Variant 1',
      'quantity': 2,
      'coupon': ''
    }
  ]
});
</script>

Code description and variables

  1. id (string mandatory variable) — the unique transaction identifier.
  2. affiliation (string optional variable) — the store or branch where the transaction was made.
  3. revenue (optional string variable) — total amount of the transactions, including shipping cost and tax. If no value is specified, the amount will be calculated based on the cost and items number in the transaction.
  4. tax (string optional variable) — the sum of all taxes for this transaction.
  5. shipping (optional string variable) — the delivery cost of the order.
  6. coupon (optional string variable) — a coupon or a promo code that was used at checkout. Can be specified both for the entire order and for individual products.
  7. Sent events will affect the bounce rate.

Result

In the "Product performance" report will appear information on sales by products:

report will appear information on sales by products

The "Sales Performance" report displays all sent data by transactions:

report displays all sent data by transactions

When you click on the ID, the products in that transaction are displayed:

When you click on the ID, the products in that transaction are displayed

The Product List Performance report contains data on which product was purchased from which list:

The Product List Performance report contains data on which product was purchased from which list

When you click on the name we get the same data, but in the goods section of this list:

When you click on the name we get the same data, but in the section of goods in this list

The "Marketing" — "Order Coupon" report will show data on the use of coupons/promocodes within the order:

report will show data on the use of coupons within the order

The "Income" value in this case is equal to the full transaction amount:

value in this case is equal to the full amount of the transaction

In the report "Marketing" — "Product Coupon" will appear data on the use of coupons/promocodes in the context of products:

promocodes in the context of products

The value of the "Product Income" indicator is equal to the similar indicator in the "Product Performance" report.

The "Marketing" — "Affiliate Code" report shows data on stores branches where transactions were made (names are taken from the affiliation variable):

names are taken from the affiliation variable

Within the same session, the same transaction is not counted a second time:

Within the same session, the same transaction is not counted a second time

However, there are two corresponding events:

there are two corresponding events

If you send transaction data with the same identifier to analytics, the corresponding figures will be added together:

the corresponding figures will be added together

This is why it is very important that when you reload the page this code is not displayed again.

9. Refunds

This is about tracking cancelled transactions or returning certain items. Cancelled transactions are possible if no more than six months have passed since the transaction date. If the specified transaction ID is not found, the request will be ignored.

If the site does not have transaction cancellation functionality, this data can be sent directly from the internal system using Measurement Protocol.

Full refund

If you cancel the purchase completely, it is enough to specify the transaction ID.

Example code for a complete transaction cancellation from a previous event in GTM:

<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'ecommerce': {
    'refund': {
      'actionField': {'id': 'TID1'}
    }
  },
  'event': 'gtm-ee-event',
  'gtm-ee-event-category': 'Enhanced Ecommerce',
  'gtm-ee-event-action': 'Full Refund',
  'gtm-ee-event-non-interaction': 'False',
});
</script>

Example code in GTag:

<script>
gtag('event', 'refund', { 'transaction_id': 'TID1' })
</script>

Code description and variables

  1. id (string mandatory variable) — the cancelled transaction identifier.
  2. The events sent will affect the bounce rate.

Result

In the Product List Performance report, the data does not change:

In the Product List Performance report, the data does not change

In the report "Product Performance" the value of the indicator "Product Refund Amount" has been changed:

Product Refund Amount

In the "Sales Performance" report the value of the "Refund Amount" indicator has been changed:

indicator has changed

In this case, this value is the same as the income indicator for this transaction.

Returns of certain items

When returning certain products, you must specify the transaction ID, the ID and the quantity of each of the returned products in that transaction.

Example code in GTM for a transaction with TID2 and a product with ID2 (the second product from the Product Impressions event):

<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'ecommerce': {
    'refund': {
      'actionField': {'id': 'TID2'},
      'products': [
            {'id': 'ID2', 'quantity': 1}
       ]
     }
  },
  'event': 'gtm-ee-event',
  'gtm-ee-event-category': 'Enhanced Ecommerce',
  'gtm-ee-event-action': 'Partial Refund',
  'gtm-ee-event-non-interaction': 'False',
});
</script>

Example code in GTag:

<script>
gtag('event', 'refund', {
  'transaction_id': 'TID2',
  'items': [
    {
      'id': 'ID2',
      'quantity': 1
    }
  ]
});
</script>

Code description and variables

  1. id in the actionField (string required variable) — transaction identifier in which the products are returned.
  2. id in the products array (string required variable) — identifier of the returned products.
  3. quantity (mandatory variable, always an integer) — returned products number.
  4. The sent events will affect the bounce rate.

Result

In the “Product Performance” report, the “Product Refund Amount” value became equal to the one item price, since only one item was returned:

value became equal to the price of one item, since only one item was returned

In the "Sales Performance" report, the "Refund Amount" value indicator is equal to the price per unit of the product:

indicator is equal to the price per unit of product

For a full refund, it was equal to the full transaction value.

10. Promotion Impressions

Tracking allows you to get data about the number of times an internal advertising campaign's banner has been displayed.

The implementation is similar to the Product Impressions event: either we send data on all the internal ad elements on the page, or only those that have been caught in the visible area.

Actions with popups are completely similar to banners.

Example code in GTM:

<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'ecommerce': {
    'promoView': {
      'promotions': [
      { 
        'id': 'PromoID1',
        'name': 'Promo 1',
        'creative': 'Banner 1',
        'position': 'slot1'
      },
      {
        'id': 'PromoID2',
        'name': 'Promo 2',
        'creative': 'Banner 1',
        'position': 'slot2'
      }]
    }
  },
  'event': 'gtm-ee-event',
  'gtm-ee-event-category': 'Enhanced Ecommerce',
  'gtm-ee-event-action': 'Promotion Impressions',
  'gtm-ee-event-non-interaction': 'True',
});
</script>

Example code in GTag:

<script>
gtag('event', 'view_promotion', {
  'promotions': [
    {
      'id': 'PromoID1',
      'name': 'Promo 1',
      'creative_name': 'Banner 1',
      'creative_slot': 'slot1'
    },
    {
      'id': 'PromoID2',
      'name': 'Promo 2',
      'creative_name': 'Banner 1',
      'creative_slot': 'slot2'
    }
  ]
});
</script>

Code description and variables

  1. id (string mandatory variable) — the ID of the shown internal advertising campaign.
  2. name (string mandatory variable) — the name of the shown internal advertising campaign.
  3. creative (string optional variable) — name of the element of the shown internal advertising campaign.
  4. position (string optional variable) — position of the element of the shown internal advertising campaign.
  5. Sent events will not affect the bounce rate.

In the case of the mandatory variable, you must specify at least one of two values: the company name or its identifier.

Result

When you send the data in the report "Marketing" — "Internal Promotion" we get the numbers of banner impressions in the context of internal campaigns:

we get the numbers of banner views in the context of internal campaigns

11. Promotion Clicks

It's about sending data about clicks on banners of an internal advertising campaign. The data obtained will allow you to determine the most effective banners and their location on the pages of the site.

Example code in GTM:

<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'ecommerce': {
    'promoClick': {
      'promotions': [{
        'id': 'PromoID1',
        'name': 'Promo 1',
        'creative': 'Banner 1',
        'position': 'slot1'
      }]
    }
  },
  'event': 'gtm-ee-event',
  'gtm-ee-event-category': 'Enhanced Ecommerce',
  'gtm-ee-event-action': 'Promotion Clicks',
  'gtm-ee-event-non-interaction': 'False',
});
</script>

Example code in GTag:

<script>
gtag('event', 'select_content', {
  'promotions': [
    {
      'id': 'PromoID1',
      'name': 'Promo 1',
      'creative_name': 'Banner 1',
      'creative_slot': 'slot1'
    }
  ]
});
</script>

Code description and variables

  1. id (string mandatory variable) — the ID of the clicked internal advertising campaign.
  2. name (string mandatory variable) — the clicked internal advertising campaign name.
  3. creative (optional string variable) — the clicked element name of the internal advertising campaign.
  4. position (string optional variable) — the clicked element position of the internal advertising campaign.
  5. The sent events will affect the bounce rate.

In the case of a mandatory string variable, at least one of two values should be specified: the name of the campaign shown, or its identifier.

Result

After sending this data, the "Marketing" — "Internal Promotion" report will change the values of "Clicks (internal campaign)" and "CTR (internal campaign)":

report will change the values

In order for the data on sales in the context of internal advertising campaigns to appear in this report, in the events Product Impressions, Product Clicks and Product Details you must specify the corresponding campaign name in the List variable. 

The Product Clicks event code will look like this:

<script>window.dataLayer = window.dataLayer || 
[];dataLayer.push({ 'ecommerce': {   
'currencyCode': 'USD',   'click': {     
'actionField': {'list': 'Promo 1'},     
'products': [{      'name': 'Product 1',      
'id': 'ID1',      'price': '23.5',      
'brand': 'Brand 1',      'category': 
'Category 1/Subcategory 11',      'variant': 'Variant 1',      
'position': 1     }]   } }, 'event': 'gtm-ee-event', 
'gtm-ee-event-category': 'Enhanced Ecommerce', 
'gtm-ee-event-action': 'Product Clicks', 
'gtm-ee-event-non-interaction': 'False',});</script>

When submitting ordering data (Purchases) in the promo variable, you do not need to specify the advertising campaign name.

The report "Marketing" — "Internal Promotion" will have the following data:

you do not need to specify the name of the advertising campaign

The executed transaction parameters:

Parameters of the executed transaction

Remember

What you can find out by setting up all advanced e-commerce events:

  1. How users move through the configured sales funnel.
  2. How the product attractiveness changes for users when it's displayed in different lists or on different positions in the same list.
  3. Which banners are most effective at a given location on the page.
  4. What options bundles selected by users at checkout are the most popular.
  5. Which product option is most frequently purchased or returned.
  6. Identification of products which cards are most frequently clicked on, but less frequently added to cart and/or purchased.

All data is displayed in reports for this type of data, and if standard reports are not enough — you can create your own and group in it an individual parameters and indicators set, as in the item "Removing goods from the cart”.

Topics:
8
0
Found a mistake? Select it and press Ctrl + Enter

Subscribe

to the most useful newsletter on internet marketing
Cookies policy
Netpeak processes information about your visit using cookies to improve site performance. By continuing to browse our site, you agree to the use of these cookies. More information — Accept