Event Tracking - Digital Marketing's Underused Gem

Event Tracking: Digital Marketing’s Underused Gem?

SocialB Digital Marketing Blog Last modified: 16 Feb 2017 by Paul Hogg

By now, most digital marketers should be familiar with Google Analytics. As one of the staple tools of online marketing, Google’s Analytics platform is a powerful tool for measuring how people came to your website and how they are interacting when they get there. This information is essential to improving users’ on-site experience with the aim to generate more revenue, signups, ad clicks, or whatever your goal happens to be.

This is good and well, but –

What If I Told You You Could Be Missing Out On On-Site Behaviour Information

Enter Event Tracking

Google’s Campaign URL Builder is a really great tool for creating custom URLs. These allow you to analyse exactly what a visitor clicked on to come to your website, and the information you gain from using it when used correctly is highly informative and allows you to focus your off-site marketing efforts. But what about on-site? This is where event tracking comes in.


Let’s say you put a PDF titled ‘Fashion Trends For March 2017’ on your website, available for your users to download. This could be a fantastic resource, but how do you know? You spent 5 hours writing this PDF – was it worth it?

The Google Analytics code you installed on your website won’t be able to pick up external resources. So, in this case, you’ll need to add event tracking to the download link. This essentially tracks the number of clicks on this link, allowing you to see how many people have viewed the PDF. From this data, you can see what people do after they’ve viewed the PDF (did they return to the website and complete a goal?). This information will give you an idea of how much the PDF is potentially worth – if a new visitor came to your website, viewed the PDF, then completed a goal, it’s likely the PDF is what gave them a good impression of your business and products/services.

For a much simpler way of implementing event tracking, please see our series on Google Tag Manager where we explore this subject in part 2.

Ok, so how do I add this to my website?

To add event tracking to your website you’ll need to add a small piece of code to your links. This is a straightforward copy/paste process that you can do with the following code:

<a href="http://www.example.com/uploads/fashion-trends-march-2017.pdf" onclick="ga('send', 'event', 'PDF', 'View', 'Fashion Trends For March 2017');">Download Fashion Trends For March 2017 PDF</a>

(Please do NOT copy this code as it contains custom CSS and may not work.)

All we had to do to track the number of people that viewed this PDF was add the line of code highlighted in bold. The parts in red were customised to tell Google Analytics that a PDF was Viewed which was called Fashion Trends For March 2017.

Let’s break it down:

onclick="ga('send', 'event', 'PDF', 'View', 'Fashion Trends For March 2017');"

(Feel free to copy and customise this code.)

  • PDF – This is the event Category. This tells Google Analytics what was interacted with. In this example, the link leads to a PDF.
  • View – This is the event Action. This tells Google Analytics what type of interaction the user performed. In this example, the PDF is being Viewed.
  • Fashion Trends For March 2017 – This is the event Label. This tells Google Analytics what to label the event as. In this example, the PDF being Viewed is called ‘Fashion Trends For March 2017‘.

Mailto Links

One of the more useful applications of event tracking is seeing how many people click email links. Most websites have both contact forms and clickable email links on them. While tracking contact form submissions is essential, a lot of people still choose to click the email link in your header/footer/contact page/other location.

Adding event tracking to mailto links is a little bit different.

Here is an example:

<a href="mailto:info@example.com" onclick="setTimeout(function(){ga('send', 'event', 'Email', 'Click', 'info@example.com - Header');}, 1500);">info@example.com</a>

(Please do NOT copy this code as it contains custom CSS and may not work.)

This code is very slightly different. The information inside the ga() block is still the same, however.

Let’s break it down:

onclick="setTimeout(function(){ga('send', 'event', 'Email', 'Click', 'info@example.com - Header');}, 1500);"

(Feel free to copy/paste and customise this code)

  • Email – In this example, the link leads to an Email Address.
  • Click – In this example, the Email Address was Clicked.
  • info@example.com – Header – In this example, the Email that was Clicked was the ‘info@example.com‘ link located in the Header.

Other Uses For Event Tracking

  • External links (social buttons, sister-sites/subdomains, etc)
  • Internal banners (how many people are clicking on the new summer sale banner?)
  • Sign-ups, log-ins and form submissions
  • Downloads (PDFs, CSVs, Images, etc)
  • Widget interactions (calculators, product filters, etc)
  • Videos (how many people viewed this video? – A little bit more complicated)
  • Social sharing button interaction (how many people clicked to share this on Facebook? What about Twitter?)
  • Form completion progress/drop out (a little bit more complicated)


Event tracking is an easy to implement, yet incredibly powerful way of analysing exactly what visitors are interacting with once they’re on your website. It’s worth taking some time out to add this code to your website – the data you’ll collect will be more than worth it.

Any questions? Let us know in the comments. Happy tracking!

For a much simpler way of implementing event tracking, please see our series on Google Tag Manager where we explore this subject in part 2.

* Please note: The code provided is Javascript. If your website doesn’t support Javascript it may not work. Always contact your website’s developer before adding any code.

** Please note: The code provided is designed to work with the current Google Analytics tracking code. The same principles still apply to the older versions but you may need your developer to check what code you’ll need to use.

Leave a Reply

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