Setting up a Google Analytics eCommerce Tag in Google Tag Manager


Posted on March 11th, by Jay Murphy in Digital Marketing. No Comments

Hello all!

A quick post to show the steps in creating a Google Analytics eCommerce Transaction Tag in Google Tag Manager.

We are going to assume you have the basics in place – a Google Analytics Account and a Google Tag Manager account with the basic pageview tag setup.  (If not here is a post to help you get started!

OK – You are going to have to setup a few things – A Google Tag Manager tag and trigger; dataLayer information about the transactions on your receipt page and some configuration in Google Analytics.

Google Tag Manager Setup

For the GTM side of things you will need to setup a trigger and a tag.  (And we are also going to setup a variable for your Google Analytics Tracking code – if you setup more tags you will be glad you did this!)

Setup a Google Analytics Tracking code variable – I call it “UA Tracking Code”:

Google Analytics Tracking Code Variable

Then we setup a Trigger for the page that contains our eCommerce dataLayer code.  You will need to setup the trigger so that it fires on the URL of your receipt page.  So copy and paste the unique portion of your URL into the trigger.  Our receipt page always ends in “/step-3” so our trigger looks like this:

GTM Google Analytics eCommerce Transaction Trigger

And then finally we want to setup a tag that fires on this trigger.  It will look like this:

eCommerce Tag in Google Tag Manager

Notice it all comes together here – we use the “UA Tracking Code” variable to set the correct Tracking ID, we choose a Track Type of “Transaction” and we want to fire this on our “Receipt Page Trigger”.  Our next step is to include the eCommerce code in our dataLayer.

eCommerce dataLayer Code

When working with Google Tag Manager the dataLayer array is used to pass information to Google Tag Manager where it can then use it for passing to other Tags such as Google Analytics, AdWords Conversion, Facebook Conversion… You name it they can be sent for GTM.  In our case we are setting the basic Google Analytics eCommerce transaction.

For a transaction Google Analytics needs two sets of information the transactions and the item (or items) associated with that sales transaction.  And if we use the following format our Transaction from above will know how to read this information.

Transaction dataLayer:

This dataLayer update contains information about the the purchase including the unique Transaction ID, the optional Affiliation (which you can use for affiliates or if you do not have affiliates you can choose another purpose…), the total price for the transaction, any tax with the purchase and finally any shipping costs.  The Transaction ID and Total are the only required fields.

Products (or Items) dataLayer:

In this data you see the SKU, product name, optional category, price and quantity.  You can send multiple products in the dataLayer and putting it all together your code would look something like this:

This brings it all together. Just FYI the code:

is a nice way to ensure that the dataLayer array is initialized correctly (as an array) if it has not already been declared in other place within your code other wise it uses the current value of the dataLayer array.

NOTE: How do people typically generate this dataLayer information?  Well the common approach is to create this within your eCommerce system – some plugins or tools are available to do this automatically.  Check with your shopping cart or eCommerce solution.

Configuring Google Analytics

Before you can see the eCommerce report in Google Analytics you have to configure your web view(s) to collect this data.  Simply navigate to the Web View menu within the Admin area:

eCommerce Configuration in Google Analytics

Click on Ecommerce Settings to reach this page:

Ecommerce Configuration step 2

Click on the “Enable Ecommerce” switch to “ON”.  (You could also enable the “Related Products” reports as well – to learn more about this see this link: https://support.google.com/analytics/answer/6223409?hl=en.)

Ecommerce Configuration step 3

On this next page do not turn on Enhanced Ecommerce; that will be a whole new blog post!  Click on the “Submit” button and…

Congratulations!!! You are now tracking eCommerce into your Google Analytics account and can see reports like this:

eCommerce-GoogleAnalyticsProductPerformance-GTMTransactionTag

Your eCommerce metrics will allow you to review product performance, how your marketing impact sales and a lot more.

Be Sociable, Share!




Leave a Reply

Your email address will not be published.

wordpress Wordpress Theme