Custom Google Analytics event tracking can be added to links, pages, and entire sites. You can setup a link to track the click, or the onclick
event.
How an "onclick" event is structured, and how you can create your own
Here's an example of the full "tracker":
onclick="that=this;_gaq.push(['_trackEvent','EventCategory','EventAction',that.href]);"
Since the CMS will provide the wrapping portion which is
onclick="..."
we are only need to build the middle, which is
that=this;_gaq.push(['_trackEvent','EventCategory','EventAction',that.href]);
Let's go through and explain the pieces you'll need to modify to make it work.
EventCategory
This you can replace with your unique identifier of the webpage where the link appears that you're tracking. This will show up in the Google Analytics report, so make it unique and recognizable. You can't use spaces or special characters, so it might look something like this: e.g. WebComm-Training
.
EventAction
EventAction is the type of action the onclick event you are tracking performs. This is usually one of these three: Click,
Toggle,
or Downloads
.
So, if we're building a tracker to monitor the amount of clicks our "View our Intro Training" link gets on our training page, it might look something like this:
that=this;_gaq.push(['_trackEvent','WebTraining','Click',that.href]);
Now, let's show you where to put this on your link so it starts tracking.
Placing the tracker you've built onto the link you want to track
- Login to your webpage, and begin editing the page you wish to add the tracker.
- Click the green button on the editable region you wish to edit (e.g. Main Content.)
- Highlight the link you wish to add the tracker.
- Click on the Advanced Tab.
- Paste your tracker into the onclick field.
-
that=this;_gaq.push(['_trackEvent','EventCategory','EventAction',that.href]);
-
- Click OK.
- Save and publish your page and you should now be tracking that link.
Click on the link a few times to send tracking information through to your Google Analytics, however, the clicks may not show up right away. You may need to check back in a few days.