/** * @param \GoogleAnalyticsTracker\HitTypes\Page $page * @return mixed */ public function map($page) { if (!$page instanceof \GoogleAnalyticsTracker\HitTypes\Page) { throw new \UnexpectedValueException("The Page Mapper only accepts Page HitTypes"); } $data = array('t' => \GoogleAnalyticsTracker\HitTypes\Page::TYPE, 'dh' => $page->getDomain(), 'dp' => $page->getPage()); if ($page->hasTitle()) { $data['dt'] = $page->getTitle(); } $data = array_merge($data, parent::map($page)); return $data; }
/** * @param Event $event * @return mixed */ public function map($event) { if (!$event instanceof \GoogleAnalyticsTracker\HitTypes\Event) { throw new \UnexpectedValueException("The Event Mapper only accepts Event HitTypes"); } $data = array('t' => \GoogleAnalyticsTracker\HitTypes\Event::TYPE, 'ea' => $event->getAction(), 'ec' => $event->getCategory()); if ($event->hasLabel()) { $data['el'] = $event->getLabel(); } if ($event->hasValue()) { $data['ev'] = $event->getValue(); } $data = array_merge($data, parent::map($event)); return $data; }