跟踪Flash广告上的点击次数

时间:2020-11-25 15:19:43

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.

当网站有第三方Flash广告时,该网站是否可以跟踪点击闪存?由于Flash文件不是由站点创建的,因此无法更改。但该网站希望通过自己的点击跟踪确认广告代理商报告的点击次数。

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

附加到对象或嵌入标记的JavaScript onclick(或其他鼠标事件)不起作用。

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.

我最近尝试过的是在flash上​​放置一个浮动的不可见div并将click事件附加到它上面。但是这在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?

我想到的另一种方法是使用我自己的Flash加载程序SWF。新的SWF会将广告SWF文件作为其显示的电影加载。然后,只要发生点击,加载程序闪存就会触发我的点击跟踪JS,然后允许点击事件继续进行广告Flash。这听起来可行/可行吗?

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)来自域example.com的flash是否可以从ads.mordor.com加载swf文件? 2)在另一个swf中加载的swf是否都可以获得点击事件?

1 个解决方案

#1


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.

你的装载技术似乎最合理。其中一个好处是,您可以将其设置为通用,以便它可以根据您的需要加载您想要的任何广告,同时始终产生相同的点击数据。这简化了捕获不同Flash广告有时会产生的多种类型点击数据的需求。

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)

ImportMe.as(在名为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)

Tester.as(加载从前一代码生成的ImportMe.swf剪辑)

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.

此示例唯一不测试的是外部事件是否会在内部剪辑执行URL重定向之前触发。

#1


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.

你的装载技术似乎最合理。其中一个好处是,您可以将其设置为通用,以便它可以根据您的需要加载您想要的任何广告,同时始终产生相同的点击数据。这简化了捕获不同Flash广告有时会产生的多种类型点击数据的需求。

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)

ImportMe.as(在名为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)

Tester.as(加载从前一代码生成的ImportMe.swf剪辑)

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.

此示例唯一不测试的是外部事件是否会在内部剪辑执行URL重定向之前触发。