Getting Started with Google Tag Manager – Publishing Google Analytics
Publishing Google Analytics to your site is relatively straightforward via Google Tag Manager. Once set up you’ll be able to add event tracking and a range of other tags to your site without having to roll out additional tracking code on your site.
Google Tag Manager can also significantly cut down on the development time needed to track a range of visitor interactions from file downloads through to video plays and e-commerce transactions.
Note that if you already have Google Analytics on your site you’ll need to think about migrating any additional tracking you have on the site over to tags in Google Tag Manager in advance.
Creating a Tag Manager Account
To begin you’ll first need a Google account – log in and then go to tagmanager.google.com to set up a tag manager account. You can set up multiple sites within a tag manager account but if you manage sites for multiple organisations it’s best to stick to a single account per organisation.
To add a new account, enter an account name from the Admin screen.
Click continue and you’ll then be asked to set up a container. Typically you’ll have one container per web property (or App) although complex sites may handle this differently.
Typically for a website you’ll enter the name of the website (or its domain name).
Under Where to Use Container select the type of site you want to manage. Select Web for a normal website or (iOS or Android for an App). Click create to complete this step.
Installing the Tag Manager Code on Your Site
To add Google Tag Manager to your website you’ll need to copy some code and paste it into your website template so that it appears on all pages throughout your site.
It’s important that you add the code in the right place – it must appear just after the opening “” tag in your HTML code.
To access the code click Admin at the top of the screen, and select Install Google Tag Manager underneath the Container. Copy and paste the code from the next screen.
Add a Google Analytics Tag to Google Tag Manager
The container you created above is essentially a holding store for all of the tags you’ll deploy to your website. Google Analytics is published via one of these tags.
As each tag that reports data to Google Analytics needs to refer to your Google Analytics Property account (the code that appears in the UA-XXXXXX-X format) it can save time to store the account number as a “constant” and then simply refer to it in each of your tags.
To create a new Variable and Universal Analytics Tag first click onto Variables and then click new.
Give the variable a name e.g. “UA Number” as shown below and select the “Constant” option.
Then Under Configure Variable enter your UA tracking id – found in the Property Settings for your account in Google Analytics. Click Create Variable
The final step is to create a tag that publishes Google Analytics to your site.
Back in the Container screen, select Tags from the left-hand side menu and click New Tag
- Click on ‘Untitled Tag’ at the top to rename your new tag – something like “Google Analytics”
- Select Google Analytics as the product
Universal Analytics as the tag type – this is the latest version of Google Analytics (although there’s also the option to use the older version).
- You next need to select the account to send data to
- Under Configure Tag click the add button next to the Tracking ID field
- Select your newly created user defined variable constant ‘UA number’
Using your new constant has the advantage that, particularly as your tracking requirements become more complex, you can simply enter the variable rather than having to remember your UA number each time you create a new tag. Remember, altering the constant will also affect all associated Tags.
- Select Pageview underneath track type
- Under Fire On select All Pages (assuming you want to track your full site)
- Click Create Tag
Almost there – you now just need to Publish the tag and test that things are working. Click “Publish” at the top right hand side of the screen to do so. It’s worth logging into Analytics after you do so to check out the real time reports that show you who is on the site right now – go to your website and check that you can see hits coming through.
(Note that sometimes real time reports can be suspended if you haven’t checked into that view for a while – once you check back in they will be reactivated but this can lead to a delay in data appearing).
When you set up Google Analytics you add tracking code to your website either using the standard GA tracking snippet or via a tag management solution such as Google Tag Manager.
By default Google Analytics tracks page views. You can however also extend tracking to also capture additional user interactions via event tracking, virtual page views or use e-commerce tracking to capture online transactions.
Until Universal Analytics – the latest version of Google Analytics – tracking however stopped there. If you had other payment systems, CRM systems or essentially any other systems connected to the internet it was not possible to incorporate the data into GA.
Introducing the Measurement Protocol
This all changed with the introduction of the measurement protocol – a technical set of rules on how to send data to Google Analytics servers and incorporate the data into your account. With the measurement protocol the potential is enormous. Examples of how it could be used include tracking offline transactions, sales team follow ups and even footfall in a real world store.
Tracking Email Opens
As a simple introduction to how the measurement protocol can be used let’s take a look at tracking email opens from a marketing campaign. Whilst many email management tools will provide you with these statistics wouldn’t it be great if you could also incorporate this data into Google Analytics?
First things first – you’ll need to be using Universal Analytics. If you are using the older classic or asynchronous versions you’ll need to upgrade. It’s also essential to note that as part of Google’s terms of service that you can’t use any information here that could personally identify an individual. This means that names and email addresses are out.
Data is sent to Google Analytics via an “HTTP request” – not as complicated as it sounds as to track email opens you can simply add an HTML image tag to the footer of your email.
Building the Code
The code starts of as the following:<img src="https://www.google-analytics.com/collect?v=1&AddCodeHere"/>
You then need to replace the AddCodeHere above with a series of statements to tell Google how you’d like to track email opens and the account to send the data to.
You next need to add:
&tid=UA-XXXXXXX-X – replace the XXXXXX-X with your Google Analytics property code (go to Admin and click Property / Tracking Code if you are not sure of this.
&cd= YYYYYY – this is a unique random number that anonymously identifies a particular user or device (via a client ID). Many email software solutions will be able to complete this via a dynamic parameter (for example you could use *|UNIQID|* in MailChimp).
&t=event&ec=email&ea=open – this code is then required to indicate you want to capture the interaction as an event, the category should be email and the action should be “open”.
Finally you’ll want to add a final set of parameters to attribute the email open to a particular campaign. For example you may wish to track the campaign as a newsletter promoting a spring offer for which the tracking code could be:
Replace the campaign source value (after &cs) and campaign name (value after &cn) as required.
Bringing it All Together
Putting all of this together you’ll end up with an image tag similar to the following (where you will have amended the items in bold).<img src="https://www.google-analytics.com/collect?v=1&tid=UA-XXXXXXX-X&cd= YYYYYY&t=event&ec=email&ea=open&cs=newsletter&cm=email&cn=spring_newsletter_2016"/>
Remarketing via Google Adwords offers a powerful opportunity to retarget people who have visited your site. With the introduction of Google Analytics audience lists retargeting has become even more powerful.
For example, someone may have visited your site and not completed a purchase or some other interaction you were hoping for and so targeting them with a tailored ad may encourage them to return.
Firstly enable remarketing:
- Log into Analytics
- Click Admin
- Navigate to Property, then Tracking Info, and finally Data Collection. Ensure remarketing is set to ‘ON’.
Now it’s time to build audiences:
- Click Admin
- In the Property Column click “Audience Definitions” and then select “Audiences”
- If you already have an audience set up on the next screen, you can add another by clicking +New Audience.
- Otherwise select the MAIN View (for whatever site you are in) underneath "Link Configuration"
- Select the associated AdWords account using the “Destination Account” option (not you’ll need Admin access to both the Analytics account and relevant AdWords account to do so).
- Click Next Step and enable remarketing
- Then choose how you want to build the audience list (to target for remarketing).
For example you could choose everyone (All Users), new or returning users, users who complete a preconfigured goal or users who complete a transaction
- For more advanced options select “Smart List” – this enables you to build up a segment based upon more complex rules – for example traffic sources (e.g. campaigns) or content that people have viewed
- NOTE – for Smart Lists you may need to use “Regular Expressions” to build up complex rules (e.g. for multiple pages people have viewed).
- Lists are available to use in AdWords as soon as you’ve set them up. However there must be a minimum number of people who quality for the audience (at least 1,000 users) before your remarketing ads actually start to show
Troubleshooting Google Analytics installations just became a little easier thanks to an enhancement rolled out to Google Tag Assistant - available as a Google Chrome extension.
Tag Assistant Recordings allow you to record interactions you make with a website and then review what data Google Analytics recorded. If your account hasn't been set up properly or if data is either not captured or in the wrong format this great new feature should be a huge help.
The extension is only available for Google Chrome - you can download it here. Once configured click onto the tag assistant icon at the top right hand side of the browser, click "check this page" and then when ready hit "record".
Related Google Analytics Services
In a number of previous articles we've talked about the problem of spam referrals appearing within Google Analytics data. This problem now appears to be growing exponentially and without taking steps to exclude this data from your reports (changing your tracking / configuration within Google Analytics or using advanced segments to remove this data) your reports and any insights derived from them could become meaningless - or worse still highly misleading.
We're hopeful that Google will roll out a solution soon as for some unfiltered views we are now sometimes seeing that well over 50% of the traffic is spam - in a few cases equating to over 50,000 visits within a relatively short time frame.
Spammers are now also getting smarter - solutions previously described to use your website hostname as a filter are now encountering problems and maintaining lists of referrals to exclude requires ongoing proactive management with new sources appearing regularly.
In the meantime we've started work on a list of spam referrals, automated traffic and other suspicious referrals that you may want to exclude. This list won't be fully comprehensive but we'll endeavour to keep it up to date based upon what we encounter. We're hoping to publish this later this week.
Solutions such as that proposed by LunaMetrics (see link in the following article) may become increasingly essential to maintain the integrity of your reporting until such a time as a solution is available via Google.
Changing spammer tactics include:
- Adopting legitimate source names (but perhaps adapting them via adding a subdomain)
- Changing the hostname
- Using minor misspellings so they appear legitimate e.g. theguardlan (rather than guardian)
- Using new referral sources
- Use variations of the top level domain (e.g. .org or .info)
- Dropping suspect metrics - e.g. a 100% bounce rate or 100% new sessions can raise a red flag and so spammers appear to have changed tactics to often avoid these