Unfortunately I did not get any feedback on piwik-hackers. Perhaps no one is using this mailing list anymore, so I’ll try it here, in the forums:
To ensure that “last cookie wins” works similar to analytics and as expected by everyone familiar with online marketing, I would like to track EVERY campaign interaction (not only the first one within a visit). This is why I would like to split a visit whenever there is a visitor coming from a search engine or a campaign.
I suggest changing core/Tracker/Visit.php from:
/**
* Returns true if the last action was done during the last 30 minutes
* @return bool
*/
protected function isLastActionInTheSameVisit()
{
return isset($this->visitorInfo['visit_last_action_time'])
&& ($this->visitorInfo['visit_last_action_time']
> ($this->getCurrentTimestamp() -
Piwik_Tracker_Config::getInstance()->Tracker['visit_standard_length']));
}
To:
/**
* Returns true if the last action belongs to the last Visit.
* This is usually true, when the previous action was done during the last 30 minutes.
* Provides hook for individual splitting of visits.
* @return bool
*/
protected function isLastActionInTheSameVisit()
{
$belongsToLastVisit = isset($this->visitorInfo['visit_last_action_time'])
&& ($this->visitorInfo['visit_last_action_time']
> ($this->getCurrentTimestamp() - Piwik_Tracker_Config::getInstance()->Tracker['visit_standard_length']));
Piwik_PostEvent('Tracker.isLastActionInTheSameVisit', $belongsToLastVisit,
array('visitorInfo' => $this->visitorInfo, 'request' => $this->request, 'idsite' => $this->idsite));
return $belongsToLastVisit;
}
This allows me to decide on my own, whether it is a new visit or not, e.g. somewhere in my Tracker-Plugin:
public function isLastActionInTheSameVisit($notification)
{
$belongsToLastVisit = &$notification->getNotificationObject();
$info = $notification->getNotificationInfo();
$referrer = new Piwik_Tracker_Visit_Referer();
$refererUrl = Piwik_Common::getRequestVar('urlref', '', 'string',
$info['request']);
$currentUrl = Piwik_Common::getRequestVar('url', '', 'string',
$info['request']);
$refererInfo = $referrer->getRefererInformation($refererUrl,
$currentUrl, $info['idsite']);
if(in_array($refererInfo['referer_type'], array(2,6))) # Ignores
direct entries.
{
$belongsToLastVisit = false;
}
}
Is this possible, or is there any other more simple way to for me to reach my goal?
Do you think my suggestion incurres massive performance issues?