Basically I want to run the Google Analytics on the server and not show the 1px .GIF (the reason for this is that I want to display an image without it being in HTML but as a Content-type: image/jpeg
$GA_ACCOUNT = "MO-3845491-5";
$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;
}
$googleAnalyticsImageUrl = googleAnalyticsGetImageUrl();
//echo '<img src="' . $googleAnalyticsImageUrl . '" />';
//open the google script with all our settings to generate the 1px x 1px blank gif which reports to GA
$handle = fopen ($googleAnalyticsImageUrl, "r");
$test = fgets($handle);
echo $test;
fclose($handle);
//Pretend this page was a jpg image all along and get the jpg and return it.
$imageurl = fopen ('http://www.default.com/test.jpg', "r"); //this is where the real file should be located
while (!feof ($imageurl)) {
$image = fgets($imageurl, 4096);
header('Content-type: image/jpeg');
echo $image;
}
fclose($imageurl);
Any help would be greatly appreciated as I am very new to GA