dv8withn8
dv8withn8

Reputation: 333

Tracking File Downloads with Google Analytics

I have an html file that gets loaded when a user connects a flash drive to their PC. That HTML contains a direct link to a PDF on our server. (They don't want to put the PDF on the drive for some reason) Anyway, I'm trying to figure out how to track how many times this PDF is accessed from one of these drives.

Since the user is being taken directly to the file and not a landing page, is there a way I can attach analytics to the link that directs the user to the file? I was thinking a Virtual Page View would work but I don't understand exactly how GA would be getting that data.

Can anyone help demystify this?

Upvotes: 1

Views: 1955

Answers (3)

Dan
Dan

Reputation: 3890

You can attach a javascript function to the link and have it track the page view with Google Analytics

Check this out for more.

It's an easy way to track any file download on a website.

Upvotes: 0

Sampsa Suoninen
Sampsa Suoninen

Reputation: 624

The issue is not the JavaScript, since you can include that locally, but the fact that GA won't work on HTML loaded from a filesystem.

The landing page can be built so that it automatically triggers the download and GA while that happens. Pageviews won't be an issue, since downloads should be tracked as events anyway.

Upvotes: 0

jk.
jk.

Reputation: 14435

GA needs to run javascript. PDFs will not invoke a call to GA when hit directly from search results, emails, or flash drives.

You might be able to track it by creating a rewrite rule on your server to a page that runs the GA code then loads the PDF on that page.

I had a similar feature on my site and it worked well except that while tracking the PDFs, the page that loaded the PDF was inflating my pageviews numbers. I didn't want PDF's to be mixed in with pageviews because it confused the client who had been used to separating the two. I created a filter for the PDF 'calling' page and the pageview number settled back down.

I ended up removing this method and falling back to the server logs for PDF downloads and GA for everything else.

GA is a javascript tracker. Plain and simple.

Upvotes: 3

Related Questions