Skip to content

Instantly share code, notes, and snippets.

@dmolsen
Created January 6, 2011 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dmolsen/768548 to your computer and use it in GitHub Desktop.
Save dmolsen/768548 to your computer and use it in GitHub Desktop.
A fix to the sendRequestToGoogleAnalytics() function from ga.php to support cURL
<?
function sendRequestToGoogleAnalytics($utmUrl) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accepts-Language: " . $_SERVER["HTTP_ACCEPT_LANGUAGE"]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_URL, $utmUrl);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment