tags:

views:

247

answers:

1

When a site has third party flash ads, is it possible for the site to track clicks to the flash? As the flash files are not created by the site, they cannot be changed. But the site wants to confirm the click-through counts that the ad agency is reporting with its own click tracking.

JavaScript onclick (or other mouse events) attached to the object or embed tags do not work.

What I have tried most recently is to place a floating invisible div over the flash and attaching the click event to that. However this does not function well in IE.

An alternative I am thinking of is to use my own Flash loader SWF. The new SWF would load the ad SWF file as a movie it displays. Then whenever a click happens the loader flash would trigger my click tracking JS, and then allow the click event to continue on to the ad flash. Does that sound possible/feasible?

Addendum: I have two questions about the loader method:
1) Can a flash from domain example.com load a swf file from ads.mordor.com?
2) Can a swf loaded within another swf both get click events?

+1  A: 

Your loader technique seems the most sane. One of the benefits is, you can make it generic so that it can load any ad you want, with as many instances on the page as you need, while always yielding the same click data. This simplifies the need to capture multiple types of click data that different Flash ads sometimes produce.

Here is some code I got working, sorry in advance for the large snippets.

ImportMe.as (has a button instance on the stage named myButton)

package
{
    import flash.display.MovieClip;
    import flash.display.SimpleButton;
    import flash.events.MouseEvent;

    public class ImportMe extends MovieClip
    {
     public function ImportMe()
     {
      myButton.addEventListener(MouseEvent.CLICK, button_OnClick);
     }

     private function button_OnClick(event:MouseEvent):void
     {
      // shifts the button right 10 pixels to prove the event fired
      myButton.x += 10;
     }
    }
}

Tester.as (loads the ImportMe.swf clip generated from the previous code)

package
{
    import flash.display.MovieClip;
    import flash.display.Loader;
    import flash.net.URLRequest;
    import flash.events.*;

    public class Tester extends MovieClip
    {
     public function Tester()
     {
      var request:URLRequest = new URLRequest("importme.swf");
      var loader:Loader = new Loader();
      loader.addEventListener(Event.COMPLETE, loader_OnComplete);
      loader.addEventListener(MouseEvent.CLICK, loader_OnClick);
      loader.load(request);
      addChild(loader);
     }

     private function loader_OnComplete(event:Event):void
     {
      trace("loaded");
     }

     private function loader_OnClick(event:MouseEvent):void
     {
      trace("clicked");
     }
    }
}

The only thing this example doesn't test is whether or not the external event will fire before the internal clip does a url redirect.

Soviut
But is it actually possible? My actionscript is rusty, so before i dust it off i want to know if it is workable.
Rob
Seems like you would need to know how to 'activate' the link in the Flash ad, which might require that you know how it was built. Sounds like it might be difficult, but then again my actionscript is probably more rusty than yours...
metanaito
I think that click events in flash bubble like they do in HTML/DOM/JS, can anyone confirm that?
Rob