While signing up for a new Google Analytics profile, we noticed a change in their new platform. The confirmation screen that gives you the tracking code is now drawn in via AJAX. Being the curious types that we are, we opened up Firebug to take a look at why this might be happening.
The first thing we noticed was that the response from Google looks like a block of PHP code wrapped in what appears to be a Java serialized string.

Cleaning up the response, it looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <?php // Copyright 2009 Google Inc. All Rights Reserved. $GA_ACCOUNT = "MO-11576892-1"; $GA_PIXEL = "ga.php"; function googleAnalyticsGetImageUrl() { global $GA_ACCOUNT, $GA_PIXEL; $url = ""; $url .= $GA_PIXEL . "?"; $url .= "utmac=" . $GA_ACCOUNT; $url .= "&utmn=" . rand(0, 0x7fffffff); $referer = $_SERVER["HTTP_REFERER"]; $query = $_SERVER["QUERY_STRING"]; $path = $_SERVER["REQUEST_URI"]; if (empty($referer)) { $referer = "-"; } $url .= "&utmr=" . urlencode($referer); if (!empty($path)) { $url .= "&utmp=" . urlencode($path); } $url .= "&guid=ON"; return $url; } ?> <?php $googleAnalyticsImageUrl = googleAnalyticsGetImageUrl(); ?> <img src="<?= $googleAnalyticsImageUrl ?>" /> |
It’s definitely PHP, so why does the server return PHP code to a client-side script? It returned a function that builds up an image URL containing our account ID and some other information.
The Tracking Code Troubleshooting page has documentation on what all the query string parameters mean. The image URL that is built up contains only basic information of what would otherwise look like a normal tracking code request. Only the account ID, path, referrer, and a random number are passed. There’s also guid=ON, which is not in the documentation.
The other strange part is that normally the account ID begins with UA-, but in this case begins with MO-. Maybe it’s some sort of initialization request?