iOS devices report their firmware version in their user agent string, not the device version. Therefore, it is difficult to break down iPhones by their corresponding device versions. Take the iPhone 5 user agent string, for example, (running iOS 6.1.3):

"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"

And compare it to an iPhone 4 (also running iOS 6.1.3):

"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"

The only JavaScript-recognizable difference between iPhone devices is currently screen resolution:

  • iPhone 3 and earlier versions: 480 × 320
  • iPhone 4 and iPhone 4S: 960 × 640
  • iPhone 5: 1136 × 640
  • iPhone 6: 1334 × 750
  • iPhone 6 Plus: 1920 × 1080

Because Adobe uses the device's user agent to populate mobile reports, it's currently impossible to obtain screen resolution without additional implementation. To help circumvent the limitation that iOS devices' user agent strings impose, use the following snippet of code. Pass it into a prop or eVar:

if (navigator.userAgent.indexOf('iPhone') > -1)
{s.eVarXX = screen.width + "x" + screen.height;}

This snippet first detects if the device is an iPhone. If it is, the code uses JavaScript to pull the screen resolution. Using this method allows you to at least distinguish between iPhone 5, iPhone 4, and previous generations.

Questo prodotto è concesso in licenza in base alla licenza di Attribuzione-Non commerciale-Condividi allo stesso modo 3.0 Unported di Creative Commons.  I post su Twitter™ e Facebook non sono coperti dai termini di Creative Commons.

Note legali   |   Informativa sulla privacy online