Tracking Visitors in a Rich Media World, Part V: Flash

March 31st, 2009 by ghebbron

Flash tracking as with AJAX is done through calls to dcsMultiTrack. However because a Flash applet file (.swf) is embedded into a page as a self contained object this means we must use a different method to make calls to other elements such as the logging script within the page.

We can use any event in Flash to trigger a dcsMultiTrack call; video completions, slide views, loading percentage indicators, clicks, drags, drops and more. The most common or at least traditional method for calling dcsMultiTrack within Flash uses the getURL function:

on(release){
getURL(”javascript:dcsMultiTrack(’parameter1′,’value1′,’parameter2′,’value2′);”);
}

This code would be added to each button that needs to be tracked. If you’re smart you won’t want to rewrite the multiTrack onto every event handler call for every button across your site. It makes sense as with did with AJAX to use a more modular approach. Taking the getURL method above and placing the call into its own ActionScript function, then calls to the event handlers can also be passed along with parameters to this function.

function trackEvent(value1,value2){
getURL(”javascript:dcsMultiTrack(’parameter1′,’”+value1+”‘,’parameter2′, ‘”+value1+”‘);”);
}

An alternate to getURL is the externalInterface method:
import flash.external.ExternalInterface;

function trackEvent(value1,value2):Void
{
If (ExternalInterface.available)
{
ExternalInterface.call(”dcsMultiTrack”,’Parameter1′,value1,’parameter2′,valu e2);
}
}

Where scalability may be a factor the externalInterface method is the best probably the best choice. In addition to being scalable, externalInterface is the new “best practice” method for page/Flash object interactions. It allows data to be passed in and out of the Flash object (a getURL is a static one-way command). Because of the added flexibility, this method will allow new interactions to happen as they are developed.

Should the externalinterface method be attached to all event handlers enabling you to collect information on any and every interaction? Or prehaps limited only to duistinct content loads/views within the applet? And what should you be passing as parameters? Why not join us to discuss this at Engage 2009 in our Workgroup. Look forward to seeing you there.

Tags: , ,

One Response to “Tracking Visitors in a Rich Media World, Part V: Flash”

  1. Ary Mega Says:

    Faced with this issue today, thank you for providing.

Leave a Reply