Hey guys, I’m working on a custom report (which involves going straight to the DB), and I’m trying to figure out some potential inconsistencies with the way piwik is logging data. I have the following four rows of data from log_visit from the same visitor:
Basically, it’s the same user, but visitor_returning is only marked as “1” for the second visit, and not for the 3rd and 4th visit. I would also expect the days since first and last visit to be different (for example, instead of 22 for the last row, I’d expect visitor_days_since_last to be 13 - the # of days from 07/18 to 08/01)
So, it seems to be only happening for a relatively small number of users. Just to figure out the behavior I was mentioned above, I ran the following query:
SELECT
visitor_returning,
COUNT(visitor_returning),
AVG(visitor_days_since_last)
FROM
log_visit
WHERE
visitor_days_since_last > 0
GROUP BY
visitor_returning
(Notes: we’re only tracking one site, so I didn’t use idsite. log_visit has about ~12.5 million rows - so, there are a lot of people who don’t come back ).
In this case, I’d expect visitor_days_since_last to always be 0 when visitor_returning = 0, but it doesn’t seem to be the case.
Perhaps I can safely assume that if “visitor_days_since_last” is greater than 0, than they’re a return visitor?
Heya, thanks for all your responses. I hope you can indulge me with one more answer to one more question
To perhaps clean up this minor discrepancy on my end in the Piwik code, I was thinking about a few different solutions.
The first way I was thinking is to modify Piwik_Tracker_Visit’s handleNewVisit method. I’m running 1.8.4, and there’s a bit of code that puts info into the visitorInfo array; notably this line in handleNewVisit() :
… so this will make it so that a visitor is marked as a returning visitor if visitor_days_since_last is greater than 0.
The second approach I thought about was just making a custom plugin that implements the Tracker.newVisitorInformation event hook (and just modify the referenced $notification object). I thought this way might be cleaner, since I try to avoid modifying piwik core code when I can.
Anyway, I guess my question is: am I missing anything here (if there are more areas I’ll need to change), and am I approaching this correctly?