コード例 #1
0
 public function summaryAction()
 {
     $config = Pimcore_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")));
     }
     if ($config->advanced) {
         if ($this->_getParam("id") && $this->_getParam("type")) {
             $url = "/pimcoreanalytics/" . $this->_getParam("type") . "/" . $this->_getParam("id");
             $filters[] = "ga:pagePath==" . $url;
         }
     } else {
         if ($this->_getParam("path")) {
             $filters[] = "ga:pagePath==" . $this->_getParam("path");
         }
     }
     $opts = array("dimensions" => "ga:date");
     if (!empty($filters)) {
         $opts["filters"] = implode(";", $filters);
     }
     $result = $this->service->data_ga->get("ga:" . $config->profile, $startDate, $endDate, "ga:uniquePageviews,ga:pageviews,ga:exits,ga:bounces,ga:entrances", $opts);
     $data = array();
     $dailyDataGrouped = array();
     foreach ($result["rows"] as $row) {
         foreach ($result["columnHeaders"] as $index => $metric) {
             if ($index) {
                 $dailyDataGrouped[$metric["name"]][] = $row[$index];
                 $data[$metric["name"]] += $row[$index];
             }
         }
     }
     $order = array("ga:pageviews" => 0, "ga:uniquePageviews" => 1, "ga:exits" => 2, "ga:entrances" => 3, "ga:bounces" => 4);
     $outputData = array();
     foreach ($data as $key => $value) {
         $outputData[$order[$key]] = array("label" => str_replace("ga:", "", $key), "value" => round($value, 2), "chart" => Pimcore_Helper_ImageChart::lineSmall($dailyDataGrouped[$key]), "metric" => str_replace("ga:", "", $key));
     }
     ksort($outputData);
     $this->_helper->json(array("data" => $outputData));
 }
コード例 #2
0
?>
" />
                    </div>
                    <div class="value"><?php 
echo $this->data["timeonsite"];
?>
</div>
                    <div class="label"><?php 
echo $this->translate("average_timeonsite");
?>
</div>
                </div>
                <div class="smallchart">
                    <div class="chart">
                        <img src="<?php 
echo Pimcore_Helper_ImageChart::lineSmall($this->dailyDataGrouped["bouncerate"]);
?>
" />
                    </div>
                    <div class="value"><?php 
echo round($this->data["bouncerate"], 2);
?>
</div>
                    <div class="label"><?php 
echo $this->translate("bouncerate");
?>
</div>
                </div>
            </div>
        </div>
    </div>