Google Analytics Tracking for Adobe Flash

A new API for using  Google Analytics Tracking in Flash/Flex projects this API is developed in ActionScript 3.0 and can be used as a component or called in your ActionScript code, Google Analytics Tracking for Adobe Flash seems to solve a lot of troubles and the needed workarounds for making consistent user tracking in your Flash projects, keep reading for a more detailed explanation extracted from the implementation overview.

The Google Analytics Tracking for Adobe Flash component makes it easy for you to implement Google Analytics in your Flash-driven content. This component contains all of the functionality of the Google Analytics Javascript code, and is 100% compatible with the latest ga.js tracking code. The Flash Tracking component is a compiled tracking object native to ActionScript 3, making Analytics implementation intuitive in Flash, and Flex development environments.

You can develop Analytics Tracking for Flash in either Adobe Flash or Adobe Flex environments. Each environment requires a different component, which you can download from http://code.google.com/p/gaforflash/. These components are based on ActionScript 3 and can be set up in one of two ways for each environment:

In Adobe Flash

  • Add and configure a simple component in the component inspector and drag it to the stage.
  • Import the Flash Tracking libraries directly into your library and start coding.

In Adobe Flex

  • Include an MXML component that you configure from am MXML file.
  • Import the Flash Tracking libraries into your script tags/AS3 files.

How to use the Component in Adobe Flash

In order to use the Flash tracking component in your environment, you either use the visual tools inside Flash, or you set up the tracking object directly in your code. Regardless of whether you are setting up the component visually or via code, you provide the following elements:

  • the web property ID—This is also known as the UA number of your tracking code and looks like UA-xxxxx-yy, where the x’s and y’s are replaced with the numbers that correspond to your account and profile information for the object you are tracking. See Web Property for more information.
  • the tracking mode—Choose either bridge mode or AS3 mode. This mode determines how your tracking communicates with the Analytics servers and is described in detail below.
  • the debugging mode—No matter which environment or tracking mode you use, you can turn debugging on to validate and test your tracking.

Installation for Flash CS3

Before you begin to use gaforflash to add Analytics tracking within Flash CS3,
you first need to add the gaforflash SWC to Flash CS3.

To do so:
1. If you have Flash CS3 currently open, quit the application.

2. Navigate to the location where you unzipped the Google Analytics zip
and find the swc (e.g. lib/analytics_flash.swc).

3. Create a “Google” directory in one of the following locations
and copy the SWC file there:
– (Windows) C:\Program Files\Adobe\ Adobe Flash CS3\language\Configuration\Components
– (Mac OS X) Macintosh HD/Applications/Adobe Flash CS3/Configuration/Components

Flash CS3 is now set up to support Google Analytics Tracking For Adobe Flash.

Alternatively if you want to use gaforflash in code-only mode
you can do the same as the above and add the lib/analytics.swc,
you will then need to drag the “AnalyticsLibrary” component in your Library.

Installation for Flex Builder 3

Before you can compile your code, you will need to link it to the gaforflash SWC file.

To do so:
1. select Project->Properties.
A Properties dialog box will appear for your project.
Click on Flex Build Path and then select the Library Path tab:

2. Click Add SWC… within the Library Path pane.
An Add SWC dialog box will appear.
Navigate to the location where you unzipped the Google Analytics zip
and select lib/analytics.swc file and click OK.

or

Just drop the analytics.swc file into your Flex project /libs directory

Here’s the link for the Google code project

The gaforflash direct download

More info on the API

Author: Dave Gamez

Digital Craftsman from México and have more than 14 years of experience both in design and development in the digital field. I currently work in web, desktop, mobile and illustration projects alike and spend my time between being Technology Director at Team-O a Digital Studio I co-founded with Cecy Meade and doing consultancy work, when time allows it I like to experiment and tinker with code, animation and illustration.