public function __construct($event, $params) { if (empty($event)) { Shopware()->PluginLogger()->debug("event must be set, received: '{$event}', event could not be tracked"); return; } if (!array_key_exists('_a', $params)) { $params['_a'] = Shopware_Plugins_Frontend_Boxalino_P13NHelper::getAccount(); } if (!array_key_exists('_ev', $params)) { $params['_ev'] = $event; } if (!array_key_exists('_t', $params)) { $params['_t'] = round(microtime(true) * 1000); } $cems = Shopware()->Front()->Request()->getCookie('cems'); $cemv = Shopware()->Front()->Request()->getCookie('cemv'); if (!array_key_exists('_bxs', $params)) { $params['_bxs'] = empty($cems) ? self::getSessionId() : $cems; } if (!array_key_exists('_bxv', $params)) { $params['_bxv'] = empty($cemv) ? self::getSessionId() : $cemv; } if (array_key_exists('referer', $params)) { $this->referer = $params['referer']; unset($params['referer']); } else { $this->referer = array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : ''; } $this->params = $params; }
private static function buildScript($pushes = null) { $account = Shopware_Plugins_Frontend_Boxalino_P13NHelper::getAccount(); return <<<SCRIPT <script type="text/javascript"> var _bxq = _bxq || []; _bxq.push(['setAccount', '{$account}']); _bxq.push(['trackPageView']); {$pushes} (function(){ var s = document.createElement('script'); s.async = 1; s.src = '//cdn.bx-cloud.com/frontend/rc/js/ba.min.js'; document.getElementsByTagName('head')[0].appendChild(s); })(); </script> SCRIPT; }