setResolution() public method

Sets user resolution width and height.
public setResolution ( integer $width, integer $height )
$width integer
$height integer
コード例 #1
0
<?php

// Example file to demonstrate PiwikTracker.php
// See http://piwik.org/docs/tracking-api/
require_once '../../libs/PiwikTracker/PiwikTracker.php';
PiwikTracker::$URL = 'http://localhost/trunk/';
$piwikTracker = new PiwikTracker($idSite = 1);
// You can manually set the Visitor details (resolution, time, plugins)
// See all other ->set* functions available in the PiwikTracker class
$piwikTracker->setResolution(1600, 1400);
// Sends Tracker request via http
$piwikTracker->doTrackPageView('Document title of current page view');
// You can also track Goal conversions
$piwikTracker->doTrackGoal($idGoal = 1, $revenue = 42);
echo 'done';
コード例 #2
0
 /**
  * Returns a PiwikTracker object that you can then use to track pages or goals.
  *
  * @param         $idSite
  * @param         $dateTime
  * @param boolean $defaultInit If set to true, the tracker object will have default IP, user agent, time, resolution, etc.
  *
  * @return PiwikTracker
  */
 public static function getTracker($idSite, $dateTime, $defaultInit = true, $useLocal = false)
 {
     if ($useLocal) {
         require_once PIWIK_INCLUDE_PATH . '/tests/LocalTracker.php';
         $t = new Piwik_LocalTracker($idSite, self::getTrackerUrl());
     } else {
         $t = new PiwikTracker($idSite, self::getTrackerUrl());
     }
     $t->setForceVisitDateTime($dateTime);
     if ($defaultInit) {
         $t->setIp('156.5.3.2');
         // Optional tracking
         $t->setUserAgent("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)");
         $t->setBrowserLanguage('fr');
         $t->setLocalTime('12:34:06');
         $t->setResolution(1024, 768);
         $t->setBrowserHasCookies(true);
         $t->setPlugins($flash = true, $java = true, $director = false);
     }
     return $t;
 }
コード例 #3
0
 /**
  * Returns a PiwikTracker object that you can then use to track pages or goals.
  *
  * @param $idSite
  * @param $dateTime
  * @param $defaultInit If set to true, the tracker object will have default IP, user agent, time, resolution, etc.
  * @return PiwikTracker
  */
 protected function getTracker($idSite, $dateTime, $defaultInit = true)
 {
     $t = new PiwikTracker($idSite, $this->getTrackerUrl());
     $t->setForceVisitDateTime($dateTime);
     if ($defaultInit) {
         $t->setIp('156.5.3.2');
         // Optional tracking
         $t->setUserAgent("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)");
         $t->setBrowserLanguage('fr');
         $t->setLocalTime('12:34:06');
         $t->setResolution(1024, 768);
         $t->setBrowserHasCookies(true);
         $t->setPlugins($flash = true, $java = true, $director = false);
     }
     return $t;
 }
コード例 #4
0
ファイル: Aplicativo.php プロジェクト: netinhoteixeira/pudim
 /**
  * Inicia a análise de tráfego.
  */
 private function iniciarAnaliseTrafego()
 {
     if ($this->_configuracao->get($this->_servidor . '.piwik_id')) {
         require_once implode(DIRECTORY_SEPARATOR, [__DIR__, '..', '..', '..', '..', 'library', 'PiwikTracker.php']);
         $piwikTracker = new \PiwikTracker($this->_configuracao->get($this->_servidor . '.piwik_id'), $this->_configuracao->get($this->_servidor . '.piwik_url'));
         if ($this->_configuracao->get($this->_servidor . '.piwik_token_auth')) {
             $piwikTracker->setTokenAuth($this->_configuracao->get($this->_servidor . '.piwik_token_auth'));
         }
         if (isset($_SERVER['HTTP_REFERER'])) {
             $piwikTracker->setReferrer($_SERVER['HTTP_REFERER']);
         }
         // detecta o endereço da internet do cliente
         if (isset($_SERVER['HTTP_CLIENT_IP'])) {
             $piwikTracker->setIp($_SERVER['HTTP_CLIENT_IP']);
         } else {
             if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
                 $piwikTracker->setIp($_SERVER['HTTP_X_FORWARDED_FOR']);
             } else {
                 if (isset($_SERVER['HTTP_X_FORWARDED'])) {
                     $piwikTracker->setIp($_SERVER['HTTP_X_FORWARDED']);
                 } else {
                     if (isset($_SERVER['HTTP_FORWARDED_FOR'])) {
                         $piwikTracker->setIp($_SERVER['HTTP_FORWARDED_FOR']);
                     } else {
                         if (isset($_SERVER['HTTP_FORWARDED'])) {
                             $piwikTracker->setIp($_SERVER['HTTP_FORWARDED']);
                         } else {
                             if (isset($_SERVER['REMOTE_ADDR'])) {
                                 $piwikTracker->setIp($_SERVER['REMOTE_ADDR']);
                             } else {
                                 $piwikTracker->setIp('DESCONHECIDO');
                             }
                         }
                     }
                 }
             }
         }
         $piwikTracker->setUserAgent($_SERVER['HTTP_USER_AGENT']);
         if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
             $idioma = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
             $piwikTracker->setBrowserLanguage($idioma[0]);
             unset($idioma);
         }
         if ($this->postExists('localTime')) {
             $piwikTracker->setLocalTime($this->post('localTime'));
         }
         if ($this->postExists('screenWidth') && $this->postExists('screenHeight')) {
             $piwikTracker->setResolution($this->post('screenWidth'), $this->post('screenHeight'));
         }
         if ($this->postExists('position')) {
             $posicao = $this->post('position');
             $piwikTracker->setLongitude($posicao['longitude']);
             $piwikTracker->setLatitude($posicao['latitude']);
             unset($posicao);
         }
     } else {
         $piwikTracker = null;
     }
     return $piwikTracker;
 }
コード例 #5
0
function piwik_analytics($aid, $purl, $name, $go, $html = 1)
{
    require_once dirname(__FILE__) . '/lib/PiwikTracker.php';
    global $blog_settings;
    if (empty($go)) {
        $go = $_SERVER['PHP_SELF'];
    }
    PiwikTracker::$URL = $blog_settings->get('piwik_url');
    $screen_resolution = "1280x800";
    if (!isset($_SESSION[iterate]) && $html) {
        if (!isset($_COOKIE["piwik_user_resolution"])) {
            //means cookie is not found set it using Javascript
            $_SESSION[iterate] = 1;
            ?>
<script language="javascript"><!--
	writeCookie();
	function writeCookie() {
		var the_cookie = "piwik_user_resolution="+ screen.width +"x"+ screen.height;
		document.cookie=the_cookie
		location ='<?php 
            echo $go;
            ?>
';
	}
//--></script>
<?php 
        } else {
            $screen_resolution = $_COOKIE["piwik_user_resolution"];
        }
    } else {
        $screen_resolution = $_COOKIE["users_resolution"];
    }
    $screen_resolution = preg_split('x', $screen_resolution);
    $t = new PiwikTracker($idSite = $aid, $blog_settings->get('piwik_url'));
    // Optional tracking
    $t->setUserAgent($_SERVER['HTTP_USER_AGENT']);
    $t->setBrowserLanguage(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2));
    $t->setLocalTime(date("H:i:s"));
    $t->setResolution($screen_resolution[0], $screen_resolution[1]);
    // Mandatory
    $t->setUrl($url = $purl);
    $t->doTrackPageView($name);
}