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

Tracker: triggering goal shortly after visit starts results in new visit #1108

Closed
anonymous-matomo-user opened this issue Jan 12, 2010 · 6 comments
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc. duplicate For issues that already existed in our issue tracker and were reported previously.
Milestone

Comments

@anonymous-matomo-user
Copy link

Note: Not the same as #1107.

If a webpage tracks a page and then immediately tracks a goal (e.g., is Java present) then the cookie data will not be set when the server is recording the goal, so it won't know that there is a new visit occurring.

One solution is when recognizeTheVisitor is called and action is null (i.e., tracking goal) to force a search of the database if the cookie holds an old visit. Although this hits the database, it should only really be triggered in the bug case since goals generally happen during an already occurring visit.

@robocoder
Copy link
Contributor

I don't believe trackPageView() and trackGoal() were intended to be both be called on the same page.

@mattab
Copy link
Member

mattab commented Jan 14, 2010

trackPageView and trackGoal can be called on the same page - clarkf, if you can submit a patch this would help, thanks!

@mattab
Copy link
Member

mattab commented Jan 14, 2010

quoting vipsoft (PDO doesn't have a getInfo equivalent, so that's not a solution,
assuming this is a problem...)

@anonymous-matomo-user
Copy link
Author

when the trackGoal is called after trackPageView, the update query may not affect any rows, but it can match one row. In the PHP doc:

When using UPDATE, MySQL will not update columns where the new value is the same as the old value. This creates the possibility that mysql_affected_rows() may not actually equal the number of rows matched, only the number of rows that were literally affected by the query.

possible solution:

Mysqli.php, insert new function:

public function rowMatch($queryResult) {
$info = mysqli_info($this->connection);
preg_match('/Rows matched: (\d*)/', $info, $matches);
return (int) $matches[1];
}

Visit.php, change handleKnownVisit function:

if(Piwik_Tracker::getDatabase()->rowMatch($result) == 0)

Hope this helps

@robocoder
Copy link
Contributor

Replying to rastatramp: As previously stated, we won't use mysqli_info() because there's no PDO equivalent.

@robocoder
Copy link
Contributor

Rastatramp's fix (comment:4) should have been posted in #1107. While clarkf reports that this ticket is not the same as #1107, the root cause is the same. I'm marking this as a dupe of #1107, and re-opening that one.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. duplicate For issues that already existed in our issue tracker and were reported previously.
Projects
None yet
Development

No branches or pull requests

3 participants