For more information about calling the tracking pixel directly look at this article by Google.
After reading up on Google' documentation about how to use the tracking pixel I came up with a modified version of this PHP file.
Right now I combined the two (the tracking and the data coming from the parser, as described here) and use this primarily for my own analytics; To see where the user clicks, what screens are viewed, what device and OS the user is on etc. If other people found an other / better way i'd love to hear about it in the comments!
This implementation consists of two parts, AS3 and PHP. Let start off with the AS3.
// Setup tracking. This constant is just a string that holds the application name.
// The url passed is the location where the tracking.php is located. Include a trailing slash
// Do actual tracking on the screens/pages you want
Underwater this then creates an call to tracking.php?appname=YOUR_APPNAME&page=THE_SCREEN_YOU_WANT_TO_TRACK
The PHP then constructs an URL with the parameters defined in the Google spec defined above, calling the tracking GIF directly. Including the user defined parameters, appname and page.
header('Content-Type: text/html; charset=utf-8');
$var_utmac='UA-000000-0'; //enter the new urchin code
$var_utmhn='yourdomain.com'; //enter your domain
$var_utmn=rand(1000000000,9999999999);//random request number
$var_cookie=rand(10000000,99999999);//random cookie number
$var_random=rand(1000000000,2147483647); //number under 2147483647
$var_referer=$_SERVER['HTTP_REFERER']; //referer url
$var_uservar = $_GET["page"]; //this is the 'page' or 'application screen' we want to track, this comes through a parameter
$var_utmp='/app/'.$_GET["appname"].'/'.$var_uservar; // this creates a fake dir in our analytics called apps to differentiate between the mobile application and the normal pages we are tracking.
$handle = fopen($urchinUrl, "r");
$test = fgets($handle);
This PHP can of course be extended/modified to track events or other bits of interesting information that is useful to you. I'm still looking at a way to do event tracking. Ideas anyone?
The results after a day was a nice list in Google Analytics showing up like this:
Again the project can be found on Github for you to play around with, any questions and or comments, improvements etc, place a comment, i'd love to hear some feedback!