0

I would like to know if it is possible to use Google Analytics to track links that do not necessarily relate to a specific website?

In other words, if I make a newsletter with a hyperlink to www.shinyhappypeople.com, how can I equip this hyperlink so that a click event on the link will be recognized and tracked by my Google Analytics account?

disasterkid
  • 6,948
  • 25
  • 94
  • 179

1 Answers1

2

You're looking for event tracking. You can bind an event tracking call to absolutely any interaction with a webpage (or non-interaction such as firing an event after a predefined period of time - remember to set the 'non-interaction' flag!).

The basic code for event tracking is as such:

ga('send', 'event', '[category]', '[action]', '[label]', [value]);

So if you have a HTML anchor element (hyperlink) you will want to bind this to the onclick event. I'll demostrate this by hardcoding it, but you could dynamically bind using native JS or something like jQuery of course:

<a href="http://www.shinyhappypeople.com" onclick="ga('send', 'event', 'User Interaction', 'link-click', 'shinyhappypeople.com', 1);">click me</a>

For full details of everything you can do with event tracking just see the Google Docs here.

dmpg_tom
  • 857
  • 7
  • 11
  • "You can bind an event tracking call to absolutely any interaction with a webpage" But what if my data is not a webpage and is an email newsletter? – disasterkid Oct 26 '15 at 08:06
  • 1
    Just to clarify before I update the answer - do you want to track links to URLs that you have no control over? – dmpg_tom Oct 26 '15 at 08:50
  • No, an empty URL cannot be tracked. I am wondering if I can feed the URLs inside the newsletter with GA data so that GA can recognize them. – disasterkid Oct 26 '15 at 09:30
  • 1
    You really have 2 options - you either use the normal UTM campaign parameters on your URLs which allows GA to automatically track the source of the entries to your site (and then you can use the campaign reporting to understand clicks on URLs in the emails). Or you use a redirect page which is what you actually link to, this redirect page then forwards the user to the correct content, before it forwards it send GA tracking. You cannot place GA tracking directly in an email. – dmpg_tom Oct 26 '15 at 09:37
  • So, if I am not mistaken, in your UTM solution you still need a website and in the second, you need at least a redirect page. Right? – disasterkid Oct 26 '15 at 10:18
  • 1
    correct, there is no way to track any click interaction with an email without redirecting to some sort of web page. All mainstream email marketing providers (e.g. mailchimp) use a the redirect method. – dmpg_tom Oct 26 '15 at 10:30
  • Good to know! Thank you! – disasterkid Oct 26 '15 at 10:51