@anonymous-piwik-user opened this Issue on January 12th 2010

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 commented on January 13th 2010 Contributor

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

@mattab commented on January 14th 2010 Member

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

@mattab commented on January 14th 2010 Member

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

@anonymous-piwik-user commented on February 11th 2010

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 commented on February 15th 2010 Contributor

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

@robocoder commented on February 15th 2010 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 on February 15th 2010
Powered by GitHub Issue Mirror