array( "method" => "GET", "user_agent" => $_SERVER["HTTP_USER_AGENT"], "header" => ("Accepts-Language: " . $_SERVER["HTTP_ACCEPT_LANGUAGE"])) ); if (!empty($_GET["utmdebug"]))$data = file_get_contents($utmUrl, false, stream_context_create($options)); else $data = @file_get_contents($utmUrl, false, stream_context_create($options)); } // Track a page view, updates all the cookies and campaign tracker, makes a server side request to Google Analytics and writes the transparent gif byte data to the response. function trackPageView() { $domainName = $_SERVER["SERVER_NAME"]; if (empty($domainName)) $domainName = ""; // Get the referrer from the utmr parameter, this is the referrer to the page that contains the tracking pixel, not the referrer for tracking pixel. $documentReferer = $_GET["utmr"]; if (empty($documentReferer) && $documentReferer !== "0") $documentReferer = "-"; else $documentReferer = urldecode($documentReferer); $documentPath = $_GET["utmp"]; if (empty($documentPath))$documentPath = ""; else $documentPath = urldecode($documentPath); $visitorId = getVisitorId($_SERVER["HTTP_X_DCMGUID"], $_GET["utmac"], "{$_SERVER['HTTP_USER_AGENT']}", $_COOKIE['__utmmobile']); // Always try and add the cookie to the response. setrawcookie( '__utmmobile', $visitorId, time() + 63072000, '/'); $utmGifLocation = "http://www.google-analytics.com/__utm.gif"; // Construct the gif hit url. $utmUrl = $utmGifLocation . "?" . "utmwv=" . '4.4sh' . "&utmn=" . rand(0, 0x7fffffff) . "&utmhn=" . urlencode($domainName) . "&utmr=" . urlencode($documentReferer) . "&utmp=" . urlencode($documentPath) . "&utmac=" . $_GET["utmac"] . "&utmcc=__utma%3D999.999.999.999.999.1%3B" . "&utmvid=" . $visitorId . "&utmip=" . (preg_match("/^([^.]+\.[^.]+\.[^.]+\.).*/", $_SERVER["REMOTE_ADDR"], $matches)) ? $matches[1] . "0":''; sendRequestToGoogleAnalytics($utmUrl); // If the debug parameter is on, add a header to the response that contains // the url that was used to contact Google Analytics. if (!empty($_GET["utmdebug"])) header("X-GA-MOBILE-URL:" . $utmUrl); // Finally write the gif data to the response. writeGifData(); } ?>