13Jan

Reuse Google Analytics eCommerce Data for Marketing Tag via GTM

Tag-ManagerGoogle Tag Manager (GTM) makes tracking a lot easier for Google Analytics and its new version Universal Analytics. There is a new format of eCommerce tracking called enhanced eCommerce for Universal Analytics tags. To track the purchase, you would need to put some dataLayer code on the purchase confirmation page like the example below.


<script>
// Send transaction data with a pageview if available
// when the page loads. Otherwise, use an event when the transaction
// data becomes available.
dataLayer.push({
'ecommerce': {
'purchase': {
'actionField': {
'id': 'T12345', // Transaction ID. Required for purchases and refunds.
'affiliation': 'Online Store',
'revenue': '35.43', // Total transaction value (incl. tax and shipping)
'tax':'4.90',
'shipping': '5.99',
'coupon': 'SUMMER_SALE'
},
'products': [{ // List of productFieldObjects.
'name': 'Triblend Android T-Shirt', // Name or ID is required.
'id': '12345',
'price': '15.25',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Gray',
'quantity': 1,
'coupon': '' // Optional fields may be omitted or set to empty string.
},
{
'name': 'Donut Friday Scented T-Shirt',
'id': '67890',
'price': '33.75',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Black',
'quantity': 1
}] }
}
});
</script>

And after that, you just need to tick a checkbox in the Universal Analytics tag in GTM to enable eCommerce tracking. There are more details on this Google document to provide guidance on implementing the eCommerce tracking: https://developers.google.com/tag-manager/enhanced-ecommerce

With a tag management solution, you should be able to reuse the data you capture to fire other tracking tags without changing the code on the pages. So, this article is to give some instructions on how to reuse the eCommerce data captured for Universal Analytics in other tags, especially marketing conversion tags.

Now, if you read the code, you can see a lot information are captured about the transaction. For example, the transaction revenue is particular interesting one for measuring the ROI. Many ad server platforms support revenue variable in the conversion tags. When you generate the tag from the ad server platform, make sure you request it. For example, a DoubleClick image tag with conversion value looks like this (with $5 conversion value):

http://www.googleadservices.com/pagead/conversion/1234567890/?value=5.0&label=Purch
ase&script=0

The code is from this document: https://support.google.com/adxbuyer/answer/165288?hl=en

Let’s reuse the revenue we captured in the eCommerce code to populate the DoubleClick tag above. There are a few steps involved assuming you already have the eCommerce tracking working for Universal Analytics via GTM.

Step 1: Create a macro for the revenue

A macro is a variable in GTM which you can use in your tags. Login to GTM, and create a new macro called “Purchase Revenue”, select “Data Layer Variable” as the type, and put in “ecommerce.purchase.actionField.revenue” as the value. That means if there is eCommerce dataLayer on the page, macro “Purchase Revenue” will be the transaction revenue extracted from the dataLayer.

Step 2: Create your marketing tag

Now, the macro is ready for use on purchase confirmation. Let’s assume you want to create a DoubleClick sales conversion tag in GTM, after filling in the necessary information, on the revenue field, simply put in “{{Purchase Revenue}}” and that will populate the transaction revenue from the eCommerce tracking to the tag. You still need to setup the rules to fire the tag as usual.

The macro can also be used in Javascript so if you need it for other tags, you can do it in the same way.

That’s pretty much it. Test the tag and release it, you will have revenue in your conversion tracking in your marketing campaigns. If you have any question and comment, please submit it over the form below.

Share this Story

About chaoming.li

Technology entrepreneur, web analytics specialist, Internet enthusiasts. I also like movies, computer games, history and other interesting stuff. I was born in Guangzhou China and I live in Sydney Australia now.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

© Copyright 2014, All Rights Reserved