/** * Track information. * Updates all the cookies, makes a server side request to Google Analytics. * * Defenitions of the Analytics Parameters are stored at: * http://code.google.com/apis/analytics/docs/tracking/gaTrackingTroubleshooting.html * http://www.cheatography.com/jay-taylor/cheat-sheets/google-analytics-utm-parameters-v2/ * * @param array $extraParams * @return boolean|GoogleAnalyticsServerSide */ private function track(array $extraParams = array()) { if ($this->botInfo !== null && $this->botInfo->isBot()) { return false; } $account = (string) $this->getAccount(); if (empty($account)) { throw new Exception\DomainException('The account number must be set before any tracking can take place.'); } $domainName = (string) $this->getServerName(); $documentReferer = (string) $this->getDocumentReferer(); $documentReferer = empty($documentReferer) && $documentReferer !== '0' ? '-' : urldecode($documentReferer); $this->setCookies(); // Construct the gif hit url. $queryParams = array('utmwv' => $this->getVersion(), 'utmn' => rand(0, 0x7fffffff), 'utmhn' => $domainName, 'utmr' => $documentReferer, 'utmac' => $account, 'utmcc' => $this->getCookiesString(), 'utmul' => $this->getAcceptLanguage(), 'utmcs' => $this->getCharset(), 'utmu' => 'q~'); if (0 === strpos($account, 'MO-')) { $queryParams['utmip'] = $this->getIPToReport(); } $queryParams = array_merge($queryParams, $extraParams); if (null !== ($customVarString = $this->getCustomVariableString())) { $queryParams['utme'] = (isset($queryParams['utme']) && !empty($queryParams['utme']) ? $queryParams['utme'] : '') . $customVarString; } $utmUrl = self::GIF_URL . '?' . http_build_query($queryParams, null, '&'); Http\Http::request($utmUrl); return $this; }