2
votes

I've installed Google Analytics on my website, and I want to now use 'Event tracking' to generate reports on .M4a music files that are contained in my site via typical HTML anchor tags.

Google gives this example of how to do this, which I fully understand:

<a href="../_audio/podcast_024.m4a" onClick="_gaq.push(['_trackEvent', 'Podcasts', 'Download', 'Podcast 024']);">Download</a>

However, in my case, a lot of people are accessing my .m4a podcast files by either:

1) Clicking on a direct link from an external site [eg wwww.music.com/audio/podcast_024.m4a]

or;

2) Collecting the file through a podcast aggregator such as iTunes.

So my question is:

How do I track these kind of events listed above (1 & 2)?

I imagine there is a way to track No.1 by adding perhaps some similar "onLoad" event code? If so, can I group an onLoad event with the current onclick event?

As for No.2, I have no idea?

1

1 Answers

2
votes

in both of these cases the audio file is requested directly from the server, so you can't track this with javascript (such as ga.js).

it is possible though to make requests to google analytics on the server-side, see this question for more info on that. using this technique, the link on the audio file must not point to the file itself, but to a script running on the server, making the request to ga and delivering the audio then.

aside from this, depending on your server environment, any requests to files on the server will/can be tracked anyway, via access log files.