If you are like me, a blog writer, web developer and marketing analyst you know how important is Google Analytics to understand your business.

However, if you have spent more than a little time on GA you know how frustrating is to dig deeper into metrics and dimensions reported values. As SEO experts or well-established marketeers we might end up wondering if the bounce rate is too high, how the conversion rate could be improved or what percentage of business the organic traffic is bringing to the business.

Why tracking downloads?

Today I want to focus on how tracking downloads could offer a better view on how the visitors are interacting with our site. If we assume that people visiting our site are downloading mostly a PDF on a specific topic (let’s call it topic A), we can assume that most of our visitors are interested in topic A (and not in topic B, whose PDF gets rarely downloaded). Therefore, we can make decisions regarding:

  1. The type of content we should be producing to keep users coming back
  2. The type of email marketing campaign we should be focusing on
  3. The pages we could be using to drive users along the funnel that leads to conversion

Tracking downloads might also help solving a problem regarding single page visits. As you might know, Google Analytics cannot track how much time a user spent on your last page as it calculates the session duration as the exit page timestamp – entry page timestamp. However, if they concise, it cannot calculate the time the user spent on a single page and therefore GA sets it on zero.

This could be particularly frustrating as those page are calculated as having a high bounce rate even if a user spent even a long time reading our content! So, how can we know if a page with a high bounce rate is effectively a great page or not? The solution is asking the user to do something, such as:

  1. Sharing the page on social media
  2. Clicking a Thumb up button
  3. Visit another page
  4. Download a file!

To understand a little bit more how GA metrics values could be misleading, please read the next paragraph.

Engagement Metrics: Problems with Google Analytics Reports

In addition to more traffic, a website owner wants people to visit more pages and spend on average more time on a single page as they lead to an increase in engagement, conversion and (potentially) sales. To measure changes over time we might refers to GA metrics such as:

  1. Time spent on site
  2. Number of pages viewed
  3. Lower bounce rate

In Google Analytics Time on Page and Session Duration are quite often misunderstood metrics as Google can’t measure the time a user spent looking at the last page as Google uses the time of the next page view to determine time you spent looking at the current page. Therefore, if the Time on Page is unknown, it gets recorded as zero.

This means that for each exit page, the Time on Page is zero. Google takes into account this flaw when calculating the Avg Time on page:

Avg Time on Page = Time on Page / ( Pageviews - Exits)

However, only if a page does not have a high exit rate (% Exits), then the Avg Time on Page is a pretty good reflection of the real average. This means that the Avg time on Page could be grossly underestimated. Avg Time on Page is a good metrics only if exit rate is low. This metric is particularly frustrating for bloggers as visitors tend to read an article and then leave without visiting a second page.

The Session Duration metric cannot ignore the effect of exit pages: every session has an exit page, and if there aren’t many pages in the visit, the loss of that last page timing can have a massive impact on the total: in the “Bounce” case, the Sessions count is 1 but the Session Duration is 0!

Avg Session Duration = Session Duration / Sessions

The Avg Session Duration as a key performance indicator is not recommended as fluctuations in the number of pages viewed per session, the number of bounces, and the number of sessions can all influence the metric.

In summary: the Avg Time on Page calculation removes the effect of Bounces (Exits), but the Avg Session Duration calculation includes the Session count for those Bounces which reduces the average.

Track Events and Downloads: more accurate GA metrics

A solution -as mentioned before- is to ask users to perform a task such as downloading a file. This means that every user that downloads a file is associated to a session whose duration is now calculated based on the time the user performed the download. In conclusion, an interactive type of page could help to better calculate how much time users are spending on specific pages as GA is able to track downloads in a similar manner to pageviews.

How to track downloads: JavaScript tracking code

First, you need to locate your downloads in a well defined directory; something that represents what the folders contain so that you can easily find their reference in GA; something like app/subdirectory/folder_download_name/filename.pdf. Second, to find out if these folders have been visited, go to Behavior> Site Content > Content drilldown. From here you can learn:

  1. Which PDF was downloaded the most
  2. Which pages the users visited after the download

Third, in order to allow GA to track downloads, you need to add this tracking code to the <head>, inside the section of the HTML pages that contain the downloadable files:

function download(file)


ga('send', 'pageview', file);

alert("Thank you for your download.");

(window.location="http://www.yourdomain.com/subdirectory/filename.pdf"+ file);


Now that you tracking code is in place, you can finally start tracking your downloads.

Track your downloads via a text link

In case you are using a text (“Click Here”) to allow people to download a file, you need to make a change to your text to make it trackable via GA:

  • FROM <a href=”subdirectoty/filename.pdf”>Click here to download file </a>
  • TO <a href=”javacsript:download(‘/subdirectory/filename.pdf)”>Click here</a>to download more information.

And that’s it! Happy tracking!

Tracking your downloads via an image link

Source: CodeCanyon

At times, you might prefer to use an image (a button, a photo, a PDF vector) instead of a generic text (such as “Click here”) to encourage visitors to download your files. In HTML language, it means that you now need to track a <img> instead of <text>.

The way you achieve this is very simple: it is exactly the same principle used to track downloads via text. You only change the <text> with a <img> file and you are done!

  • FROM <a href=”subdirectoty/filename.pdf”><img src=”images/filename.jpg”></a>
  • TO <a href=”javacsript:download(‘/subdirectory/filename.pdf)”><img src=”images/filename.jpg”></a>

And that’s it! You are now all set to track your downloads via images!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.