If your website contains Flash movies that link offsite or to microsites, you may wish to register the offsite link using WebTrends. This article provides an introduction. It assumes a little knowledge of ActionScript, Javascript as well as WebTrends.

This example uses a intermediary javascript function that sits between the Flash movies and the WebTrends code.

Benefits

  • It's much easier to debug if the WebTrends javascript is not called within the compiled Flash movie
  • The WebTrends tracking can be changed later without recompiling the Flash movie or even speaking to your Flash developer

Drawbacks

  • Javascript must be enabled to trigger the link to the target web page
  • Both Flash and Javascript will be required to navigate your website

This is bad from an accessibility point of view, but I won't discuss that here.

ActionScript for Flash buttons

Edit your Flash movies so that the button that links to your external website or microsite has an ActionScript event handler which will trigger a call to Javascript.

Older ActionScript versions

[source]on (release)
{
getURL("javascript:myFlashEvent('Open Days','http://www.nottingham.ac.uk/opendays');");
}[/source]

ActionScript 3+

The getURL function was removed in ActionScript 3, so a slightly more complex example is required
[source]if (ExternalInterface.available)
{
try
{
ExternalInterface.call(
'myFlashEvent', // function name
'Open Days', // function parameter 1
'http://www.nottingham.ac.uk/opendays' // function parameter 2
);
}
catch (error:Error)
{
// Error handling here
}
catch (error:SecurityError)
{
// Error handling here
}
}[/source]

The ActionScript calls the Javascript intermediary function myFlashEvent, which in turn registers the event with WebTrends and then loads the new web page.

Javascript

[source language="javascript"]function myFlashEvent(eventDescription, eventValue){

// Register Event with WebTrends
dcsMultiTrack(
'DCS.dcsuri', eventValue, // name/value pair for URL
'WT.ti', 'FlashEvent:' + eventDescription // name/value pair for page title
);

// Go to URL
document.location.href = eventValue;
}[/source]

This function will track the event as a visit to a URI using the DCS.dcsuri parameter. The page title for the URI will be set to e.g. 'FlashEvent:My Page Title' using the WT.ti parameter.

Results

The click event is showing up nicely in WebTrends as FlashEvent:Open Days, see the screenshot below

Screenshot of WebTrends Console

Example code

A working example of this code can be found here.

Sorry, I don't have access to the .fla file, so that is not included.

Adapting the Javascript for Google Analytics

The myFlashEvent function can easily be adapted to work with Google Analytics instead:

[source language="javascript"]function myFlashEvent(eventDescription, eventValue){

// Register event
pageTracker._trackEvent(
'Flash', 'Link',
eventDescription, eventValue
);

// Go to URL
document.location.href = eventValue;
}[/source]

Reference