Hello Szabi! Avatar

Posts tagged javascript

Notes

Silverlight tracking with Google Analytics

We (at my company) wanted to know the Silverlight distribution rate within our visitors. Since Google Analytics doesn’t support this kind of tracking yet (but there are rumors that they are working on it) I had to find a solution by myself.

Mark Monster posted a really good script, and I’ve implemented it successfully. But it is a no-go, and I tell you why: Analytics has a pretty neat API which you can use to track “virtual pageviews”, E-Commerce transactions and so on. Mark’s solution based on virtual pageviews which are good for tracking nonexisting pages (for example AJAX content), but definitely not good for tracking “statistics”.
The script generated almost 800.000 pageviews in one day, which -of course- distorted our real numbers. So, I’ve had a lot of pageviews which I could you use, but this method wasn’t acceptable in the long run.

And there came the Event tracking feature! It’s awesome, if you want to know more about your visitors’ habits. Basically you can track clicks which don’t lead to another page, like e-mail and PDF links, play counts in an embedded video, and so on. (you can read more about the feature in the official documentation). I modified Mark’s script a bit, and came out with this solution:

You need two things to apply it to your page:

  1. Microsoft’s Silverlight checker script
  2. The code above

Paste them in your code after _trackPageview, like in this example:

Keep in mind that you must paste the two new javascripts after the pageTracker init!

If everything’s ok, you would see something like this:

Hints:

  • After you’re done you have to wait a few hours until Analytics gather the data (so don’t be impatient!)
  • Since Event tracking is currently in a limited beta test, the Analytics team hadn’t rolled it out to everyone, so you might not see the link to these reports in the Content menu. But don’t worry, Analytics is collecting your data whether you have this link or not. And, with a little trick, you can see the charts! Just open a report (doesn’t matter which one), and change the word after the “/reporting/” parameter in the URL.
    Like this: www.google.com/analytics/reporting/sources?blah=blah&…
    To this: www.google.com/analytics/reporting/events?blah=blah&…

Feel free to use the code, and kudos to Mark Monster for the original idea!

Following