Articles in The '_trackEvent' Tag

August 5 2009

Tracking PDF Downloads in Google Analytics

by MoreVisibility

PDF Files are no doubt a part of your website. Sure, they’re not HTML, PHP, or ASP pages, but they are files that contain information that is just as valuable as any other page on your website. So, why not track PDF files in Google Analytics, too?

At MoreVisibility, we see a lot of websites out there using Google Analytics that are not tracking their PDF Files as either pageviews or events – both of which are possible to do. The best part about it is that it’s very easy to configure, which is good news for any person on your IT / technical team.

To track any PDF file on your website, simply follow the quick steps below and you’ll be well on your way. It gets a bit technical from here on out, so roll up your sleeves and put your hard hats on.

1. Find a page that links to one of your PDF files.

2. Find where the PDF file is on the page – look for the anchor (<a>) tag. It should look something like this:

<a href="files/quarterly-earnings.pdf" target="_blank">Quarterly Earnings Report</a>

3. Insert the following “onClick” event within this anchor tag. It should look like this:

<a href="files/quarterly-earnings.pdf" target="_blank" onClick="pageTracker._trackPageview('/files/quarterly-earnings.pdf');">Quarterly Earnings Report</a>

4. Upload the page and enjoy the results! You should see the number of times that your PDF file was accessed within the Content >> Top Content section of your Google Analytics profile.

Tracking a PDF Download as an Event (vs. as a Pageview)
To track your PDF Downloads as Events, simply use the _trackEvent function instead of the _trackPageview function, like so:

<a href="files/quarterly-earnings.pdf" target="_blank" onClick="pageTracker._trackEvent("PDF Files", "Downloads", "Quarterly Earnings Report", "500");">Quarterly Earnings Report</a>

(Learn all about Event Tracking with my latest blog post from last week)

The activity that occurred on your PDF Files will be within the Event Tracking section, which is a sub-section of the Content section of reports, instead of in the Top Content report.

Is there a difference between tracking PDF files as Pageviews or as Events?
Other than the obvious fact that one way will count them as a pageview, while the other way will count them as an event, the biggest difference between the two is the ability to track Goals. As of today, Google Analytics does not have the ability to track Events as Goals, so if you were planning to track all PDF downloads as Goals, you will need to track them as Pageviews, and not as Events. Advanced Segments are now available for Events, but they are not the same as Goals.

So what are you waiting for? Grab your webmaster and start tracking your PDF files with Google Analytics!

July 27 2009

Tracking Flash, Movies, and more with Event Tracking!

by MoreVisibility

Event TrackingLast month, the Google Analytics team finally lifted the curtains and officially removed the “Beta” label off of its brand new Event Tracking section. With Event Tracking, site owners now have the ability to track special interactions with their website, separate from pageviews. This can include tracking the activity of a movie player, an applet, a flash virtual tour, or any site element made in AJAX.

For starters, the new Event Tracking section of reports will be located within the main Content section, right underneath the Site Search report sub-section. Once there, you’ll be introduced to four new metrics: Categories, Actions, Labels, and Values. These metrics are also the building blocks of setting up Event Tracking on your flash applet or video player, as we’ll talk about in a little bit. First, let’s cover the metrics / reports that make up this section.

1. Categories
Categories are the highest level of organizational structure that you can have with Event Tracking. Think of it like the “root” level of a directory. You would use labels like “Videos” or “Downloads” for your Categories, and they would most likely be used multiple times throughout the main elements that you wish to track with Event Tracking.

2. Actions
Actions are exactly what they sound like – the actual interactions with your object. If you’re setting up Event Tracking for a video on your site, you could track a user pressing Play, Stop, Rewind, Fast-Forward, or adjusting the volume as an Action.

3. Labels
Labels are an optional value with Event Tracking, which allow you to provide additional information about the Action that just happened. Labels can be used for naming a movie (the title of the Movie), or the URL of a downloaded file, or some other name that you’d like to use for the subsequent Action.

4. Values
Values are also optional elements in Event Tracking that allow you to assign a numerical value to any action. These can help you quantify all of your actions, and Google Analytics will even throw in an Average Value figure for you to get an idea of how popular your Actions are.

Putting it all together
Because of the updated Google Analytics Tracking Code’s (ga.js) object-oriented modeling, newer features like Event Tracking are highly customizable, and can be programmed onto your movie or applet in a variety of different ways. However, the “standard” coding for Event Tracking looks like this:

pageTracker._trackEvent("Videos", "Stop", "G.I. Joe Trailer", "150");

Notice in my code example that you can see the four metrics in order from left to right after the call to _trackEvent- Category (“Videos”), Action (“Stop”), Label (“G.I. Joe Trailer”), and Value (“150”). This format must be followed, no matter where or how you decide to use Event Tracking.

A few general notes regarding Event Tracking

1. You must use the newer ga.js tracking script on your website’s pages in order to be able to utilize Event Tracking – it will not work using urchin.js.

2. There is a maximum of 500 Events allowed in a single user session (visit). Because of this, you should avoid setting up tracking for excessive mouse movements, tracking every second a video is played for, or every time someone right-clicks their mouse while playing your newest shoot-’em-up flash game.

3. Event Tracking – previously considered an interaction hit – is no longer counted as such by Google Analytics. This means that your Bounce Rate or your Average Time on Site metrics won’t be affected. Check out my blog post from back in January about Event Tracking interaction hits.

For deep technical schematics on Event Tracking, check out the Google Analytics Event Tracking Guide.

Happy Event Tracking!

© 2024 MoreVisibility. All rights reserved.