Judah Phillips On Rich Internet Apps For Beginners, Part II Of III: Google Analytics

March 28, 2007

Yesterday, famous guest blogger Judah Phillips of Reed Publishing wrote Part I of a three-part guess post for this blog. Part I was, What are Rich Internet Applications? Today, we have Part II, How to measure them with Google Analytics. (And the follow up will be, how to measure them with Unica.)

Before you read this post, you might want to read a post that Justin Cutroni published on Saturday night. He wrote about tracking clicks to pages where you make the name up, because you can’t put the code on the page. Links that take you off the page, .pdfs, etc. It is a good basis for what Judah is going to talk about: creating page names out of thin air and then using the pretend pages to track events (and hence, rich media) in GA. So here we are, lucky again to have Judah Phillips:

Since we all know about page tags, let’s get down to business with “the Google” and how it tracks “the Rich Media:”

Google Analytics enables tracking of any browser event, such as Javascript and Flash events. Those smart folks at Google have a little JavaScript function called urchinTracker() that enables event tracking. Use the JavaScript function with an argument specifying a name for the event.

For example, the function:

javascript:urchinTracker(‘/mysite/flashrichmedia/playbutton’);

logs each occurrence of that Flash event as a page view of

/mysite/flashrichmedia/playbutton.

Some caveats:
1) Always use a forward slash to begin the argument.
2) Actual pages with these filenames do not need to exist.
3) You can organize your events into any structure or hierarchy you want.

Important: Google says to place your tracking code “between the opening tag and the JavaScript call” if your pages include a call to urchinTracker(), utmLinker(), utmSetTrans(), or utmLinkPost().

For example, if the page view is the major event and the “play” event a minor event; then, your hiearchy would be Page View > Event, where the page contains an event, such that:

/mysite/ria_bittons/playbutton
/mysite/ria_bittons/pausebutton
/mysite/ria_bittons/playbutton
/mysite/ria_clips/clip

Some example of the code (from Google Help):

on (release) {// Track with no actiongetURL("javascript:urchinTracker('/folder/file');");} 

This one above tracks when you click and release (although technically, it just notices the release) of a flash button (and records the file you specify as a page view).

on (release) {//Track with actiongetURL("javascript:urchinTracker('/folder/file');");_root.gotoAndPlay(3);myVar = "Flash Track Test"}

The second one is the same, but by using a function,
passing it a parameter, and
identifying the instance you want to track, you can measure when your file was used
in a specific scene in a little flash movie. So it is a more specific
method for handling event tracking in Flash.

onClipEvent (enterFrame) {getURL("javascript:urchinTracker('/folder/file');");} 

And the third one repeats the action throughout the movie so that each time the file is loaded, it gets tracked as an event. If you were to pass a unique file at the end of the movie, you could recognize it using this method (or the other methods) to know that the whole movie was watched (as long as your session doesn’t time out).

Now wait until Google updates your analytics to see if it all worked.