Pageproperty['ismobiledevice'] - can I trust this to detect mobile devices?

As you may know Google has begun (or will shortly) start imposing site penalties on invasive popups triggered on mobile devices.

Can I rely on the Nitroscript {if (pageproperty[‘ismobiledevice’])} variable to accurately prevent code from triggering on mobile devices?

Cheers.
Andy.

Hi Andy,

That variable is only set to true if (1) you’re on the legacy templates; (2) you have NitroMobile enabled; and, (3) the following regex matches your user agent string:

/(Blackberry|MIDP|Mobile|webOS|Nokia|\bHTC|\bLGE-|\bLG-|UP.Browser|SonyEricsson|SAGEM|SamSung|Symbian|iphone)/i

And this regex doesn’t match:

/iPad/

While it generally works fine, I don’t think it’s completely foolproof.

We’d be happy to update it, though. This seems to be the current standard:

Do you have a preference?

Regards,
Donogh

Thanks Donogh.

Perhaps hold off as I’m still debating a switch over to the newer templates but haven’t had the time to tackle this just yet.

Saying that, I’m sure others would find that to be a useful snippet if it were working on those responsive templates. Server side would be my preference for this type of code.

cheers.
Andy.

Hi Andy,

It would definitely be generally useful.

I’ll add an item to our backlog to cover a new NitroScript variable that takes that updated RegEx into account. We’ll also ensure the built-in mailing list popup feature doesn’t trigger if it’s true.

Thanks for the feedback.

Regards,
Donogh

Hi @andy

Please be advised that we have made the necessary adjustments in the code.

Here is a summary of those changes:

  • The pop up window will no longer appear on mobile devices;
  • We have updated the regex to improve the mobile device detection and is now based on the one provided by http://detectmobilebrowsers.com/
  • There is a new variable accessible from NitroScript called {pageproperty[‘useragentismobile’]} which is a flag indicating whether the user agent (the customer’s browser) is a mobile device.

All those changes are available on branches Beta, Alpha, and Early Adopters.

Hope this helps.

Kindest regards,
Franclin

Thanks very much Franclin.