Improving Apple Device Detection Accuracy

Richard Uren

3/29/2017 12:00 AM

Handset Detection Archive
This blog originally appeared on and may not relate directly to 51Degrees.

Apple’s devices have always presented a challenge for web analytics companies as all their devices, for each device family, use the same HTTP headers or User-Agent. This makes differentiating between different iPhone models impossible using web requests alone.

Example iPhone User-Agent Headers

Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B329 Safari/8536.25 Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D201 Safari/9537.53

Apple User-Agent headers contain no device model information.

Example Android User-Agent Headers

Mozilla/5.0 (Linux; Android 5.1.1; SAMSUNG SM-N910C Build/LMY47X) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/2.1 Chrome/34.0.1847.76 Mobile Safari/537.36 Mozilla/5.0 (Linux; Android 7.1.1; Pixel XL Build/NMF26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.91 Mobile Safari/537.36

Android User-Agent headers contain device model information.

To address this challenge, back in 2012, we introduced a small javascript snippet which builds a device fingerprint that can assist in detecting the device. The snippet takes the device screen size, the display pixel ratio and combines that with a micro benchmark to produce a what we call a fingerprint.

Fingerprints look like this ‘320:480:100:110’. There’s no personally identifying information in there, just a few attributes about the hardware of the device that helps our detection engine hone in on the correct device.

Today we’re tweaking that snippet to reduce the variablilty of the benchmark, plus we’re providing a new URL Express customers can use to improve accuracy even further.

The previous version of the script made up to 20 1ms benchmark runs and averaged the results. This produced a wide range of numbers which we reasoned would be close to consistent when averaged out, however recent testing has proven that we gain a more consistent result if instead of averageing we simply take the highest result.

Customers using v4 Express detection (javascript) have no changes to make as the scripts have been updated for this already. Customers using Cloud or Ultimate detection can grab an updated script from the new GitHub repo we’ve just spun up at JS Helper.

Technical Discussion

As mentioned previously, the fingerprinting benchmark takes up to 20 x 1ms benchmarks over 50ms. We chose 50ms as we felt it was a resonable tradeoff between stressing the device and getting the data we need. However, in some cases, it may be desirable to run the benchmark for longer and collect more test results for a more accurate view of the device’s hardware. It should be noted that performing longer benchmarks does impact user experience, so please use this wisely.

The new express detection script can be called with this URL // where SiteID is the ID of your website profile and Duration is the duration of the test in milliseconds. In testing we’ve seen excellent results with benchmarks upto 500ms (12 a second).