How to Use Google Analytics in a Flash Game
For this tutorial I will be using Flash Develop and the Google Analytics for Flash library. I will show how to use the trackPageView function to track player progress in your game. You will need to sign up for a Google Analytics account.
Setup Library
First, download Google Analytics for Flash. Copy the two .swc files from the lib directory in the zip into your project. In Flash Develop edit your project properties and under Compiler Options add the two .swc files to SWC Libraries.
Add Tracking Code to Project
In your AS3 class you will need to add the import statements, initialize the tracker, and call trackPageView.
Create the tracker by passing in a reference to the stage and your tracking code. The analyticsCode is your Google Analytics tracking code you can use any site for your tracking code. I am actually using the same tracking code for this blog as I use for the game. (Where can I find my tracking code?) Once the tracker is created you can call tracker.trackPageview anytime you want to send a new page view event to your Google Analytics. The page does not need to actually exist. For my game I send page views for each rod and a page view for finishing the game.
Setting Up a Goal
On the Website Profile page in GA click Edit next to the profile you are using for this game. Under Conversion Goals and Funnel click Edit to create a new Goal. Set the Goal Active to On. The Goal URL is the "page" you are going to use for game over or whatever you want to have the user finish. The Goal Name is just a readable title for that goal. Now enter the steps to reach that goal, so for my game I have the steps of starting the game and getting each of the rods. Leave out the final game over step, that will be included for you. Click Save Changes.
Today's Data
Most people (including me) assume that you only get data the next day because by default Analytics only shows up till yesterday. However, you can get today's data by opening the date range calendar and clicking on today's date.
Setup Library
First, download Google Analytics for Flash. Copy the two .swc files from the lib directory in the zip into your project. In Flash Develop edit your project properties and under Compiler Options add the two .swc files to SWC Libraries.
Add Tracking Code to Project
In your AS3 class you will need to add the import statements, initialize the tracker, and call trackPageView.
Create the tracker by passing in a reference to the stage and your tracking code. The analyticsCode is your Google Analytics tracking code you can use any site for your tracking code. I am actually using the same tracking code for this blog as I use for the game. (Where can I find my tracking code?) Once the tracker is created you can call tracker.trackPageview anytime you want to send a new page view event to your Google Analytics. The page does not need to actually exist. For my game I send page views for each rod and a page view for finishing the game.
Setting Up a Goal
On the Website Profile page in GA click Edit next to the profile you are using for this game. Under Conversion Goals and Funnel click Edit to create a new Goal. Set the Goal Active to On. The Goal URL is the "page" you are going to use for game over or whatever you want to have the user finish. The Goal Name is just a readable title for that goal. Now enter the steps to reach that goal, so for my game I have the steps of starting the game and getting each of the rods. Leave out the final game over step, that will be included for you. Click Save Changes.
Today's Data
Most people (including me) assume that you only get data the next day because by default Analytics only shows up till yesterday. However, you can get today's data by opening the date range calendar and clicking on today's date.
Thanks for this Phil, worth me sharing I think :)
Very cool thanks for sharing! I am working on a game for Mochi's Word Play contest and wanted a way to track this sort of information. Thanks!
Thanks for your share! google chrome 49+ for windows 7 123 games free download download corel x3 free Points Full