/** * */ public function dispatchLoopShutdown() { if (!Tool::isHtmlResponse($this->getResponse())) { return; } if ($this->enabled && ($code = AnalyticsHelper::getCode())) { // analytics $body = $this->getResponse()->getBody(); // search for the end <head> tag, and insert the google analytics code before // this method is much faster than using simple_html_dom and uses less memory $headEndPosition = stripos($body, "</head>"); if ($headEndPosition !== false) { $body = substr_replace($body, $code . "</head>", $headEndPosition, 7); } $this->getResponse()->setBody($body); } }
public function portletAnalyticsSitesAction() { $t = \Zend_Registry::get("Zend_Translate"); $sites = new Site\Listing(); $data = [["id" => 0, "site" => $t->translate("main_site")]]; foreach ($sites->load() as $site) { if (\Pimcore\Google\Analytics::isConfigured($site)) { $data[] = ["id" => $site->getId(), "site" => $site->getMainDomain()]; } } $this->_helper->json(["data" => $data]); }
public function dataExplorerAction() { $config = Google\Analytics::getSiteConfig($this->getSite()); $startDate = date("Y-m-d", time() - 86400 * 31); $endDate = date("Y-m-d"); $metric = "ga:pageviews"; $dimension = "ga:date"; $descending = true; $limit = 10; if ($this->getParam("dateFrom") && $this->getParam("dateTo")) { $startDate = date("Y-m-d", strtotime($this->getParam("dateFrom"))); $endDate = date("Y-m-d", strtotime($this->getParam("dateTo"))); } if ($this->getParam("dimension")) { $dimension = $this->getParam("dimension"); } if ($this->getParam("metric")) { $metric = $this->getParam("metric"); } if ($this->getParam("sort")) { if ($this->getParam("sort") == "asc") { $descending = false; } } if ($this->getParam("limit")) { $limit = $this->getParam("limit"); } if ($filterPath = $this->getFilterPath()) { $filters[] = "ga:pagePath==" . $filterPath; } $opts = ["dimensions" => $dimension, "max-results" => $limit, "sort" => ($descending ? "-" : "") . $metric]; if (!empty($filters)) { $opts["filters"] = implode(";", $filters); } $result = $this->service->data_ga->get("ga:" . $config->profile, $startDate, $endDate, $metric, $opts); $data = []; foreach ($result["rows"] as $row) { $data[] = ["dimension" => $this->formatDimension($dimension, $row[0]), "metric" => (double) $row[1]]; } $this->_helper->json(["data" => $data]); }
?> , mail: <?php echo $this->mail_settings_complete; ?> , debug: <?php echo \Pimcore::inDebugMode() ? "true" : "false"; ?> , devmode: <?php echo PIMCORE_DEVMODE ? "true" : "false"; ?> , google_analytics_enabled: <?php echo \Zend_Json::encode((bool) \Pimcore\Google\Analytics::isConfigured()); ?> , google_webmastertools_enabled: <?php echo \Zend_Json::encode((bool) \Pimcore\Google\Webmastertools::isConfigured()); ?> , customviews: <?php echo \Zend_Json::encode($this->customview_config); ?> , language: '<?php echo $this->language; ?> ', websiteLanguages: <?php
public function navigationAction() { $config = Google\Analytics::getSiteConfig($this->getSite()); $startDate = date("Y-m-d", time() - 86400 * 31); $endDate = date("Y-m-d"); if ($this->getParam("dateFrom") && $this->getParam("dateTo")) { $startDate = date("Y-m-d", strtotime($this->getParam("dateFrom"))); $endDate = date("Y-m-d", strtotime($this->getParam("dateTo"))); } // all pageviews if ($filterPath = $this->getFilterPath()) { $filters[] = "ga:pagePath==" . $filterPath; } $opts = array("dimensions" => "ga:pagePath", "max-results" => 1, "sort" => "-ga:pageViews"); if (!empty($filters)) { $opts["filters"] = implode(";", $filters); } $result0 = $this->service->data_ga->get("ga:" . $config->profile, $startDate, $endDate, "ga:pageViews", $opts); $totalViews = (int) $result0["totalsForAllResults"]["ga:pageViews"]; // ENTRANCES $opts = array("dimensions" => "ga:previousPagePath", "max-results" => 10, "sort" => "-ga:pageViews"); if (!empty($filters)) { $opts["filters"] = implode(";", $filters); } $result1 = $this->service->data_ga->get("ga:" . $config->profile, $startDate, $endDate, "ga:pageViews", $opts); $prev = array(); foreach ($result1["rows"] as $row) { $d = array("path" => $this->formatDimension("ga:previousPagePath", $row[0]), "pageviews" => $row[1]); $document = Document::getByPath($row[0]); if ($document) { $d["id"] = $document->getId(); } $d["percent"] = round($d["pageviews"] / $totalViews * 100); $d["weight"] = 100; if ($prev[0]["weight"]) { $d["weight"] = round($d["percent"] / $prev[0]["percent"] * 100); } $prev[] = $d; } // EXITS $opts = array("dimensions" => "ga:pagePath", "max-results" => 10, "sort" => "-ga:pageViews"); if (!empty($filters)) { $opts["filters"] = implode(";", $filters); } $result2 = $this->service->data_ga->get("ga:" . $config->profile, $startDate, $endDate, "ga:pageViews", $opts); $next = array(); foreach ($result2["rows"] as $row) { $d = array("path" => $this->formatDimension("ga:previousPagePath", $row[0]), "pageviews" => $row[1]); $document = Document::getByPath($row[0]); if ($document) { $d["id"] = $document->getId(); } $d["percent"] = round($d["pageviews"] / $totalViews * 100); $d["weight"] = 100; if ($next[0]["weight"]) { $d["weight"] = round($d["percent"] / $next[0]["percent"] * 100); } $next[] = $d; } $this->view->next = $next; $this->view->prev = $prev; $this->view->path = $this->getFilterPath(); $this->getResponse()->setHeader("Content-Type", "application/xml", true); }