I’ve seen on MotoGP.com that when I view the site from a mobile device or tablet I get a message saying ‘would you like to see our mobile apps’ message and if I choose ‘no’ that the next time I visit from the same device the message no longer appears. I would really like to introduce such functionality to my site but I’m unsure about a good way to do that, I thought something like this:
- Using PHP lookup device when user visits site (try to detect OS, iOS
or Android for example) - Lookup user’s MAC address
- From a table in the DB containing MAC addresses and a boolean flag, check
if user has visited before and expressed a preference for not seeing
the dialogue box again. - If the MAC address is not in the DB show the message
- If MAC address is in the db with flag set, don’t show message.
Any comments on whether this is a good approach or not? It’s just what I came up with from scratch and searching seemed to yield nothing.
Thanks for any comments.
David
The easy way to do this is as follows:
Detect their device via their User Agent. See How do I check if the useragent is an ipad or iphone? on how to do so (Deceptive question name, this method would work for any device/browser). Also available is a convenience class in PHP.
Set a cookie if the user declines, so that you can check in future as to whether you should show your prompt again. See What is the "best" way to get and set a single cookie value using JavaScript on how to do so in Javascript.
An amalgamation of this and rdurand’s idea would create the best solution for you for all mobile devices. Smart Banners are available to devices running iOS6 and above, and provide a neat and tidy way to inform your users that there is a mobile app available for their platform. If the device runs iOS 5 or below, or isn’t iOS at all, then the above method I’ve described should cover their bases too.