PHP Class Piwik\Tracker\Visit

A visit is either NEW or KNOWN. - If a visit is NEW then we process the visitor information (settings, referrers, etc.) and save a new line in the log_visit table. - If a visit is KNOWN then we update the visit row in the log_visit table, updating the number of pages views, time spent, etc. Whether a visit is NEW or KNOWN we also save the action in the DB. One request to the piwik.php script is associated to one action.
Inheritance: implements Piwik\Tracker\VisitInterface
Show file Open project: piwik/piwik Class Usage Examples

Public Properties

Property Type Description
$dimensions

Protected Properties

Property Type Description
$goalManager GoalManager
$request Request
$requestProcessors Piwik\Tracker\RequestProcessor[]
$userSettings Piwik\Tracker\Settings
$visitProperties Piwik\Tracker\Visit\VisitProperties

Public Methods

Method Description
__construct ( )
generateUniqueVisitorId ( ) : string
handle ( ) Main algorithm to handle the visit.
isHostKnownAliasHost ( $urlHost, $idSite ) is the host any of the registered URLs for this website?
setRequest ( Request $request )

Protected Methods

Method Description
getAllVisitDimensions ( )
getSettingsObject ( ) : Piwik\Tracker\Settings Gets the UserSettings object
getTimeSpentReferrerAction ( ) : integer
getVisitorIdcookie ( ) : string Returns visitor cookie
getVisitorIp ( ) : string Returns the visitor's IP address
handleExistingVisit ( $visitIsConverted ) In the case of a known visit, we have to do the following actions:
handleNewVisit ( boolean $visitIsConverted ) In the case of a new visit, we have to do the following actions:
insertNewVisit ( $visit )
updateExistingVisit ( $valuesToUpdate )

Private Methods

Method Description
getExistingVisitFieldsToUpdate ( $visitIsConverted ) : array Gather fields=>values that needs to be updated for the existing visit in log_visit
getModel ( )
getTimezoneForSite ( $idSite )
getVisitStandardLength ( )
makeVisitorFacade ( )
markArchivedReportsAsInvalidIfArchiveAlreadyFinished ( )
printVisitorInformation ( )
setIdVisitorForExistingVisit ( $valuesToUpdate ) : mixed
setNewVisitorInformation ( )
toCanonicalHost ( $host )
triggerHookOnDimensions ( Piwik\Plugin\Dimension\VisitDimension[] $dimensions, string $hook, array | null $valuesToUpdate = null ) : array | null
triggerPredicateHookOnDimensions ( $dimensions, $hook )

Method Details

__construct() public method

public __construct ( )

generateUniqueVisitorId() public static method

public static generateUniqueVisitorId ( ) : string
return string returns random 16 chars hex string

getAllVisitDimensions() protected method

protected getAllVisitDimensions ( )

getSettingsObject() protected method

Gets the UserSettings object
protected getSettingsObject ( ) : Piwik\Tracker\Settings
return Piwik\Tracker\Settings

getTimeSpentReferrerAction() protected method

protected getTimeSpentReferrerAction ( ) : integer
return integer Time in seconds

getVisitorIdcookie() protected method

Returns visitor cookie
protected getVisitorIdcookie ( ) : string
return string binary

getVisitorIp() protected method

Returns the visitor's IP address
protected getVisitorIp ( ) : string
return string

handle() public method

Once we have the visitor information, we have to determine if the visit is a new or a known visit. 1) When the last action was done more than 30min ago, or if the visitor is new, then this is a new visit. 2) If the last action is less than 30min ago, then the same visit is going on. Because the visit goes on, we can get the time spent during the last action. NB: - In the case of a new visit, then the time spent during the last action of the previous visit is unknown. - In the case of a new visit but with a known visitor, we can set the 'returning visitor' flag. In all the cases we set a cookie to the visitor with the new information.
public handle ( )

handleExistingVisit() protected method

1) Insert the new action 2) Update the visit information
protected handleExistingVisit ( $visitIsConverted )
$visitIsConverted

handleNewVisit() protected method

1) Insert the new action 2) Insert the visit information
protected handleNewVisit ( boolean $visitIsConverted )
$visitIsConverted boolean

insertNewVisit() protected method

protected insertNewVisit ( $visit )

isHostKnownAliasHost() public static method

is the host any of the registered URLs for this website?
public static isHostKnownAliasHost ( $urlHost, $idSite )

setRequest() public method

public setRequest ( Request $request )
$request Request

updateExistingVisit() protected method

protected updateExistingVisit ( $valuesToUpdate )
$valuesToUpdate

Property Details

$dimensions public static property

public static $dimensions

$goalManager protected property

protected GoalManager,Piwik\Tracker $goalManager
return GoalManager

$request protected property

protected Request,Piwik\Tracker $request
return Request

$requestProcessors protected property

protected RequestProcessor[],Piwik\Tracker $requestProcessors
return Piwik\Tracker\RequestProcessor[]

$userSettings protected property

protected Settings,Piwik\Tracker $userSettings
return Piwik\Tracker\Settings

$visitProperties protected property

protected VisitProperties,Piwik\Tracker\Visit $visitProperties
return Piwik\Tracker\Visit\VisitProperties