Downloads such as PDF, piece of code etc. can be tracked as Events in Google Analytics.
Event tracking requires
- Calling trackEvent function
- trackEvent function can take up to 5 parameters, of those 2 are required
What are those parameters for trackEvent function
- category (required) The name you supply for the group of objects you want to track. It can be anything but be consistent with whatever you decide to use.
I suggest using “Outbound Links” for outbound link tracking
- action (required) A name for the type of user interaction for that event. But again you can use anything you like e.g. “Click”,“Partner Link Click” or whatever makes sense for your business.
I suggest that if you have different categories of link then use the category name that defines those links.
- label (optional) A string to provide additional description for that event.
I suggest using the actual name of the links e.g. gapremium.com, google.com etc.
- value (optional) An integer that you can use to provide numerical data about the user event.
You can leave this value in case of outbound links or use 1 unless you want to give more weights to certain links.
- non-interaction (optional) Boolean value, set as true or false
true= not a valid interaction, count it as a bounce
false = considered a valid interaction (default)
If you DO NOT set this value then an outbound click will be considered as a valid interaction thus WON’T BE COUNTED in BOUNCE RATE.
Suggestion: Since you really do want people to click on outbound links, set this value to true e.g. it is a valid hit and not a bounce.
How to call it?
_gaq.push([_trackEvent(category, action, label, value, noninteraction));
_gaq.push([‘_trackEvent’, ‘Download’, ‘eBook’, ‘How to Use Google Analytics’, 1, true]);
So your code will like
<a href=”howto.pdf” onClick=”_gaq.push([‘_trackEvent’, ‘Download’, ‘eBook’, ‘How to Use Google Analytics’, 1, true]);”>Download How to Use Google Analytics eBook</a>