flash - 对ActionScript 2实现Google Analytics(分析)跟踪的最佳方法是什么?

标签 flash google-analytics actionscript-2

我正在寻找用于将Google Analytics(分析)事件跟踪与ActionScript 2 Flash电影配合使用的代码,示例,库,组件。我可以在Google代码网站上找到有关AS3的信息,但找不到AS2。关于标记我的Flash文件以使用异步Google Analytics(分析)代码的教程和示例的最佳资源是什么?我发现了有关旧版Google Analytics(分析)代码的一些旧信息。

谢谢

最佳答案

我必须对AS2项目进行大量维护,所以我知道您来自哪里。这是我的工作:

第1步是在您的HTML中设置Flash影片可以使用的Google Analytics(分析)跟踪信标。 Google提供了有关如何执行此操作的示例,但以下是我最近进行的设置的示例:

<!-- Set up Google Analytics tracking -->
    <script type="text/javascript">
        var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
        document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>

    <script type="text/javascript">

        // I'm pulling in my project id tag from a config file
        // you will want to use the project id that google gives you. Ex: UA-#####-#

        var pageTracker = _gat._getTracker('<?php echo $config['_tracker']; ?>');
        pageTracker._initData();

    </script>
<!-- End Google Analytics setup -->


通过在页面上设置信标,您现在可以使用ExternalInterface使Flash电影向Google发送跟踪消息。在Flash的某个位置,您需要一个函数,可以从代码中的其他任何地方调用该函数,如下所示:

function track(event:String) {    
    if(ExternalInterface.available) {
        ExternalInterface.call("pageTracker._trackPageview", event);
    }
}


当您要跟踪事件时,您可以使用Google Analytics(分析)语法传递一个准确描述事件的字符串。例如:/root/loadingFinished或类似名称。

希望这会有所帮助!祝好运!

关于flash - 对ActionScript 2实现Google Analytics(分析)跟踪的最佳方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6204221/

相关文章:

actionscript-3 - 我有一个soundTransform问题。

google-analytics - Google Analytics(分析):需要处理比标准限制更多的维度和指标数量的大型查询?

javascript - 如何用JS/jQuery控制flash电影

variables - 为什么函数会声明 "myVariable = myVariable;"?

flash - Flash 中的多种字体/语言支持

python - 可以在 Facebook 墙上发布的 Flash 文件中添加链接吗?

google-chrome - 不进入隐身模式就无法进入 Google Analytics

google-analytics - 在 Google Analytics 中重放历史数据(事件)

flash - YouTube api音频不会停止播放

flash - 我的项目渲染器没有找到属性 "data."