Skip to content
Extraits de code Groupes Projets
Valider 76a91e4e rédigé par mattpiwik's avatar mattpiwik
Parcourir les fichiers

Refs #409

 * Deprecated setting, moved to JS API instead
{{{
; if set to 0, any goal conversion will be credited to the last more recent non empty referer. 
; when set to 1, the first ever referer used to reach the website will be used
use_first_referer_to_determine_goal_referer = 0
}}}
 * New setting to allow using 3rd party cookies for visitor ID cookie only
{{{
; Piwik uses first party cookies by default. If set to 1, 
; the visit ID cookie will be set on the Piwik server domain as well
; this is useful when you want to do cross websites analysis 
use_third_party_cookies = 0
}}}
 * Tracker uses 1st cookie values for Goals referrer attribution 
 * removed log_conversion.referer_idvisit field, unused

git-svn-id: http://dev.piwik.org/svn/trunk@3888 59fd770c-687e-43c8-a1e3-f5a4ff64c105
parent 8da6d218
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -220,6 +220,11 @@ latest_version_url = http://piwik.org/latest.zip ...@@ -220,6 +220,11 @@ latest_version_url = http://piwik.org/latest.zip
api_service_url = http://api.piwik.org api_service_url = http://api.piwik.org
[Tracker] [Tracker]
; Piwik uses first party cookies by default. If set to 1,
; the visit ID cookie will be set on the Piwik server domain as well
; this is useful when you want to do cross websites analysis
use_third_party_cookies = 0
; set to 0 if you want to stop tracking the visitors. Useful if you need to stop all the connections on the DB. ; set to 0 if you want to stop tracking the visitors. Useful if you need to stop all the connections on the DB.
record_statistics = 1 record_statistics = 1
...@@ -229,10 +234,6 @@ visit_standard_length = 1800 ...@@ -229,10 +234,6 @@ visit_standard_length = 1800
; visitors that stay on the website and view only one page will be considered as time on site of 0 second ; visitors that stay on the website and view only one page will be considered as time on site of 0 second
default_time_one_page_visit = 0 default_time_one_page_visit = 0
; if set to 0, any goal conversion will be credited to the last more recent non empty referer.
; when set to 1, the first ever referer used to reach the website will be used
use_first_referer_to_determine_goal_referer = 0
; By default, Piwik does not trust the idcookie as accurate and will always check that if the visitor visited ; By default, Piwik does not trust the idcookie as accurate and will always check that if the visitor visited
; the website earlier by looking for a visitor with the same IP and user configuration (to avoid abuse or misbehaviour) ; the website earlier by looking for a visitor with the same IP and user configuration (to avoid abuse or misbehaviour)
; This setting should only be set to 1 in an intranet setting, where most users have the same configuration (browsers, OS) ; This setting should only be set to 1 in an intranet setting, where most users have the same configuration (browsers, OS)
......
...@@ -228,7 +228,6 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface ...@@ -228,7 +228,6 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface
server_time datetime NOT NULL, server_time datetime NOT NULL,
idaction_url int(11) default NULL, idaction_url int(11) default NULL,
idlink_va int(11) default NULL, idlink_va int(11) default NULL,
referer_idvisit int(10) unsigned default NULL,
referer_visit_server_date date default NULL, referer_visit_server_date date default NULL,
referer_type int(10) unsigned default NULL, referer_type int(10) unsigned default NULL,
referer_name varchar(70) default NULL, referer_name varchar(70) default NULL,
......
...@@ -33,14 +33,6 @@ class Piwik_Tracker ...@@ -33,14 +33,6 @@ class Piwik_Tracker
const STATE_EMPTY_REQUEST = 11; const STATE_EMPTY_REQUEST = 11;
const STATE_NOSCRIPT_REQUEST = 13; const STATE_NOSCRIPT_REQUEST = 13;
const COOKIE_INDEX_IDVISITOR = 1;
const COOKIE_INDEX_REFERER_ID_VISIT = 6;
const COOKIE_INDEX_REFERER_TIMESTAMP = 7;
const COOKIE_INDEX_REFERER_TYPE = 8;
const COOKIE_INDEX_REFERER_NAME = 9;
const COOKIE_INDEX_REFERER_KEYWORD = 10;
const COOKIE_INDEX_VISITOR_RETURNING = 11;
// We use hex ID that are 16 chars in length, ie. 64 bits IDs // We use hex ID that are 16 chars in length, ie. 64 bits IDs
const LENGTH_HEX_ID_STRING = 16; const LENGTH_HEX_ID_STRING = 16;
const LENGTH_BINARY_ID = 8; const LENGTH_BINARY_ID = 8;
......
...@@ -16,21 +16,12 @@ ...@@ -16,21 +16,12 @@
*/ */
class Piwik_Tracker_GoalManager class Piwik_Tracker_GoalManager
{ {
/**
* @var Piwik_Cookie
*/
protected $cookie = null;
/** /**
* @var Piwik_Tracker_Action * @var Piwik_Tracker_Action
*/ */
protected $action = null; protected $action = null;
protected $convertedGoals = array(); protected $convertedGoals = array();
function setCookie($cookie)
{
$this->cookie = $cookie;
}
static public function getGoalDefinitions( $idSite ) static public function getGoalDefinitions( $idSite )
{ {
$websiteAttributes = Piwik_Common::getCacheWebsiteAttributes( $idSite ); $websiteAttributes = Piwik_Common::getCacheWebsiteAttributes( $idSite );
...@@ -181,29 +172,28 @@ class Piwik_Tracker_GoalManager ...@@ -181,29 +172,28 @@ class Piwik_Tracker_GoalManager
'server_time' => Piwik_Tracker::getDatetimeFromTimestamp($visitorInformation['visit_last_action_time']), 'server_time' => Piwik_Tracker::getDatetimeFromTimestamp($visitorInformation['visit_last_action_time']),
'location_country' => $location_country, 'location_country' => $location_country,
'location_continent'=> $location_continent, 'location_continent'=> $location_continent,
'visitor_returning' => $this->cookie->get( Piwik_Tracker::COOKIE_INDEX_VISITOR_RETURNING ), 'visitor_returning' => $visitorInformation['visitor_returning'],
); );
$referer_idvisit = $this->cookie->get( Piwik_Tracker::COOKIE_INDEX_REFERER_ID_VISIT ); $refererTimestamp = Piwik_Common::getRequestVar('_refts', 0, 'int', $action->getRequest());
if($referer_idvisit !== false) $refererUrl = Piwik_Common::getRequestVar('_ref', '', 'string', $action->getRequest());
$referrer = new Piwik_Tracker_Visit_Referer();
$referrer = $referrer->getRefererInformation($refererUrl, $currentUrl = '', $idSite);
$goalData = array(
'referer_visit_server_date' => date("Y-m-d", $refererTimestamp),
'referer_type' => $referrer['referer_type'],
'referer_name' => $referrer['referer_name'],
'referer_keyword' => $referrer['referer_keyword'],
);
// Basic health check on the referer data
if($goalData['referer_type'] > 0
&& strlen($goalData['referer_name']) > 1
// Cookie only lasts 6 months by default, so we shouldn't see anything older than 1 year
&& $refererTimestamp > Piwik_Tracker::getCurrentTimestamp() - 365 * 86400 * 2
&& $refererTimestamp <= Piwik_Tracker::getCurrentTimestamp())
{ {
$refererTimestamp = (int)$this->cookie->get( Piwik_Tracker::COOKIE_INDEX_REFERER_TIMESTAMP ); $goal += $goalData;
$goalData = array(
'referer_idvisit' => (int)$referer_idvisit,
'referer_visit_server_date' => date("Y-m-d", $refererTimestamp),
'referer_type' => htmlspecialchars_decode($this->cookie->get( Piwik_Tracker::COOKIE_INDEX_REFERER_TYPE )),
'referer_name' => htmlspecialchars_decode($this->cookie->get( Piwik_Tracker::COOKIE_INDEX_REFERER_NAME )),
'referer_keyword' => htmlspecialchars_decode($this->cookie->get( Piwik_Tracker::COOKIE_INDEX_REFERER_KEYWORD )),
);
// Basic health check on the referer data
if($goalData['referer_idvisit'] > 0
&& $goalData['referer_type'] > 0
&& strlen($goalData['referer_name']) > 1
&& $refererTimestamp > Piwik_Tracker::getCurrentTimestamp() - 365.25 * 86400 * 2)
{
$goal += $goalData;
}
} }
$goal += $visitCustomVariables; $goal += $visitCustomVariables;
......
...@@ -45,14 +45,6 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -45,14 +45,6 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
protected $visitorKnown; protected $visitorKnown;
protected $request; protected $request;
// @see detect*() referer methods
protected $typeRefererAnalyzed;
protected $nameRefererAnalyzed;
protected $keywordRefererAnalyzed;
protected $refererHost;
protected $refererUrl;
protected $refererUrlParse;
protected $currentUrlParse;
// can be overwritten in constructor // can be overwritten in constructor
protected $timestamp; protected $timestamp;
...@@ -84,8 +76,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -84,8 +76,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
Piwik_PostEvent('Tracker.setRequest.idSite', $idsite); Piwik_PostEvent('Tracker.setRequest.idSite', $idsite);
if($idsite <= 0) if($idsite <= 0)
{ {
$idsite = Piwik_Common::getRequestVar('idsite', '', 'string', $this->request); Piwik_Tracker_ExitWithException(new Exception('Invalid idSite'));
Piwik_Tracker_ExitWithException(new Exception('Invalid idsite: '.$idsite));
} }
$this->idsite = $idsite; $this->idsite = $idsite;
...@@ -224,12 +215,11 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -224,12 +215,11 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
} }
// update the cookie with the new visit information // update the cookie with the new visit information
$this->updateCookie(); $this->setThirdPartyCookie();
// record the goals if applicable // record the goals if applicable
if($someGoalsConverted) if($someGoalsConverted)
{ {
$goalManager->setCookie($this->cookie);
$goalManager->recordGoals( $this->idsite, $this->visitorInfo, $this->visitorCustomVariables, $action); $goalManager->recordGoals( $this->idsite, $this->visitorInfo, $this->visitorCustomVariables, $action);
} }
unset($goalManager); unset($goalManager);
...@@ -394,7 +384,6 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -394,7 +384,6 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
$serverTimestamp = $this->getCurrentTimestamp(); $serverTimestamp = $this->getCurrentTimestamp();
$idcookie = $this->getVisitorIdcookie(); $idcookie = $this->getVisitorIdcookie();
$returningVisitor = $this->isVisitorKnown() ? 1 : 0;
$defaultTimeOnePageVisit = Piwik_Tracker_Config::getInstance()->Tracker['default_time_one_page_visit']; $defaultTimeOnePageVisit = Piwik_Tracker_Config::getInstance()->Tracker['default_time_one_page_visit'];
...@@ -402,7 +391,11 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -402,7 +391,11 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
$country = Piwik_Common::getCountry($userInfo['location_browser_lang'], $country = Piwik_Common::getCountry($userInfo['location_browser_lang'],
$enableLanguageToCountryGuess = Piwik_Tracker_Config::getInstance()->Tracker['enable_language_to_country_guess'], $enableLanguageToCountryGuess = Piwik_Tracker_Config::getInstance()->Tracker['enable_language_to_country_guess'],
$this->getVisitorIp()); $this->getVisitorIp());
$refererInfo = $this->getRefererInformation();
$referrer = new Piwik_Tracker_Visit_Referer();
$refererUrl = Piwik_Common::getRequestVar( 'urlref', '', 'string', $this->request);
$currentUrl = Piwik_Common::getRequestVar( 'url', '', 'string', $this->request);
$refererInfo = $referrer->getRefererInformation($refererUrl, $currentUrl, $this->idsite);
/** /**
* Save the visitor * Save the visitor
...@@ -411,7 +404,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -411,7 +404,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
'idsite' => $this->idsite, 'idsite' => $this->idsite,
'visitor_localtime' => $localTime, 'visitor_localtime' => $localTime,
'idvisitor' => $idcookie, 'idvisitor' => $idcookie,
'visitor_returning' => $returningVisitor, 'visitor_returning' => $this->isVisitorKnown() ? 1 : 0,
'visit_first_action_time' => Piwik_Tracker::getDatetimeFromTimestamp($serverTimestamp), 'visit_first_action_time' => Piwik_Tracker::getDatetimeFromTimestamp($serverTimestamp),
'visit_last_action_time' => Piwik_Tracker::getDatetimeFromTimestamp($serverTimestamp), 'visit_last_action_time' => Piwik_Tracker::getDatetimeFromTimestamp($serverTimestamp),
'visit_entry_idaction_url' => $idActionUrl, 'visit_entry_idaction_url' => $idActionUrl,
...@@ -491,9 +484,9 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -491,9 +484,9 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
} }
/** /**
* Returns vistor cookie * Returns visitor cookie
* *
* @return string * @return binary
*/ */
protected function getVisitorIdcookie() protected function getVisitorIdcookie()
{ {
...@@ -691,6 +684,11 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -691,6 +684,11 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
{ {
return Piwik_Tracker_Config::getInstance()->Tracker['cookie_path']; return Piwik_Tracker_Config::getInstance()->Tracker['cookie_path'];
} }
protected function shouldUseThirdPartyCookie()
{
return (bool)Piwik_Tracker_Config::getInstance()->Tracker['use_third_party_cookies'];
}
/** /**
* This methods tries to see if the visitor has visited the website before. * This methods tries to see if the visitor has visited the website before.
...@@ -727,17 +725,34 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -727,17 +725,34 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
$this->setCookie( new Piwik_Cookie( $this->setCookie( new Piwik_Cookie(
$this->getCookieName(), $this->getCookieName(),
$this->getCookieExpire(), $this->getCookieExpire(),
$this->getCookiePath(), $this->getCookiePath()) );
$key = $this->idsite ) );
$this->printCookie(); $this->printCookie();
// Does the idvisitor cookie contain a 16b string? // Read ID Visitor
if( false !== ($idVisitor = $this->cookie->get( Piwik_Tracker::COOKIE_INDEX_IDVISITOR )) $found = false;
&& strlen($idVisitor) == Piwik_Tracker::LENGTH_HEX_ID_STRING) // - If set to use 3rd party cookies for Visit ID, read the cookies
// - By default, reads the first party cookie ID
$useThirdPartyCookie = $this->shouldUseThirdPartyCookie();
if($useThirdPartyCookie)
{
$idVisitor = $this->cookie->get(0);
if($idVisitor !== false
&& strlen($idVisitor) == Piwik_Tracker::LENGTH_HEX_ID_STRING)
{
$found = true;
}
}
else
{
$idVisitor = Piwik_Common::getRequestVar('_id', '', 'string', $this->request);
$found = strlen($idVisitor) >= Piwik_Tracker::LENGTH_HEX_ID_STRING;
}
// Does the cookie contain a Visitor ID?
if( $found )
{ {
$this->visitorInfo['idvisitor'] = Piwik_Common::hex2bin($idVisitor); $this->visitorInfo['idvisitor'] = Piwik_Common::hex2bin($idVisitor);
$this->visitorKnown = true;
printDebug("The visitor has the piwik cookie (idvisitor = ".$idVisitor.") "); printDebug("The visitor has the piwik cookie (idvisitor = ".$idVisitor.") ");
} }
else else
...@@ -769,10 +784,10 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -769,10 +784,10 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
visit_first_action_time, visit_first_action_time,
idvisit, idvisit,
visit_exit_idaction_url, visit_exit_idaction_url,
visit_exit_idaction_name visit_exit_idaction_name,
visitor_returning
FROM ".Piwik_Common::prefixTable('log_visit'). FROM ".Piwik_Common::prefixTable('log_visit').
" WHERE " WHERE ".$where."
".$where."
ORDER BY visit_last_action_time DESC ORDER BY visit_last_action_time DESC
LIMIT 1"; LIMIT 1";
$visitRow = Piwik_Tracker::getDatabase()->fetch($sql, $bindSql); $visitRow = Piwik_Tracker::getDatabase()->fetch($sql, $bindSql);
...@@ -781,12 +796,13 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -781,12 +796,13 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
&& $visitRow && $visitRow
&& count($visitRow) > 0) && count($visitRow) > 0)
{ {
$this->visitorInfo['idvisitor'] = $visitRow['idvisitor'];
$this->visitorInfo['visit_last_action_time'] = strtotime($visitRow['visit_last_action_time']); $this->visitorInfo['visit_last_action_time'] = strtotime($visitRow['visit_last_action_time']);
$this->visitorInfo['visit_first_action_time'] = strtotime($visitRow['visit_first_action_time']); $this->visitorInfo['visit_first_action_time'] = strtotime($visitRow['visit_first_action_time']);
$this->visitorInfo['idvisitor'] = $visitRow['idvisitor'];
$this->visitorInfo['idvisit'] = $visitRow['idvisit']; $this->visitorInfo['idvisit'] = $visitRow['idvisit'];
$this->visitorInfo['visit_exit_idaction_url'] = $visitRow['visit_exit_idaction_url']; $this->visitorInfo['visit_exit_idaction_url'] = $visitRow['visit_exit_idaction_url'];
$this->visitorInfo['visit_exit_idaction_name'] = $visitRow['visit_exit_idaction_name']; $this->visitorInfo['visit_exit_idaction_name'] = $visitRow['visit_exit_idaction_name'];
$this->visitorInfo['visitor_returning'] = $visitRow['visitor_returning'];
$this->visitorKnown = true; $this->visitorKnown = true;
...@@ -799,6 +815,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -799,6 +815,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
else else
{ {
printDebug("The visitor was not matched with an existing visitor..."); printDebug("The visitor was not matched with an existing visitor...");
$this->visitorKnown = false;
} }
} }
...@@ -948,38 +965,16 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -948,38 +965,16 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
/** /**
* Update the cookie information. * Update the cookie information.
*/ */
protected function updateCookie() protected function setThirdPartyCookie()
{ {
printDebug("We manage the cookie..."); if(!$this->shouldUseThirdPartyCookie())
// If new visit && not direct entry
if( isset($this->visitorInfo['referer_type'])
&& $this->visitorInfo['referer_type'] != Piwik_Common::REFERER_TYPE_DIRECT_ENTRY)
{ {
// if the setting is set to use only the first referer, return;
// we don't update the cookie referer values if they are already set
if( !Piwik_Tracker_Config::getInstance()->Tracker['use_first_referer_to_determine_goal_referer']
|| $this->cookie->get( Piwik_Tracker::COOKIE_INDEX_REFERER_TYPE ) == false)
{
$this->cookie->set( Piwik_Tracker::COOKIE_INDEX_REFERER_TYPE, $this->visitorInfo['referer_type']);
$this->cookie->set( Piwik_Tracker::COOKIE_INDEX_REFERER_NAME, $this->visitorInfo['referer_name']);
$this->cookie->set( Piwik_Tracker::COOKIE_INDEX_REFERER_KEYWORD, $this->visitorInfo['referer_keyword']);
$this->cookie->set( Piwik_Tracker::COOKIE_INDEX_REFERER_ID_VISIT, $this->visitorInfo['idvisit']);
$this->cookie->set( Piwik_Tracker::COOKIE_INDEX_REFERER_TIMESTAMP, $this->getCurrentTimestamp());
}
} }
printDebug("We manage the cookie...");
// for a new visit, we flag the visit with visitor_returning
if(isset($this->visitorInfo['visitor_returning']))
{
$this->cookie->set( Piwik_Tracker::COOKIE_INDEX_VISITOR_RETURNING,
$this->visitorInfo['visitor_returning'] );
}
// idcookie has been generated in handleNewVisit or we simply propagate the old value
$this->cookie->set( Piwik_Tracker::COOKIE_INDEX_IDVISITOR,
bin2hex($this->visitorInfo['idvisitor']) );
// idcookie has been generated in handleNewVisit or we simply propagate the old value
$this->cookie->set(0, bin2hex($this->visitorInfo['idvisitor']) );
$this->cookie->save(); $this->cookie->save();
} }
...@@ -1005,6 +1000,67 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -1005,6 +1000,67 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
return $action; return $action;
} }
/**
* @param $action
* @return bool true if the outlink the visitor clicked on points to one of the known hosts for this website
*/
protected function detectActionIsOutlinkOnAliasHost(Piwik_Tracker_Action_Interface $action)
{
if($action->getActionType() != Piwik_Tracker_Action_Interface::TYPE_OUTLINK)
{
return false;
}
$actionUrl = $action->getActionUrl();
$actionUrlParsed = @parse_url(Piwik_Common::unsanitizeInputValue($actionUrl));
if(!isset($actionUrlParsed['host']))
{
return false;
}
return $this->isHostKnownAliasHost($actionUrlParsed['host']);
}
/**
* Returns a 64-bit hash of all the configuration settings
* @return string
*/
protected function getConfigHash( $os, $browserName, $browserVersion, $resolution, $plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $ip, $browserLang)
{
$hash = md5( $os . $browserName . $browserVersion . $plugin_Flash . $plugin_Java . $plugin_Director . $plugin_Quicktime . $plugin_RealPlayer . $plugin_PDF . $plugin_WindowsMedia . $plugin_Gears . $plugin_Silverlight . $plugin_Cookie . $ip . $browserLang, $raw_output = true );
return substr( $hash, 0, Piwik_Tracker::LENGTH_BINARY_ID);
}
/**
* Returns either
* - "-1" for a known visitor
* - at least 16 char identifier in hex @see Piwik_Common::generateUniqId()
*/
protected function getVisitorUniqueId()
{
if($this->isVisitorKnown())
{
return -1;
}
return Piwik_Common::generateUniqId();
}
protected function setCookie( $cookie )
{
$this->cookie = $cookie;
}
}
class Piwik_Tracker_Visit_Referer
{
// @see detect*() referer methods
protected $typeRefererAnalyzed;
protected $nameRefererAnalyzed;
protected $keywordRefererAnalyzed;
protected $refererHost;
protected $refererUrl;
protected $refererUrlParse;
protected $currentUrlParse;
/** /**
* Returns an array containing the following information: * Returns an array containing the following information:
* - referer_type * - referer_type
...@@ -1029,23 +1085,21 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -1029,23 +1085,21 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
* *
* - referer_url : the same for all the referer types * - referer_url : the same for all the referer types
* *
* @param URLs must be URL Encoded
*/ */
public function getRefererInformation() public function getRefererInformation($refererUrl, $currentUrl, $idSite)
{ {
$this->idsite = $idSite;
// default values for the referer_* fields // default values for the referer_* fields
$this->refererUrl = Piwik_Common::unsanitizeInputValue($refererUrl);
$this->refererUrlParse = @parse_url($this->refererUrl);
$this->currentUrlParse = @parse_url(Piwik_Common::unsanitizeInputValue($currentUrl));
$this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_DIRECT_ENTRY; $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_DIRECT_ENTRY;
$this->nameRefererAnalyzed = ''; $this->nameRefererAnalyzed = '';
$this->keywordRefererAnalyzed = ''; $this->keywordRefererAnalyzed = '';
$this->refererHost = ''; $this->refererHost = '';
// get the urls and parse them
$refererUrl = Piwik_Common::getRequestVar( 'urlref', '', 'string', $this->request);
$currentUrl = Piwik_Common::getRequestVar( 'url', '', 'string', $this->request);
$this->refererUrl = $refererUrl;
$this->refererUrlParse = @parse_url(Piwik_Common::unsanitizeInputValue($refererUrl));
$this->currentUrlParse = @parse_url(Piwik_Common::unsanitizeInputValue($currentUrl));
if(isset($this->refererUrlParse['host'])) if(isset($this->refererUrlParse['host']))
{ {
$this->refererHost = $this->refererUrlParse['host']; $this->refererHost = $this->refererUrlParse['host'];
...@@ -1090,9 +1144,8 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -1090,9 +1144,8 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
*/ */
protected function detectRefererSearchEngine() protected function detectRefererSearchEngine()
{ {
$rawRefererUrl = Piwik_Common::unsanitizeInputValue($this->refererUrl); $searchEngineInformation = Piwik_Common::extractSearchEngineInformationFromUrl($this->refererUrl);
$searchEngineInformation = Piwik_Common::extractSearchEngineInformationFromUrl($rawRefererUrl); Piwik_PostEvent('Tracker.detectRefererSearchEngine', $searchEngineInformation, $this->refererUrl);
Piwik_PostEvent('Tracker.detectRefererSearchEngine', $searchEngineInformation, $rawRefererUrl);
if($searchEngineInformation === false) if($searchEngineInformation === false)
{ {
return false; return false;
...@@ -1161,26 +1214,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -1161,26 +1214,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
} }
return false; return false;
} }
/**
* @param $action
* @return bool true if the outlink the visitor clicked on points to one of the known hosts for this website
*/
protected function detectActionIsOutlinkOnAliasHost(Piwik_Tracker_Action_Interface $action)
{
if($action->getActionType() != Piwik_Tracker_Action_Interface::TYPE_OUTLINK)
{
return false;
}
$actionUrl = $action->getActionUrl();
$actionUrlParsed = @parse_url(Piwik_Common::unsanitizeInputValue($actionUrl));
if(!isset($actionUrlParsed['host']))
{
return false;
}
return $this->isHostKnownAliasHost($actionUrlParsed['host']);
}
// is the referer host any of the registered URLs for this website? // is the referer host any of the registered URLs for this website?
protected function isHostKnownAliasHost($urlHost) protected function isHostKnownAliasHost($urlHost)
{ {
...@@ -1199,38 +1233,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface ...@@ -1199,38 +1233,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
} }
return false; return false;
} }
/**
* Returns a 64-bit hash of all the configuration settings
* @return string
*/
protected function getConfigHash( $os, $browserName, $browserVersion, $resolution, $plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $ip, $browserLang)
{
$hash = md5( $os . $browserName . $browserVersion . $plugin_Flash . $plugin_Java . $plugin_Director . $plugin_Quicktime . $plugin_RealPlayer . $plugin_PDF . $plugin_WindowsMedia . $plugin_Gears . $plugin_Silverlight . $plugin_Cookie . $ip . $browserLang, $raw_output = true );
return substr( $hash, 0, Piwik_Tracker::LENGTH_BINARY_ID);
}
/**
* Returns either
* - "-1" for a known visitor
* - a unique 32 char identifier @see Piwik_Common::generateUniqId()
*/
protected function getVisitorUniqueId()
{
if($this->isVisitorKnown())
{
return -1;
}
else
{
return Piwik_Common::generateUniqId();
}
}
protected function setCookie( $cookie )
{
$this->cookie = $cookie;
}
} }
/** /**
......
...@@ -50,6 +50,7 @@ class Piwik_Updates_1_2 extends Piwik_Updates ...@@ -50,6 +50,7 @@ class Piwik_Updates_1_2 extends Piwik_Updates
' => false, ' => false,
'ALTER TABLE `'. Piwik_Common::prefixTable('log_conversion') .'` 'ALTER TABLE `'. Piwik_Common::prefixTable('log_conversion') .'`
DROP `referer_idvisit`,
ADD `idvisitor` BINARY(8) NOT NULL AFTER `idsite`, ADD `idvisitor` BINARY(8) NOT NULL AFTER `idsite`,
ADD custom_var_k1 VARCHAR(50) DEFAULT NULL, ADD custom_var_k1 VARCHAR(50) DEFAULT NULL,
ADD custom_var_v1 VARCHAR(50) DEFAULT NULL, ADD custom_var_v1 VARCHAR(50) DEFAULT NULL,
......
...@@ -1253,8 +1253,11 @@ var ...@@ -1253,8 +1253,11 @@ var
'&_ref=' + encodeWrapper(purify(referralUrl)) + '&_ref=' + encodeWrapper(purify(referralUrl)) +
'&_refts=' + referralTs + '&_refts=' + referralTs +
'&_viewts=' + lastVisitTs + '&_viewts=' + lastVisitTs +
'&_cvar=' + customVariablesString +
request; request;
if(customVariablesString.length > 5) {
request +='&_cvar=' + customVariablesString;
}
// Don't save in the cookie, the deleted custom variables // Don't save in the cookie, the deleted custom variables
for(cvarId in customVariables) { for(cvarId in customVariables) {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter