public function ssga::create in GA Push 7
File
- libs/
ssga.class.inc, line 82 - SSGA Class implementation
Class
- ssga
- Class created for serversidegoogleanalytics http://code.google.com/p/serversidegoogleanalytics/
Code
public function create() {
if ($this
->getEventString()) {
#Event
$this
->setAnalyticsType();
$parameters = array(
'utmwv' => $this
->getVersion(),
'utmn' => $this
->getRandomNumber(),
'utmhn' => $this
->getHostName(),
'utmt' => 'event',
'utme' => $this
->getEventString(),
'utmcs' => $this
->getCharset(),
'utmul' => $this
->getLanguage(),
# "utmdt" => $this->getPageTitle(),
'utmhid' => $this
->getGetUniqueId(),
# "utmp" => $this->getPageView(),
'utmac' => $this
->getAccountId(),
'utmcc' => $this
->getCookieVariables(),
);
}
else {
#PageView
$parameters = array(
'utmwv' => $this
->getVersion(),
'utmn' => $this
->getRandomNumber(),
'utmhn' => $this
->getHostName(),
'utmcs' => $this
->getCharset(),
'utmul' => $this
->getLanguage(),
'utmdt' => $this
->getPageTitle(),
'utmhid' => $this
->getGetUniqueId(),
'utmp' => $this
->getPageView(),
'utmac' => $this
->getAccountId(),
'utmcc' => $this
->getCookieVariables(),
);
}
$c = curl_init();
curl_setopt($c, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
if ($_SERVER['HTTP_REFERER']) {
curl_setopt($c, CURLOPT_REFERER, $_SERVER['HTTP_REFERER']);
}
curl_setopt($c, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($c, CURLOPT_URL, $this->beaconURL . '?' . http_build_query($parameters));
#ip
#curl_setopt($c, CURLOPT_INTERFACE, $_SERVER['REMOTE_ADDR'] );
#curl_setopt($c, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: " . $_SERVER['REMOTE_ADDR'], "HTTP_X_FORWARDED_FOR: " . $_SERVER['REMOTE_ADDR']));
$o = curl_exec($c);
curl_close($c);
return $o;
}