Hi guys ( and girls ) today i will talk about the GA for Flash without use any component, only the GA library, like in post title: easy way.

Well the first part is download the GA library: http://code.google.com/p/gaforflash/downloads/list
There you will download a compacted file and when extract it, into the ‘lib’ folder you will see two swc files but the important file now is the analytics.swc

Second step is add analytics.swc file in your library path on Flash. Go to Edit > Preferences > Actionscript > Actionscript 3.0 Settings and now you may browser for SWC file on library path and select the analytics.swc file. Done? Fine. Now we can begin code.

In order for bridge mode to function correctly, ExternalInterface.avaliable must be set to true in your ActionScript 3 code. This also means thatallowScriptAccess should be set to always in the HTML page that embeds the Flash content.

Probably into your project files have a ‘mother function’ for your navigation and is in this function that analytics will have more efficiency, but lest import the GA classes first and after create the GATracker:

1
2
3
4
import com.google.analytics.AnalyticsTracker;
import com.google.analytics.GATracker;
// @ Creating the GA Object
var tracker:AnalyticsTracker = new GATracker( this, "UA-111-222", "AS3", true );

The upper code import and create the GA Object into your project, well import is the same code always but when you create the object need change the data for your Google Analytics account.

23
24
25
26
27
28
29
30
31
32
33
private function changeLink(m:MouseEvent):void
{
	pageID = m.currentTarget.id;
	pageName = pageList[pageID];
	// @ Using bellow custom loader and Events
	var newLoader:loadit = new loadit("pageName");
	newLoader.addEventListener(Events.PROGRESS, showProgress);
	newLoader.addEventListener(Events.COMPLETE, showPage);
	// @ Adding GA for Flash
	tracker.trackPageview("/ + String(pageName) + ");
}

The tracker.trackPageview will send to your HTML page a event alway that changLin function be executed and one day after in your Google Analytics account you will see the access for your flash links. tracker.trackPageview (virtualPage:String), this virtualPage receive the name that your put to your pages, no need physic file but you can set the name like one for sample

32
tracker.trackPageview("/pageName.php");

In your results will appear the access to pageName.php but this file no need exist, its so simple to use.
Try it.

Read too:

4 Responses to “Google Analytics for Flash, easy way.”

  1. 菲克斯咨询 » Blog Archive » 3月第一周精彩博客整理 Says:

    [...] ————————————— 开发技巧类 ————————————— 为Flex高级表格定制renderer 使用AS3将背景图平铺 一种较好的Math.Sin()实现 使用TimeRenderer和TimeEditor来编辑和显示时间 *** 在Flex3中生成PDF 在FlashCS4中创建原生的和非原生的AIR右键菜单 Flex:使用自定义事件传递数据 在TextInput组件中强制大写 BetterTitleWindow组件:一个自定义窗口标题栏的好方法 使用Ant编译带RSL的flex工程 使用已打开的Firefox tab页来调试Flex 在Flash中使用Google Analytics的简单方法 [...]

  2. Kożuchy Ekologiczne Says:

    To be echt I full hold with Your judgement.

  3. Kożuchy Ekologiczne Says:

    To be square I full hold with Your instrument.

  4. Kożuchy Ekologiczne Says:

    To be trustworthy I full hold with Your message.

Leave a Reply