Using enhanced eCommerce data for Remarketing via GTM (Google Tag Manager)

As I mentioned in my previous article Tracking most valuable customers based on behavior we can use the data that is sent anyhow to Google Analytics in the dataLayer and fire it into a CM (Custom Metric).
In this article, I will attempt to technically (step by step) illustrate how this analysis may be achieved.

Prerequisite:

1. Enhanced eCommerce implemented via GTM
2. Manage account permission in GTM
3. Go over the article Tracking most valuable customers based on behavior

Ready? Lets go!

Every time a customer adds an item to his cart or removes an item from his cart the following code is sent to GTM:

dataLayer.push({
‘event’: ‘addToCart’,
‘ecommerce’: {
‘currencyCode’: ‘EUR’,
‘add’: {
< ‘products’: [{
‘name’: ‘Triblend Android T-Shirt’,
‘id’: ‘12345’,
‘price’: ‘15.25’,
‘brand’: ‘Google’,
‘category’: ‘Apparel’,
‘variant’: ‘Gray’,
‘quantity’: 1
}]
}
}
});

We can use any of these parameters to send as a CM or as a CD (Custom Dimension) to our GA account.
As you see, there are lots of valuable parameters we can use. I’ll illustrate how to send a CM every time an item is being added to the cart and removed from the cart.

Step 1

Find the tag that is triggered with the “addToCart” event.
In that tag click on the edit button for configuring the tag, see Figure A.

Configuring the addToCart tag in GTM

Figure A: Configuring the addToCart tag

Step 2

Following the figures on Figure B:
1. Under “More settings”
2. Select “Custome Metrics”
3. Choose the Index of your CM that will receive the data
4. Start writing “{{”
5. Roll down with the scroll bar and select “New Variable”

Adding a Custom Metric to the addToCart tag in GTM

Figure B: Adding a CM to the addToCart tag

Step 3

Once you select the “New Variable” the Create Variable wizard shows up (see Figue C).
1. Choose the Data Layer Variable
2. Add the exact Data Layer Variable Name:
ecommerce.add.products.0.quantity
3. Make sure the Data Layer Version is set to Version 2

Give your new variable a name and hit the Save button.

Setting a new Variable that gets the amount of items that are added to cart in GTM

Figure C: Setting a new Variable that gets the amount of items that are added to cart

Save the addToCart tag (after adding the CM and the Variable that serves the data).

For the “removeFromCart” we will need almost all the same besides the following:
In Step 1, we’ll need to trace the tag that is triggered with the “removeFromCart” event.
In Step2, before the “{{” we’ll add a minus sign “-“,so it will look like this: -{{Name of Variable}}
In Step 3, we’ll insert in the Data Layer Variable Name :

ecommerce.remove.products.0.quantity

Finally, hit the Publish button, and we’re all set.

You can build a custom report to see it live:

Custom report that contains the new Custom Metric with data

Figure D: Custom report that contains the new CM with data

As you can see, after adding an item to the cart and then removing, the total “Items in cart” for this session (in green) is 0.

Now we can build a session level segment (see figure E), that will include only an audience that added (after reducing items they’ve removed), at least 2 items to their cart.

Building a segment of customers that added at least 2 items to their cart

Figure E: Building a segment of customers that added at least 2 items to their cart

1. Find your CM
2. Make sure you choose “per session”

Start the course now (free)