In this tutorial I will guide through the setup process of the goal tracking for internal and external file downloads.
Setting up Event Tracking
1. Make sure that you got the latest version of Google Analytics code on your site. It is highly recommended to keep GA tracking code somewhere in the header between the <head></head> tags.
2. Call the _trackEvent() method on the actual link attribute you want to track. The structure of this attribute is as follows:
_trackEvent(category, action, label, value, noninteraction)
- category (required). String value. The name of the group of tracking objects.
- action (required). The name of the interaction with the object. (in this case the value will be Download)
- label (optional). A Secondary dimension for event.
- value (optional). An integer value of actual event data.
- non-interaction (optional). A boolean value (true or false). Determine if the particular action of the event is required for the calculation of the bounce rate.
HTML code example:
<a href=”www.example.com/brochure.pdf” onClick=”_gaq.push(['_trackEvent', 'Downloads', 'PDF', '/brochure.pdf']);“
Setup Google Analytics Goals
1. Login to your Google Analytics and go the Admin management panel.
2. Click on the Goals tab
3. Add a new Goal, by clicking on the +Goal link
4. Define the goal parameters. Add the name of the actual Goal, set a Goal type to “Event“, provide the goal details such a value of the Category, Action, Label and Value fields.
I extracted a data from the _trackEvent object and passed into the GA goals configuration fields such as:
- Category = “Downloads”
- Action = “PDF”
- Label = “/brochure.pdf”
A full Event Tracking Guide can be find here