Ok, so we have confirmed that our calculations were incorrect.
Our provider was giving us reports based on the number of "visits". A visit is calculated based on the amount of time a user spends on our website. However, IE7 users might be rare but they might spend more time on a website compared to a Chrome user. This meant that the percentage we were going by were not based on the percentage of users with a browser, but something like "how much time does a user spend on our site, based on the browser they use".
We finally decided to drop support for IE7. The calculation was simple: The amount of time our team spends to adjust the site for IE7 does not weigh up the amount of revenue we get from the same users. It's worth noting that we won't be going through our code in one go and removing all fixes we have for IE7. Instead we will be doing it over time as part of our daily work. This means that the site will still work for IE7 for a long period of time with only minor glitches. But hopefully by the time the site is unbearable in IE7, the last few percent of users will have upgraded.
The actual solution to the problem:
In order to reduce the number of users in compatibility-mode, we tried using the X-UA-Compatible=edge
flag.
The flag can be set using both a HTML tag and as a request header. We tried both, but that didn't affect our numbers to a noteworthy level. If a site has once ended up in a old browsers compatibility-mode then it stays there until the user actively selects to go to normal browsing. To come around this we decided to do the same thing as Google+ when users are in the same jam: Show a bar at the top of the page for each time the page is loaded. This bar contains a link to information on how to exit Compatibility mode for a website, and the bar will not go away until they do.
To check if a user is surfing in compatibility mode:
var ua = navigator.userAgent.match(/MSIE [0-9]*/);
var version;
if (ua && document.documentMode !== undefined) {
version = parseInt(ua[0].replace(/[^0-9]/g, ""));
if (version !== document.documentMode) {
alert("Compat mode!");
}
}
(solution based on other stackoverflow questions. Amongst others:
this and
this)