示例#1
0
 /**
  * Will extract information for the "trackCount" and "startTime"
  * properties from the given "__utmb" cookie value.
  * 
  * @see Internals\ParameterHolder::$__utmb
  * @see Internals\Request\Request::buildCookieParameters()
  * @param string $value
  * @return $this
  */
 public function fromUtmb($value)
 {
     $parts = explode('.', $value);
     if (count($parts) != 4) {
         Tracker::_raiseError('The given "__utmb" cookie value is invalid.', __METHOD__);
         return $this;
     }
     $this->setTrackCount($parts[1]);
     $this->setStartTime(new DateTime('@' . $parts[3]));
     // Allow chaining
     return $this;
 }
示例#2
0
文件: Visitor.php 项目: clops/php-ga
 /**
  * @see generateUniqueId
  * @param int $value
  */
 public function setUniqueId($value)
 {
     if ($value < 0 || $value > 0x7fffffff) {
         Tracker::_raiseError('Visitor unique ID has to be a 32-bit integer between 0 and ' . 0x7fffffff . '.', __METHOD__);
     }
     $this->uniqueId = (int) $value;
 }
示例#3
0
 /**
  * @param int $scope
  */
 public function setScope($scope)
 {
     if (!in_array($scope, array(self::SCOPE_PAGE, self::SCOPE_SESSION, self::SCOPE_VISITOR))) {
         Tracker::_raiseError('Custom Variable scope has to be one of the CustomVariable::SCOPE_* constant values.', __METHOD__);
     }
     $this->scope = (int) $scope;
 }
示例#4
0
 /**
  * @link http://xahlee.org/js/google_analytics_tracker_2010-07-01_expanded.js line 575
  * @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
  * @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
  */
 protected function buildCustomVariablesParameter(ParameterHolder $p)
 {
     $customVars = $this->tracker->getCustomVariables();
     if ($customVars) {
         if (count($customVars) > 5) {
             // See http://code.google.com/intl/de-DE/apis/analytics/docs/tracking/gaTrackingCustomVariables.html#usage
             Tracker::_raiseError('The sum of all custom variables cannot exceed 5 in any given request.', __METHOD__);
         }
         $x10 = new X10();
         $x10->clearKey(self::X10_CUSTOMVAR_NAME_PROJECT_ID);
         $x10->clearKey(self::X10_CUSTOMVAR_VALUE_PROJECT_ID);
         $x10->clearKey(self::X10_CUSTOMVAR_SCOPE_PROJECT_ID);
         foreach ($customVars as $customVar) {
             // Name and value get encoded here,
             // see http://xahlee.org/js/google_analytics_tracker_2010-07-01_expanded.js line 563
             $name = Util::encodeUriComponent($customVar->getName());
             $value = Util::encodeUriComponent($customVar->getValue());
             $x10->setKey(self::X10_CUSTOMVAR_NAME_PROJECT_ID, $customVar->getIndex(), $name);
             $x10->setKey(self::X10_CUSTOMVAR_VALUE_PROJECT_ID, $customVar->getIndex(), $value);
             if ($customVar->getScope() !== null && $customVar->getScope() != CustomVariable::SCOPE_PAGE) {
                 $x10->setKey(self::X10_CUSTOMVAR_SCOPE_PROJECT_ID, $customVar->getIndex(), $customVar->getScope());
             }
         }
         $p->utme .= $x10->renderUrlString();
     }
     return $p;
 }
示例#5
0
 /**
  * @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/campaign/CampaignTracker.as#153
  */
 public function validate()
 {
     // NOTE: gaforflash states that id and gClickId must also be specified,
     // but that doesn't seem to be correct
     if (!$this->source) {
         Tracker::_raiseError('Campaigns need to have at least the "source" attribute defined.', __METHOD__);
     }
 }