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

% of user with Cookie can be more than 100% #7437

Closed
mattab opened this issue Mar 16, 2015 · 4 comments
Closed

% of user with Cookie can be more than 100% #7437

mattab opened this issue Mar 16, 2015 · 4 comments
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Milestone

Comments

@mattab
Copy link
Member

mattab commented Mar 16, 2015

The goal of this issue is to fix the bug where the "% visits with Cookie support" sometimes shows more than 100%. this can be seen in the demo here.

cookie 103 percent

@mattab mattab added the Bug For errors / faults / flaws / inconsistencies etc. label Mar 16, 2015
@mattab mattab added this to the Piwik 2.12.0 milestone Mar 16, 2015
@mnapoli mnapoli self-assigned this Mar 17, 2015
@mnapoli
Copy link
Contributor

mnapoli commented Mar 17, 2015

The piwik.js tracker will not detect plugins on IE because "it is not supported".

if (!((new RegExp('MSIE')).test(navigatorAlias.userAgent))) {
    if (navigatorAlias.mimeTypes && navigatorAlias.mimeTypes.length) {
        // ... look in navigator.mimeTypes
    }

    ...

    // other browser features
    browserFeatures.cookie = hasCookies();
}

full code here: https://github.com/piwik/piwik/blob/master/js/piwik.js#L3996-4022

However IE 11 does not report itself as MSIE user agent anymore which means it will go into this branch of code, so it will report for example if the browser supports cookie. I don't think it will report for other plugins yet but it could happen in the future.

Anyway now the problem is that we have IE11 cookies stats recorded. But in the "Plugins" report we do this:

$visitsSum = $visitsSumTotal - $ieVisits;

full code here: https://github.com/piwik/piwik/blob/master/plugins/DevicePlugins/API.php#L77-77

Which means we calculate the percentage over all the visits that are not IE (but IE 11 did report cookie usage). Which leads to a total greater than 100%…

I don't see a perfect way to fix this, here are options:

  • do not ignore IE visits when calculating the percentage: however this leads to % that could be wrong (e.g. 95% support for cookies could actually be 100% in reality)
  • hack to ignore IE < 11 visits: cookies % would be fixed but for other plugins we don't have stats for IE 11 so we still have wrong % for them…
  • even more hacky stuff to ignore IE < 11 visits for cookie % but ignore all IE visits for the rest of the rows: in the future if IE support improves then we will get the same problem again
  • just replace any % > 100 to 100: quick and dirty, destroys the value of the report, but that's a possibility
  • change piwik.js to differentiate between "not supported" and "unknown": that way we can have realistic %

I think the last solution is the best as it would also allow to have realistic % for any other browser that doesn't support getting supported plugins. It would also allow to show 2 percentages: the % for visits that were correctly detected and the % for all the visits (e.g. 80% browsers support Java but it's 50% in total if we include visits where we can't detect the feature). However it requires changing the tracker (and probably other extensive changes), and it wouldn't be backward compatible with data previously recorded…

@mattab @sgiehl do you see any other solution, or do you have a preference with the one I exposed?

@mattab
Copy link
Member Author

mattab commented Mar 17, 2015

Good find... it's a tricky one to decide the best way forward.

for other plugins we don't have stats for IE 11 so we still have wrong % for them…

does the plugin detection start working for IE11 as well as the cookie detection? (it uses different JS code (cookes detected with navigator.cookieEnabled while plugins detected looking at navigator.mimeTypes)

@mnapoli
Copy link
Contributor

mnapoli commented Mar 17, 2015

No I don't think so because on MSDN they still show that navigator.mimeTypes is not supported. However that may change in the future of course. That's also why there is the bullet point 2 and 3 which have slightly different implementation because of that.

Scratch that I didn't look hard enough, mimeTypes is supported in IE11: https://msdn.microsoft.com/en-us/library/ie/dn423948(v=vs.85).aspx It's confusing though because the link to the documentation leads to this: https://msdn.microsoft.com/en-us/library/ie/hh801965(v=vs.85).aspx

mnapoli added a commit that referenced this issue Mar 18, 2015
…lugins

In piwik.js we exclude IE browsers by using the `MSIE` string in the user agent. However IE11 doesn't use that user agent anymore, which means we record plugin usage for IE11, which lead to % > 100%. Now we exclude only IE6, 7, 8, 9, 10.
@mnapoli
Copy link
Contributor

mnapoli commented Mar 18, 2015

Pull request here: #7469

@mnapoli mnapoli closed this as completed Mar 19, 2015
@mattab mattab added the Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical. label Mar 22, 2015
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. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Projects
None yet
Development

No branches or pull requests

2 participants