Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook to individually split Visits #2468

Closed
anonymous-matomo-user opened this issue Jun 2, 2011 · 2 comments
Closed

Hook to individually split Visits #2468

anonymous-matomo-user opened this issue Jun 2, 2011 · 2 comments
Labels
duplicate For issues that already existed in our issue tracker and were reported previously. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.

Comments

@anonymous-matomo-user
Copy link

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;
       }
}

I posted this Suggestion in the Forums at http://forum.piwik.org/read.php?2,77140 and would like to see it being released soon.

@anonymous-matomo-user
Copy link
Author

I guess that is not a feature request. It`s a bug! It is a basic requirement to an analytics tool (in particular campaign tracking) that it works after some basic online marketing rules. With the current implementation of campaign tracking, it make no sense to track campaigns, if you work in professionell online marketing business. Hope this issue will be fixed as soon as possible.

@mattab
Copy link
Member

mattab commented Sep 17, 2011

See the feature request at: #2624 When a campaign changes, creates a new "visit" by default

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate For issues that already existed in our issue tracker and were reported previously. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

No branches or pull requests

2 participants