-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Referrers / Invalid count of unique visitors #3517
Comments
Attachment: Patch to fix it |
I made pull request on github with this patch: #13 |
Patch review: Can you please in the patch only submit the code lines that change (and not change the style of other lines or add line breaks) and also, please don't rename the function with ByRef since it's the same thing (it will make patch clearer) why not modify queryVisitsByDimension() instead of duplicating code in getPlainVisitsCursor() ? |
Attachment: |
Attachment: |
Attachment: |
Attachment: |
Attachment: |
Attachment: |
Thank you for reviewing my patch! Ok, I'll try to describe all of it as good as I can =) As I already said, issue begans from incorrect count of unique visitors in reports related with referrer type. I found incorrect data in database table The first patch appends new method with name Piwik_ArchiveProcessing_Day::getPlainVisitsCursor. File with it called as 3517-1.patch By next step, we're can calculate all selected data on php side. It can be done in method The second patch makes some aggregation logic in method Piwik_Referers::archiveDayAggregateVisits. Hi's called as 3517-2.patch Of course we want to get the most better performance of our code as we can. For that I analized a source code of our method, and found that than invokes other method - updateInterestStats by Piwik_ArchiveDayProcessing_Day class. It takes two arguments. First of them is array with new statistic indices, and second is old array with our aggregated data. Count of its invocations can amount to hundreds of thousands. And first argument of it is scalar array, which being fully copied each time when this method is invoked. For avoid this behaviour I wrote new method, called as The third patch appends a new method to Piwik_ArchiveProcessing_Day by name updateInterestStatsByRef. File with it called as 3517-3.patch By the next step we applying our new method to aggregation logic in method Piwik_Referers::archiveDayAggregateVisits. That's 3517-4.patch Finally I want to fix up a code style for all those steps. Along with it I'd give an insignificant performance improvements, as save some values from array in variables, because making a new variable is more fast than redoing many searches in associative arrays by string key. That's 3517-5.patch All steps by one patch in file called as 3517-total.patch Thank you for your time, and sorry for my bad english =) |
Thanks for the patch. unfortunately we cannot apply because it has performance improvements impact. |
Yep. I saw, we're haven't unique visitors in Referrer reports now. Nice resolve of the problem. Thanks. |
Count of unique visitors by Referer plugin don't agree with count of that by Visits plugin.
For example: On one site "Visits Over Time" report has a 28339 visitors and 48697 visits. But in Referrers->Overview tab in "Details by Referrer Type" report we can see that total count of Visits is 48697 (36499 by direct, 6295 by websites, 3099 by search engines and 2804 by campaigns). But total count of Unique visitors is 33684 (22684 by direct entry, 5488 by websites, 11332 by search engines and 7293 as campaigns). That has a difference from Visits plugin by 5345 visitors.
Looked for this bug I finded problem in Referer plugins method Referers::archiveDayAggregateVisits. It uses ArchiveProcessing_Day::queryVisitsByDimension method to find and aggregate visits and visitors. But if visitor has a several visits in one day and with different types of referrers, it calculates him more than one time.
I wrote a patch for fix this behavior. When I tested it, as addition to fix the problem turn out that the method Referers::archiveDayAggregateVisits with my patch works more fast than original version about two times on my laptop (~1.4 sec opposite ~3.1 sec of original execution time).
The text was updated successfully, but these errors were encountered: