public function testHelperRendersDisplayFeaturesAdvertising()
 {
     $this->tracker->setEnableDisplayAdvertising(true);
     $expected = 'ga("require","displayfeatures");';
     $actual = $this->script->getCode();
     $this->assertContains($expected, $actual);
 }
Beispiel #2
0
    public function testDisplayFeaturesAdvertisingLoadsFileFromDoubleclick()
    {
        $this->tracker->setEnableDisplayAdvertising(true);
        $expected = <<<SCRIPT
(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

SCRIPT;
        $actual = $this->script->getCode();
        $this->assertContains($expected, $actual);
    }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('config');
     $gaConfig = $config['google_analytics'];
     $tracker = new Tracker($gaConfig['id']);
     if (isset($gaConfig['domain_name'])) {
         $tracker->setDomainName($gaConfig['domain_name']);
     }
     if (isset($gaConfig['allow_linker'])) {
         $tracker->setAllowLinker($gaConfig['allow_linker']);
     }
     if (true === $gaConfig['enable_display_advertising']) {
         $tracker->setEnableDisplayAdvertising(true);
     }
     if (true === $gaConfig['anonymize_ip']) {
         $tracker->setAnonymizeIp(true);
     }
     if (false === $gaConfig['enable']) {
         $tracker->setEnableTracking(false);
     }
     return $tracker;
 }