Google Analytics (GA) has become the mostly widely used data analysis tool on the web because it is both powerful and free.
But it’s way underutilised, even among those who think they understand it.
GA can provide you with rich insights about your website, including who is visiting, what they are looking at, where they come from and what they are clicking on.
Having this kind of information empowers you to make decisions about your website that are based on data instead of assumptions.
- You can see, for example, where customers are prematurely dropping off your website and then take action to fix it.
- You can see what your most popular content is, and then highlight your best offers there.
- You can see which sources are bringing in the most traffic and then optimize your experience for users from those channels.
The actionable insights you can gain are literally endless.
Google Analytics is very easy to set up, but getting the most out of it is another story. It is a highly complex tool, and few people are aware of the many ways you can use it.
One particularly useful feature that is not on by default is event tracking.
Because Google Analytics tracks only pageviews (i.e. when a page loads) out of the box, it cannot tell you what users are doing on a particular page.
It will tell you how many people visited the video page on your website, but it cannot tell you how many people actually clicked on or watched your video.
Any event that does not involve a new page loading will not be tracked by default. In order to do that you need to set up event tracking.
This is becoming increasingly important as more and more pages feature dynamic content that uses things like AJAX to display new content without refreshing the page.
Additionally, many websites nowadays exist mainly as a single page with buttons that simply take a user further down, but not to a new URL. By default, Google Analytics will not register such events.
This post is going to tell you, step by step, how to enable event tracking in Google Analytics so that you can see every time a user performs any type of action on your site.
1. Install Google Tag Manager
Before Google Tag Manager (GTM) came around, you had to manually insert the code for every 3rd party tool that you wanted to use on every page you wanted to use it.
To install Google Analytics, you would paste a snippet of code onto all of your pages. And then you would have to repeat the process if you wanted to use another tool like Hotjar.
For many, this meant continual reliance on their developers.
Google Tag Manager is a free tool that allows you to manage all these code snippets and insert/modify/remove them without getting into the code of your site.
It does, however, require a one-time installation (so you may have to bother your developer one last time).
When you create an account in GTM (tagmanager.google.com), it will give you some code to paste into your website. Something like this:
Insert that code (or get your developer to do it), and BAM! That’s the last time you will ever have to put a code snippet onto your site. From now on GTM will be your tool for managing any 3rd party code snippets your site needs.
2. Install Google Analytics Via GTM
Note: If you already have Google Analytics installed on your website the old way, you can skip this part, or you should first remove the code. Otherwise, after installing it with GTM, you will have it firing twice… and that’s bad.
1. From the Workspace for the appropriate account in Google Tag Manager click on Add A New Tag.
2. Click on the Tag Configuration box and select the first option, Universal Analytics.
3. Now you will see a field called Tracking ID, and here you should paste in the Google Analytics tracking ID of your website (find it in your GA account).
4. Then click on the Triggering box and select the very first option, All Pages.
5. Give your new tag a name, and click save.
What you have just done is tell GTM to fire up your Google Analytics tracking code on every page of your website.
Easy right? Don’t forget to click Publish for the changes to take effect.
Congratulations! GA is now running on every page on which GTM is installed.
Test To Make Sure It’s Working
Go to your Google Analytics account, to the Reporting section, and click on Real-Time Overview.
Now in another tab, go to your website and click refresh. You should see an active user on your site along with your location. The timeline will show you how long ago the page was loaded.
3. Choose An Event To Track
In this example, we are going to use the simplest of all events: a button or link that takes a user to another part of the page.
With this kind of setup, you usually have two elements: a section of the website where you want a user to land, and the button or link that takes them there.
The section always contains an ID and might look something like this:
<div id=“my-section”>My content</div>
The link people click on to get there will point to that ID and look something like:
<a href=“#my-section” id=“my-button”>Click Me</a>
So far this is all HTML 101. Nothing new here. When someone clicks on the “Click Me” link, the page will jump to the section with the ID “my-section”.
Because this kind of link does not refresh the page or point to a new URL, Google Analytics will not register such a click by itself. That’s where GTM comes in.
Notice how the link itself also has an ID. This makes it especially easy to track. We can tell GTM to track every time a link with this particular ID is clicked.
Note: The button or link you want to track might not always have a unique ID property specified in the HTML, in which case you will need to tell GTM to look at some other property. But for the sake of this quick tutorial, we will assume the button you want to track has one.
4. Tell GTM To Track This Event
In order to track when someone clicks on this link or button, we are going to create a new tag and a new trigger in GTM.
The trigger will tell the tag when to fire, and then Google Analytics will be able to record each time the tag is fired, giving you useful information in GA.
First we need to tell GTM to look at the right variables.
1. In the GTM workspace of the appropriate account, click on Variables, and then under Built-In-Variables, click Configure.
2. Under the Clicks section, check all the boxes so they are blue.
Now you can set up your tag and trigger.
1. In the GTM workspace of the appropriate account, click on Add A New Tag
2. Click on the Tag Configuration box and, once again, select the first option, Universal Analytics.
3. A new field will pop up asking for the Tracking ID. Again, you should paste your GA ID in this box.
4. Now change the Track Type setting from Page View to Event.
5. Several event tracking parameters will appear. These parameters will be passed through to GA when the event fires allowing you to track clicks in different ways. For now, let’s just worry about the Category parameter—enter “Button-Click” into this field.
6. Now click on the Triggering Box, and then the plus icon in the top-right corner to create a new trigger.
7. Click on the Trigger Configuration box and under the Click category, select All Elements.
8. Now change the radio button from All Click to Some Clicks, and with the drop-down menus, change the condition to Click ID equals “my-button” (remember, that is the ID you gave to your link in the HTML).
9. Give the trigger a name and save it.
10. Finally, give your new tag a name, and save it too.
You have just created a new tag that will fire each time someone triggers it by clicking on any element of your site with the “ID my-button”. When fired, the tag will send the Category parameter “Button-Click” through to GA.
Don’t forget to publish your changes for them to take effect.
Test To Make Sure It’s Working
Head back over to your Google Analytics account, go back to the Real-Time section, but this time go to the Events subcategory.
(Make sure you are looking at your raw data view, i.e. double check that there are no filters masking your IP.)
In another tab, refresh your page, and click on your link or button. You should now see the event show up in GA along with the category parameter we gave it, “Button-Click”.
Congratulations, Google Analytics is tracking your first click event!
Now there is one more step to turn this data into useful information in your GA reports. You have to set up goalsthat reflect these events in order for them to get recorded.
5. Setting Up A Goal In Google Analytics
In order to make event tracking useful in your GA reports, you need to set up goals that reflect when events are triggered.
This will allow you to see your conversion rate, how many people clicked on your button, what percentage of them were new users, what percentage of them came from certain sources, and more.
1. In Google Analytics, click on the Admin button, and then, for the property and view that you want, click on Goals.
2. Click New Goal and give it a descriptive name (e.g. Someone Clicked on My Button!).
3. Select the Event radio option and click continue.
4. Now, in the Category field, enter the value we told GTM to pass through for this event. We set it to “Button-Click”, so enter that into the field and click Save.
It will take some time for results to show up in GA, and it will only start recording goals from now on (so the clicks you’ve already made won’t appear retroactively).
When setting up goals, remember that they are only applied to the particular property and view that you set them up for.
Event tracking will make all kinds of new data available to you,
It can get quite complicated with all the names for IDs, categories, tag names, trigger names, goal names, etc. It’s important that you develop some standard naming procedures as you move forward.
This short tutorial just barely scratches the surface of what you can track using GTM and GA. There are millions of options for you to play with to gather the data you need to make informed decisions.
We do hope this was useful to you, and will set you off on the right foot!