Пример #1
0
 /**
  * @return string
  */
 protected function buildHttpRequest()
 {
     $this->setXForwardedFor($this->visitor->getIpAddress());
     $this->setUserAgent($this->visitor->getUserAgent());
     // Increment session track counter for each request
     $this->session->increaseTrackCount();
     // See http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/v4/Configuration.as?r=237#48
     // and http://code.google.com/intl/de-DE/apis/analytics/docs/tracking/eventTrackerGuide.html#implementationConsiderations
     if ($this->session->getTrackCount() > 500) {
         Tracker::_raiseError('Google Analytics does not guarantee to process more than 500 requests per session.', __METHOD__);
     }
     if ($this->tracker->getCampaign()) {
         $this->tracker->getCampaign()->increaseResponseCount();
     }
     return parent::buildHttpRequest();
 }
Пример #2
0
 /**
  * @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
  */
 protected function buildParameters()
 {
     $p = new ParameterHolder();
     $p->utmac = $this->tracker->getAccountId();
     $p->utmhn = $this->tracker->getDomainName();
     $p->utmt = $this->getType();
     $p->utmn = Util::generate32bitRandom();
     // The "utmip" parameter is only relevant if a mobile analytics
     // ID (MO-123456-7) was given,
     // see http://code.google.com/p/php-ga/issues/detail?id=9
     $p->utmip = $this->visitor->getIpAddress();
     $p->aip = $this->tracker->getConfig()->getAnonymizeIpAddresses() ? 1 : null;
     if ($p->aip) {
         // Anonymize last IP block
         $p->utmip = substr($p->utmip, 0, strrpos($p->utmip, '.')) . '.0';
     }
     $p->utmhid = $this->session->getSessionId();
     $p->utms = $this->session->getTrackCount();
     $p = $this->buildVisitorParameters($p);
     $p = $this->buildCustomVariablesParameter($p);
     $p = $this->buildCampaignParameters($p);
     $p = $this->buildCookieParameters($p);
     return $p;
 }