Beispiel #1
0
 public function validate()
 {
     // According to the GA documentation, there is a limit to the combined size of
     // name and value of 64 bytes after URL encoding,
     // see http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html#varTypes
     // and http://xahlee.org/js/google_analytics_tracker_2010-07-01_expanded.js line 563
     if (strlen(Util::encodeUriComponent($this->name . $this->value)) > 64) {
         Tracker::_raiseError('Custom Variable combined name and value encoded length must not be larger than 64 bytes.', __METHOD__);
     }
 }
Beispiel #2
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;
 }