Google Analytics: Tracking Matrix file asset type downloads


(Nic Hubbard) #1

Since most Matrix files are served by apache, it is not as easy to log those downloads with Google Analytics. So, I wrote a little jQuery to bind click events to any links that look like files. Just make sure to add the Google tracking code above where you place this code:

    $("a[href*='.pdf'], a[href*='.doc'], a[href*='.xls'], a[href*='.ppt']").click(function() {
    	pageTracker._trackPageview('/doc/' + $(this).attr('href'));
    });
    $("a[href*='.mov']").click(function() {
    	pageTracker._trackPageview('/video/' + $(this).attr('href'));
    });
    $("a[href*='.zip']").click(function() {
    	pageTracker._trackPageview('/file/' + $(this).attr('href'));
    });
    $("a[href*='.mp3']").click(function() {
    	pageTracker._trackPageview('/audio/' + $(this).attr('href'));
    });


Now, since we have added the file type to the data we send to Google, we just go to Google Analytics, click "Content", then "Top Content", and enter the file type to search for, such as /doc or /audio and it should find all the Matrix files that were downloaded, and their stats.

Don't forget the standard jQuery ready function. :)

(Rhulse) #2

I don't normally do "that's awsesome" posts, but …


That's awesome.


(Miriam Clinton) #3

[quote]
I don't normally do "that's awsesome" posts, but …



That's awesome.

[/quote]



That IS awesome. It also looks like it will work with Piwik (www.piwik.org) which logs stats in a very similar way but is locally hosted.


(Steve Brown) #4

Its not perfect though.


This only counts when a file is accessed by clicking on YOUR links. It doesnt count any accesses that are done:


  1. From another website straight to your file
  2. From a search engine straight to the file
  3. From a bookmark straight to the file



    As long as you keep this in mind when implementing…

(Nic Hubbard) #5

[quote]
Its not perfect though.



This only counts when a file is accessed by clicking on YOUR links. It doesnt count any accesses that are done:


  1. From another website straight to your file
  2. From a search engine straight to the file
  3. From a bookmark straight to the file



    As long as you keep this in mind when implementing…

    [/quote]



    Thanks for pointing this out to everyone, this is important to remember.

(Robin Shi) #6

[quote]
Its not perfect though.



This only counts when a file is accessed by clicking on YOUR links. It doesnt count any accesses that are done:


  1. From another website straight to your file
  2. From a search engine straight to the file
  3. From a bookmark straight to the file



    As long as you keep this in mind when implementing…

    [/quote]

    I have not heard any implementation of GA doing the above but am very interested to know.

(Aslam720) #7

Hi everyone!


In a nutshell:

Im trying to create a document uploader that allows users to specify a time when the document will no longer be visible on the website.

e.g. upload movie timetable for a week and it is removed from the website after the week is up



Im having a bit of trouble with the triggers (setting them up to only affect 1 folder and subcontent), how to include the time that the document should 'expire' via the asset builder tool. I want the user to define when the document should expire and then the trigger will change its status so that is it no longer visible (e.g. Under Construction)


(Nic Hubbard) #8

[quote]
Hi everyone!



In a nutshell:

Im trying to create a document uploader that allows users to specify a time when the document will no longer be visible on the website.

e.g. upload movie timetable for a week and it is removed from the website after the week is up



Im having a bit of trouble with the triggers (setting them up to only affect 1 folder and subcontent), how to include the time that the document should 'expire' via the asset builder tool. I want the user to define when the document should expire and then the trigger will change its status so that is it no longer visible (e.g. Under Construction)

[/quote]



John,



You should post this as its own topic, otherwise it is going to get buried.