Tracking File Downloads With Google Analytics and WordPress
With the above in mind, in this article, we’ll show you how to use events in Google Analytics to track file downloads.
For the purposes of this article, I’ll assume you already have an existing Google Analytics account ready to go. If you’re relatively new to Analytics, it’s worth getting familiar with the division of account hierarchy that Analytics uses to make sure your setup is making life as simple as possible.
Google’s example account structures and overview of options at the Analytics Academy are both worth reviewing. Pole Position Marketing’s overview of account structure is another excellent resource that outlines options in a highly practical manner.
Another item you’ll want to double check is whether you’re using the latest Universal Analytics version of the tracking code. I’ll assume that’s the case. If you need to upgrade from a previous version of the script, Google have a wealth of resources available to walk you through the various options that apply.
Using Events in Google Analytics
Event tracking in Analytics is Google’s way of giving you a flexible way of measuring user interactions on your site, without being entirely tied to page loads. Events can be found in your account by going to the Reporting tab and then selecting Behavior > Events.
Events are designed with configurability in mind and each event has four primary components that you are free to tweak to match your needs:
- Category: The general term by which you want to refer to these types of events. A category gives you a simple way of grouping together similar events such as e-book or video related items.
- Action: This is simply the desired result you’re after. This could be an actual download, a click on a play button, or any other type of discrete action that you want to hone in on.
- Label (optional): Labels give you a handy additional bit of space to include any other information you might think is relevant.
- Value (optional): If, for example, you happen to know that the conversion rate on your lead magnet e-book download is 10% for a follow-on product with a value of $150, every download could usefully be ascribed a value of $15.
You can find more detail on options for each of the components above in Google’s excellent overview of Events in Analytics. Now let’s move on to actually using one of these events to capture data.
Creating a New Event
Start by logging into your account, selecting your ‘property’ and clicking the Admin link at the top of the screen:
From here, you should be able to see a three column view as pictured above. Click the Goals link in the View column and then New Goal to start setting things up:
This kicks us into the screen above where we can enter a name, assign a goal ID, and select “Event” as our goal type.
Finally, we get to the stage where we can enter the goal components mentioned earlier. Once you’re happy with your setup, click Save to register the changes and this part of our setup is complete.
Adding Basic Event Tracking on the Page
With an event set up in Analytics, we now need to be able to trigger it from WordPress. The simplest way of adding event tracking on the actual page is using an onclick event to send information through to Analytics when an element is interacted with.
For example, if we have a free e-book we want to track the performance of, the following code simply needs to be added to the relevant link as shown below:
Adding this link code to individual elements could get tedious pretty quickly, so there are a number of alternative methods you can look to employ if you’re trying to track downloads across a busy site.
One option is to slightly streamline the code by using a bit of jQuery behind the scenes to append the correct links programmatically on the basis of class names, as outlined over at the Gravitate Design blog.
A second option is to use the power of the Google Tag Manager to take care of some of the heavy lifting without having to perform any custom coding yourself.
Rather than get too far into the specifics of how to go about setting this up, we’ll point you in the direction of Amaze Metric’s excellent overview of how to go about setting up file download tracking in Google Analytics. Google Tag Manager may be slight overkill for some sites, but it can be a real timesaver for non-technical members of your team.
Tracking File Downloads With a Plugin
If all of the above sounds a little too much like hard work for your liking, you’ll be happy to hear there are also a number of plugin solutions available for taking care of tracking and managing file downloads in WordPress. Here are three of the more common options to check out:
The Google Analytics Dashboard for WP plugin brings your key site data directly into WordPress and also enables you to view information about downloads stored as events. With over 600,000 active installs and a solid near five-star rating, this plugin is a handy way of bringing some of the power of Analytics directly to your dashboard.
Download Monitor takes a slightly different approach to the matter of file downloads and puts them on a par with items such as posts and pages in your back end.
The plugin enables you to categorize, tag, and add custom meta information to your downloads, as well as tracking downloads and offer advanced features such as member-only downloads. A set of powerful extensions are also available if you need to take even more control of downloads on your site.
In addition to download counters and reporting, the WordPress Download Manager also enables you to integrate smoothly with Google Drive, Dropbox, and Box.com. A full suite of more advanced e-commerce options relating to downloads is also available with the premium version of the plugin.