In the second part of our series on Google Tag Manager (GTM) we’ll look at how to set up On-Click Events. In part 1, ‘Setting up Google Analytics with Tag Manager’, I took you through setting up a GTM account, creating a container, installing and testing your container snippet, and setting up Google Analytics for your website on GTM.To follow this guide you will need;

  • A Google Tag Manager Account,
  • Your container snippet correctly installed and working on your website,
If you haven’t got the above in place don’t worry - just check out last week’s blog for a step by step guide to bring you up to speed.

Setting up On- Click Events

1. Log into your GTM account, select the container for the relevant site and select ‘New Tag’. If you look after more than one company’s website data I would recommend a separate account for each company. That will give you one code snippet for the website, but from this you could create many containers, i.e. one for Analytics, one for Adwords and so on.three2. The Tags are the snippets of code that GTM uses to collect data. For instance, you may have a Google Analytics page view tag, Google Analytics Ecommerce tag, Google AdWords conversion tracking tags or possibly even DoubleClick tracking Tags stored within Google Tag Manager.Because there can be so many different tags within your GTM container, it is important to give each tag a clear, relevant name that follows a standard convention across all your tags. Start with something like ‘Google Analytics – Postcode Search Button’ and select Google Analytics from the ‘Tag Type’.four3. For Google Analytics (GA) tags you will need to get the UA-##### code from your GA Admin and place this in the ‘Web Property ID’. Select ‘Event’ from the Track Type and you will be prompted for the Category and Action values that are usually hard coded into the standard onclick tag.five4. The next step is to input the Category and Action for the event. For Event Tracking the category is a name that you supply as a way to group objects that you want to track. Your ‘Category’ will appear in the reporting interface as Top Categories in the Events Overview page. Typically, you will use the same category name multiple times over for related user interface elements that you want to group under a given category.The term "Action" is used to track the type of event or interaction you want to track for a particular web object. For example;
  • Time when the video completes load
  • "Play" button clicks
  • "Stop" button clicks
  • "Pause" button clicks
six5. Now select ‘+Add Rule to Fire Tag’. Rules allow you to decide when to fire a particular tag, for instance you might only want to fire an Adwords Conversion tag if the {{URL}} matches /Thank-You.html or if the user comes from a particular {{Referrer}}.seven6. Adding rules is relatively simple with GTM’s standard set up. In this example, we are going to ‘Create new rule’, the Rule name is Post Code Search Event Trigger, and we have set the tag to fire if GTM receives an {{event}} that contains ‘PostCodeSearch’. Before this tag will work we will need to implement an ‘event’ tag on the web site and name the event ‘PostCodeSearch’.eight7. Once you have created and saved your rule, save the tag.nine8. ‘Create Version’ and ‘Publish’ your tag to your live website. teneleven9. You now need to hard code your tag to your website to push to the GTM data layer on your website. You declare the event like this onclick="dataLayer.push({'event': 'PostCodeSearch'});"onetwotwelve10. On clicking the button this event will be pushed into the data layer. If it is true according to the rules you set, you will see the tag fire in httpFOX. If it is not equal to the rule, the tag will not fire.thirteenforteen Using a single Google Tag Manager container with one Google Analytics Account you can manage numerous websites. For instance, if you have separate website for individual branches of your business I would suggest one GTM container and one Analytics account. This allows you to separate the data out into different profiles by using the hostname. Crucially, you’ll also be able to segment your data as a whole to measure things like events across your different branches.If you have any questions or want some help getting the most out of your website data don’t hesitate to get in contact.Or, carry on and read the third post in the series about GA Custom Variables.