Tutorial – Google Analytics (Event) Tracking for Flash / Flex

Hi Everyone,

as of sometime in November, Google has released a AS3 module that enables communication directly with Google Analytics, w/o the constraints of passing through Javascript. This combined with the imminent public deployment of Event Tracking, makes for a very exciting combination indeed!

This post is a follow-up to a previous post: Using Google Analytics to track activity inside of a Flash or Flex AS3 application, I suggest reading it as it will give you in-depth details on how google analytics works.

There are a few situations where you would like to use the AS3 module instead of the Javascript API to track activity in your flash application. For example:

  • Your app is distributed using Gigya, ClearSpring, WidgetAvenue or other distribution platform.
  • Your app is hosted on a different host than the html page it is contained in (which would cause cross-scripting nightmares)
  • Your app is an AIR app, hence no HTML around it
  • You are a developer and don’t want to have to embed your app inside of HTML to know if event tracking works! (my favorite!)

Continue reading

Tutorial – AS3 & REST web services with RESTProxy – Part 1

Hi Everyone,

[UPDATE Jan 19th, 2008]
I’ve just modified RESTProxy.php to handle gzip encoding from the client-side. It was quite simple. I was trying to consume web services on Discogs.com and it requires that you accept gzip encoding..

a while back, almost a year ago now, I published a little package of code called RESTProxy. This proxy is accessed from Flash AS3 code through AMFPHP to process HTTP requests otherwise not possible because of cross-domain limitations or because flash.net.URLLoader doesn’t allow the operation. True in Flex you have HTTPService which allows you the full spectrum of REST web service calls, however not so in flash.

In this tutorial I’ll cover when to use RESTProxy, guide you through it’s installation then show you a few examples.

URLLoader vs. RESTProxy

The following chart explains the advantages of using RESTProxy over URLLoader.

RESTProxy versus URLLoader

However, it is possible all you want is to consume webservices using POST and GET, on a host with a valid cross-domain.xml file; in which case you do not need RESTProxy. I developed RESTProxy to consume the more advanced data services from the YouTube GData Web Services.
Continue reading