Пример #1
0
 /**
  * @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/v4/Tracker.as#1503
  *
  * @return \Plugin\GoogleAnalytics\ApiLib\Internals\ParameterHolder
  */
 protected function buildParameters()
 {
     $p = parent::buildParameters();
     $x10 = new X10();
     $x10->clearKey(self::X10_EVENT_PROJECT_ID);
     $x10->clearValue(self::X10_EVENT_PROJECT_ID);
     // Object / Category
     $x10->setKey(self::X10_EVENT_PROJECT_ID, X10::OBJECT_KEY_NUM, $this->event->getCategory());
     // Event Type / Action
     $x10->setKey(self::X10_EVENT_PROJECT_ID, X10::TYPE_KEY_NUM, $this->event->getAction());
     if ($this->event->getLabel() !== null) {
         // Event Description / Label
         $x10->setKey(self::X10_EVENT_PROJECT_ID, X10::LABEL_KEY_NUM, $this->event->getLabel());
     }
     if ($this->event->getValue() !== null) {
         $x10->setValue(self::X10_EVENT_PROJECT_ID, X10::VALUE_VALUE_NUM, $this->event->getValue());
     }
     $p->utme .= $x10->renderUrlString();
     if ($this->event->getNoninteraction()) {
         $p->utmni = 1;
     }
     if (isset($this->page)) {
         $p->utmp = $this->page->getPath();
         $p->utmdt = $this->page->getTitle();
         if ($this->page->getCharset() !== null) {
             $p->utmcs = $this->page->getCharset();
         }
         if ($this->page->getReferrer() !== null) {
             $p->utmr = $this->page->getReferrer();
         }
     }
     return $p;
 }
Пример #2
0
 /**
  * Equivalent of _trackEvent() in GA Javascript client.
  *
  * @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEventTracking.html#_gat.GA_EventTracker_._trackEvent
  * @param \Plugin\GoogleAnalytics\ApiLib\Event $event
  * @param \Plugin\GoogleAnalytics\ApiLib\Session $session
  * @param \Plugin\GoogleAnalytics\ApiLib\Visitor $visitor
  * @param \Plugin\GoogleAnalytics\ApiLib\Page $page
  */
 public function trackEvent(Event $event, Session $session, Visitor $visitor, Page $page = null)
 {
     // Ensure that all required parameters are set
     $event->validate();
     $request = new EventRequest(static::$config);
     $request->setEvent($event);
     $request->setSession($session);
     $request->setVisitor($visitor);
     if ($page) {
         $request->setPage($page);
     }
     $request->setTracker($this);
     $request->fire();
 }