Mobile redirect script: screen width or user agent??
Which method is better??
|
User-Agent.
|
Quote:
|
Quote:
|
I hate mobile redirects. Mine is basically a small computer that is able to make phone calls, it has a genuine 800px wide screen, yet I'm frequently redirected to the bland mobile version.
Anyway, here's what I think: 1) You shouldn't REDIRECT to a different URL. What happens when someone on a mobile shares your URL on social media? Use the same consistent URL and deliver mobile or desktop content dynamically. 2) Offer some way to lock the choice to mobile or desktop, so that people with phones like mine, or who get misdetected as a mobile device, can choose to see the fully featured page. |
I am attaching below a very basic code for how to detect mobile although there are far more possibilities.
Hope it helps? <?php /** Use to loosely detect a mobile browser No warranties or guarantees given. Not recomended for production environments. Loosly Updated from: http://mobiforge.com/developing/stor...-detection-php We recomend to use: http://wurfl.sourceforge.net/ **/ $MOBILE_BROWSER = 0; if (preg_match('/(up.browser|up.link|mmp|symbian|midp|wap|phone|and roid|webos|blackberry|mobile|pocket|kindle|psp|mae mo|palm)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) { $MOBILE_BROWSER++; } if (!$MOBILE_BROWSER && ( (strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or (strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.wml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE']) or isset($_SERVER['HTTP_X_SKYFIRE_PHONE']) or isset($_SERVER['X_DEVICE_USER_AGENT']) or isset($_SERVER['X_ORIGINAL_USER_AGENT']) or isset($_SERVER['X_MOBILE_UA']))) )) { $MOBILE_BROWSER++; } $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4)); $mobile_agents = array( 'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird' ,'blac', 'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno', 'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-', 'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-', 'newt','noki','palm','pana','pant','phil','play',' port','prox','qwap', 'sage','sams','sany','sch-','sec-','send','seri','sgh-','shar','sie-', 'siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-','tosh', 'tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp','wapr', 'webc','winw','winw','xda ','xda-'); if (!$MOBILE_BROWSER && in_array($mobile_ua,$mobile_agents)) { $MOBILE_BROWSER++; } if (!$MOBILE_BROWSER && (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'opera mini') > 0) or (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'opera mobi') > 0) or (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'windows ce') > 0) or (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'novarra') > 0) ) { $MOBILE_BROWSER++; } //Some custom code to deal with result $REGULAR_URL = 'http://www.reporo.com'; $MOBILE_URL = 'http://m.reporo.com'; header('Location: ' . ($MOBILE_BROWSER?$MOBILE_URL:$REGULAR_URL)); |
As an extra footnote to this post, I believe a combination of screen width and device is probably better.
Those in the know (most by now after so many posts to do with it ha!) will understand the background for mobile and that the key to success is all about billing - that is to say that the person trying to convert the user has better chance if the phone number of the user agent is available to the affiliate program or advertiser at request time. Clearly the newer devices all have wifi and so if the user connects via this method, the phone number is not availlable meaning a lower conversion method is required such as CC biling. The older devices all connect via 3G and so the numebr is always available. so there forwe those devices are often defined as smart or dumb by either one of two methods 1. screen width 2. phone capabilities (such as wifi connection or ability to play MP4's etc) So whilst dumb phones might only make up 5-10% of the volume they could perhaps contribute 20%+ of the revenue. (Remember that high growth countries like latin america only have approx 25% smartphone penetration) Knowing which device does what and its screen width will allow you to use WURFL effectively and then build a few versions of your site that will render on all devices maximising your potential to make money from all your traffic, not just a portion of it. Cheers Ben |
This goes in your root's htaccess.
Code:
RewriteEngine On PHP and Java redirects can hurt your rankings on search engines. EDIT: You can also use Tera-WURFL. The WURFL Database API is a PHP & MySQL/MSSQL/MongoDB based library by ScientiaMobile that uses the Wireless Universal Resource File (WURFL) to detect the capabilities of mobile devices. |
All times are GMT -7. The time now is 05:29 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc