How do I add Google Analytics Event Tracking to a link?

Custom Google Analytics event tracking can be added to links, pages, and entire sites through the onclick attribute.

Step 1: The onClick Google Structure


Event Category
This argument is used for measuring a specific page e.g. Mysite-Mypage.

Event Action
EventAction would be used to specify the action such as Click, Toggle, or Download.


Step 2: Naming the Categories

The event categories should have clear, unique names. 


Step 3: Try it Out

<a href="" onclick="that=this;_gaq.push(['_trackEvent','WebDigitalComm','Click',that.href]);">Track this link!</a>


More examples:

<a onclick="that=this;_gaq.push(['_trackEvent','Forms','HR Downloads', that.href]);" href="/hr/documents/Benefits/Choices/Forms/Declaration of Dependent Form.pdf" target="_blank">Adult Dependent</a>
<a href="" onclick="_gaq.push(['_trackEvent', 'Department Info Page', 'Cl
Was this article helpful? 0 out of 0 found this helpful

Have more questions? Submit a Support Ticket