Access All Your Google Analytics Data in Flash/AIR Projects with ActionScript 3 Client Library

google-analytics-logo Google Analytics blog introduced a new ActionScript 3 Client Library, this library provides a simple way to access your Analytics Data from both AIR Applications and Flash Player (though a proxy). The developers an easily integrate Google Analytics into their Flash/AIR projects with this AS3 library.

“Given the potential value of this library to many other developers, we decided to make it freely available along with its source code,”

says Denis Bulichenko, Director of Business Development at DENIVIP.

google-analytics-results

It’s very simple to embed Google Analytics data into your Application:

1. Download AS3 Google Analytics API library SWC

2. Include SWC library into your project

3. Import library packages

// Main class
import com.denivip.ga.APILoader;
// Google Analytics Account
import com.denivip.ga.GAAccount;
// Dimensions
import com.denivip.ga.dimensions.CampaignMediumDimension;
import com.denivip.ga.dimensions.CampaignSourceDimension;
// Metrics
import com.denivip.ga.metrics.VisitorBouncesMetric;
import com.denivip.ga.metrics.VisitorVisitsMetric;
// Filters classes
import com.denivip.ga.filter.Filter;
import com.denivip.ga.filter.FilterItem;
import com.denivip.ga.filter.FilterOperator;
// View classes
import com.denivip.ga.view.GAView;

4. Configure Google Analytics API request through APILoader class and initiate connection

// Create GA API connector
var apiloader_ga:APILoader = new APILoader();
// Initial configuration – ids=ga:12345
apiloader_ga.setTableID("ga:12345");
// Configure dimensions – check Developers Guide Dimensions section for details
apiloader_ga.setDimensions(new Array(new CampaignSourceDimension(), new CampaignMediumDimension()));
// Configure metrics – check Developers Guide Metrics section for details
apiloader_ga.setMetrics(new Array(new VisitorVisitsMetric(), new VisitorBouncesMetric()));
// Configure filter – check Developers Guide Filters section for details
apiloader_ga.setFilter(new Filter(new FilterItem(new CampaignMediumDimension(), new FilterOperator("=="), "referral" )));
// Configure segment
var sgm:Filter = new Filter(new FilterItem("gaid::10"));
sgm.addFilterItem("OR", new FilterItem("dynamic::ga:medium", new FilterOperator("=="), "referral"));
apiloader_ga.segmentData(sgm);           

// Timeframe setup, pay attention that months are zero based in AS3
var start_date:Date = new Date(2010, 10, 9);
var end_date:Date = new Date(2010, 11, 8);
apiloader_ga.setPeriod(start_date, end_date);

// Set callback (returns array of DataFeedResponse objects)
apiloader_ga.setCallback(refreshGraph);

// Configure view (process data and prepares everything in your way)
apiloader_ga.registerView(gav);

// Connect and begin data loading
apiloader_ga.connect(new GAAccount("login@gmail.com", "pwd"));

You can get this open source library from here and you also can find the QuickStart Guide and GA API documentation.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • Reddit
  • Technorati
  • StumbleUpon
  • Twitter
RSS Enjoy this Post? Subscribe to Ntt.cc

RSS Feed   RSS Feed     Email Feed  Email Feed Follow us Follow us
You can leave a response, or trackback from your own site.

One Response to “Access All Your Google Analytics Data in Flash/AIR Projects with ActionScript 3 Client Library”

  1. Rich Tretola says:

    Looks like this swc is no longer available at the link you listed, can you send me a copy?

Leave a Reply