• About Us
  • Blog
  • Basket
  • Account
  • Sign In


Published on Sunday, October 14, 2012

51Degrees.mobi properties in client side script

To get 51Degrees.mobi properties client side by generating dynamic JavaScript from the server using 51Degrees.mobi device detection capability, simply follow the steps of this blog.

Overall the results will be similar to Modernizr, but more efficient as some of the browser's features will have already been detected previously by RingMark, meaning there is a lot less for the device to do. Further, the resulting object will contain properties not possible to detect via the browser such as the physical screen size, the hardware make and model.

The JavaScript will create an object called feature, which exposes the available properties. A full list of properties is available on our Properties Dictionary page. This guide shows usage with our full Premium dataset in use on the server. If Lite data is being used less properties will be available and Premium properties will return undefined in JavaScript.

Step 1: You’ll need to download the 51Degrees.mobi Device Detection API. The latest version can be found here. Although this blog is using the PHP API, the same result is possible with any of our APIs, including Java, .NET and C code.

Step 2: Follow the online installation instructions, available here.

Step 3: In your project, ensure you include:




Replace MyFolder/Test/ with you file path to 51Degrees.mobi.php

Step 4:  The PHP code generates JavaScript, therefore the PHP code is within the script tags. $_51d contains information about the connecting device. 

<div id="output"></div>
var feature = new Array();

$invalidChars = array("-", "/"); //Define any invalid charaters
foreach($_51d as $key => $value)

	//if $invalidChars found within the $key string replace with nothing
	$replacestr = str_replace($invalidChars, "", $key);
	if(is_array($value))//Lists are stored as arrays, checking for this
		$finalValue = implode("|", $value); //'glue' properties together and seperate by a "|"
		$finalValue = $value;
	echo "feature.$replacestr = '$finalValue';\n"; //print $finalValue as array followed by a new line


document.getElementById("output").innerHTML = feature.HardwareVendor;// anything you want to display as HTML insert here

Step 5: 51Degrees.mobi has a large catalogue of device properties available for both Lite and Premium users. See the complete list of available device properties here.

To change the property displayed in the browser, simply change feature.HardwareVendor, in the above code, to the name of the property you wish to display. ie To display the ScreenInchesDiagonal of the device the code will look like the following:

document.getElementById("output").innerHTML = feature.HardwareVendor;// anything you want to display as HTML insert here


You will now be able to implement 51Degrees.mobi properties in client side script. Below is a snapshort section of the output result. In this case, the 'Samsung Nexus S' is the device detected. 

var feature = new Array();

feature.BitsPerPixel = '16';

feature.HardwareModel = 'Nexus S';

feature.HardwareName = 'GT-I9020T|GT-I9023';

feature.HardwareVendor = 'Samsung';

feature.Has3DCamera = 'False';

feature.Has3DScreen = 'False';

As you can see, the feature array is filled with 51Degrees.mobi properties. These can then be incorporated into your page logic and display.

Comments (0)
Piran Watson

Data Team

Other posts by Data Team
Contact author



.NET 4G 51Degrees 5G Acer Adform Adtech Advertising Afilias Alcatel Amazon AMP Analysis Analytics Android Apache API Apple Asian Market ASP.NET Asus Blackberry Browser C C# Centro Chrome chromium Client hints Cloud CMS CPU CSS3 Data Data Blog Data File Daydream Design Detection Developers Device Device Data Device Detection Device Intelligence Device Models Device property DeviceAtlas Disney dmexco DotNetNuke Download ebay Ericsson Event Facebook Firefox Foundation Framework Galaxy git repositories Google Google Analytics Google Daydream GPU GSMA Guess HAProxy Hash Trie HTC HTML5 HTTP HTTP Headers Huawei Infinix Ingeniux Internet usage iOS iOS 13 ipad iPadOS iPhone iPhone 11 Java Javascript Kentico LG Liferay LTE m.dot Memory Memory leak Meta Data Microsoft Mobile Mobile Analysis Mobile Analytics Mobile Devices Mobile Marketing Mixer Motorola Mozilla MWC MWC 2017 MWC16 Native Apps NET New Release News Nexus NFC NGINX Nokia OnePlus 5 Opera Operating System Oppo Optimisation OS Patent Performance PHP Press Release Price Band programmatic Publishers Python Redirection Research Responsive Images Responsive web design RESS Review RTB RWD Safari Samsung Scala ScientiaMobile SEO Server Server-side optimisation Seznam.cz Sitecore Smart TV Smartphone Smartwatches Sony Swedish Beers Tablet Tencent Testing Tips Tutorial Umbraco Update User Agent User-Agent Valgrind Varnish Varnish Cache Video Vodafone VoLTE Web Web Apps Web content management Webtrekk White Paper Widgets WiFi Windows WURFL Xiaomi Xperia ZTE