If your website is using the centrally sourced 2014 (Responsive) York WordPress Template and WordPress, please see the Set-Up Event Tracking page.
Event Tracking (ET) with Universal Analytics is very different from with Classic Analytics (Google Analytic's last iteration). The code you may have been familiar with using before will no longer work.
What does Event Tracking do?
ET allows you to track when people click on an event (a link, video controls, etc.) that otherwise would not be collected with our GA set-up. It registers each time a visitor clicks on / interacts with a specific element on a page.
When should you use Event Tracking?
Normally GA is able to track any page with the Analytics code on it for an account. There are circumstances it cannot track visitors' activity, including:
- External links: It cannot track any link destination that does not have the same account code on the page
eg. If a visitor goes from a page on Future Students (with the York University account code on it) follows a link to a page on the the 'Ontario University's Application Centre' site (with their own / not York University's account code on it), GA will only be able to follow the visitor until they leave the Yorku.ca site and then register the visitor as an Exit.
- Downloads: GA code cannot be placed on Word docs, pdf files, etc.. It can only be placed on html pages. As such, placing ET code on the link to the download files allows you to track whether or not a visitor interacted with the download file link (but not how they use the file once downloaded.)
How to set up Event Tracking
For every external or download link you wish to track, complete the following:
- In code-view ('Text' view in WordPress), find the link that you wish to track
- Add the following to the link:
onClick="ga('send','event','[Site Name]','[Category]','[Name of Document or Link]');"
Mandatory: Replace [Site Name] with the name of your site (remember to be consistent!)
Mandatory: Replace [Category] with a categorization for the interaction -- you can use the same one for all your links if you'd like, but you must include this! It can be as simple as 'Click' for an external link or 'Download' for your document links.
Mandatory: Replace [Name of Document or Link] with exactly that -- the name of your document or link. This must be different for every one. If you use the same details for every element you're trying to track, GA will not be able to differentiate between them!
Example of how Event Tracking would be applied on a webpage:
<a href="http://analytics.info.yorku.ca/files/2014/11/Example.pdf" onClick="ga('send','event','Analytics at York','pdfs','Example PDF');">Example PDF</a>
Which would appear as:
Where to find the data collected by Google Analytics:
- Log into Google Analytics with your Google ID
- In the left navigation, click through Behavior > Events
- Navigate to the report you'd like to review