Google Analytics for Flash - getW3Help.com - Free Web Tutorials and Resources
Subscribe
Stay Updated
Google Analytics for Flash
Posted on May 1, 2009 by Makubex, 0 comments
In this tutorial lets see how to add google analytics to your flash project.
Flash CS3, AS 3.0




"Finally a blog post after 4 months!!! seriously guys been busy.."

First you have to grab the google analtics API for flash, called GA for Flash. You can download it here. And by the way its Actionscript 3.

GA for flash helps to track visitor movement of your website. (you don't even have to use SWF Address)

1. After downloading the GA for Flash, unzip the file. In the "lib" folder copy "analytics_flash.swc" file.

2. Now you have to paste this file into the Adobe components folder, you can find it.. {drive}\Program Files\Adobe\Adobe Flash CS3\en\Configuration\Components



3. Open a New Flash File (Actionscript 3).. Do not open flash file before pasting the swc file.

4. Press Ctrl+F7 to open components panel. Under Standard Components you can find Analytics component.

5. Drag and Drop the component into the library panel.

Now we have to do little bit of Actionscript.


import com.google.analytics.AnalyticsTracker;
import com.google.analytics.GATracker;


We have to import the GA class files into our flash.


var tracker:AnalyticsTracker = new GATracker( this, "UA-796209-3", "AS3", false );


Setting up the google analtyics tracker. The GATracker class consist of four parameters:
1. Reference the current display object. (in this example its 'this')
2. The web property ID: You google analytics Urchin ID, you can find it in the dashboard and the google analytics code.
3. Tracking mode: Valid parameters are Bridge or AS3.
4. Debug mode: Keep it false for production and true for trouble shooting.

Finally,

tracker.trackPageview("/page1");

Above code is all that needed to track the page. Copy paste this code everywhere you want to track your visitors. "/page1" is the virtual name given to track the page. You can change it to any name you want.

I have just made a simple example, a site with four links. Grab the source file below.

Example:


Download Source Files

Labels: , ,

Comments
Post a Comment

Hi, I am Karthikeyan VJ (aka makubex). I am a independent Interactive Developer and I am currently focusing on Flash, Flex and AIR