Adobe Animate swf:跟踪Google Analytics中的点击次数

时间:2017-12-13 13:58:12

标签: javascript actionscript-3 flash google-analytics

我在Adobe Animate swf文件中设置按钮点击跟踪时遇到问题。当我签入Google Analytics时,我看不到任何报告的事件。

我已经附加了Animate FLA的部分AS3代码(如下)。我需要跟踪大约30个按钮,所以其余的几乎是“BtnXX.addEventListner()...”代码片段的重复。

如果有任何帮助,我将不胜感激。

我遵循了此网站上的建议:https://code.tutsplus.com/tutorials/quick-tip-how-to-use-google-analytics-for-tracking-in-flash--active-3331

代码从这里开始:

import com.google.analytics.AnalyticsTracker; 
import com.google.analytics.GATracker; 
import flash.events.MouseEvent;

var tracker:AnalyticsTracker; 
var tracker1:AnalyticsTracker;
var tracker2:AnalyticsTracker; 

if (stage) {
          initializeTracker();
}
else {
          // It seems we need to be on a display list before we can initialize the tracker
          addEventListener(Event.ADDED_TO_STAGE, addToStageHandler);         
}


function addToStageHandler(event:Event):void {
          // Clean up
          removeEventListener(Event.ADDED_TO_STAGE, addToStageHandler);
          // Initialize tracker
          initializeTracker();
}

function initializeTracker():void {
          tracker = new GATracker(stage, "UA-40516249-2", "AS3", false);
}


/* pause at the beginning */
stop();

/* Click to go to the testimonials*/

BtnFR.addEventListener(MouseEvent.CLICK, fl_GoToFR);
function fl_GoToFR(event:MouseEvent):void
{gotoAndStop("FR");}

function onClickFR (event:MouseEvent):void
{
    var mySelection:String = event.target.name;
    tracker.trackEvent('navigation', 'click', mySelection);
}

BtnDE.addEventListener(MouseEvent.CLICK, fl_GoToDE);
function fl_GoToDE(event:MouseEvent):void
{gotoAndStop("DE");}

function onClickDE (event:MouseEvent):void
{
    var mySelection:String = event.target.name;
    tracker.trackEvent('navigation', 'click', mySelection);
}

BtnAT.addEventListener(MouseEvent.CLICK, fl_GoToAT);
function fl_GoToAT(event:MouseEvent):void
{gotoAndStop("AT");}

function onClickAT (event:MouseEvent):void
{
    var mySelection:String = event.target.name;
    tracker.trackEvent('navigation', 'click', mySelection);
}

BtnAction.addEventListener(MouseEvent.CLICK, fl_ClickToMore);
function fl_ClickToMore(event:MouseEvent):void
{navigateToURL(new URLRequest("http://www.communiquer.net/index.html”), "_blank");
}
function onClickClientContact (event:MouseEvent):void
{
    var mySelection:String = event.target.name;
    tracker.trackEvent('navigation', 'click', mySelection);
}

0 个答案:

没有答案