# DeviceAtlas Client Side Component # The DeviceAtlas APIs can work in conjunction with a JavaScript property detection file and merge the resulting properties for use on the server side. The client properties are also available to other JavaScript libraries. The DeviceAtlas client detection file needs to be included on your web page for this to function. ### Client Side Access to Properties ### The properties gathered from the DeviceAtlas JavaScript detection are available to other JavaScript functions and can be accessed on the client side by using the "DeviceAtlas" namespace. **Example:** ```javascript // Does the browser support Web GL ? var supportsWebGl = DeviceAtlas.js.webGl; ``` The normal DeviceAtlas property name should be used to access the client side property. ### Server Side Access to Properties ### The JavaScript detection file creates a special cookie with the detected client properties. The usage is different in the Enterprise and Cloud APIs. *Use with Enterprise APIs* - The contents of the cookie must be passed to the API's getProperty() and getProperties() methods. *Use with Cloud APIs* - If the cookie is available and the API is configured to send the cookie the API will automatically forward the cookie contents to the Cloud service and will be used as part of the detection. The client side properties over-ride any data file properties and also serve as an input into additional logic to determine other properties such iPhone models which are normally not detectable. The cookie containing the properties is called "DAPROPS". ### Basic Server Side Usage ### 1. Include the deviceatlas-X.X.min.js file on your web page. 2. In your web application, pass the contents of the DeviceAtlas cookie to the DeviceAtlas API. NOTE: the cookie contents will only be set after the first request. It is recommended to not rely on the client side properties for the very first page. Please see the Example code bundled with the API for more information. ### Custom Configuration ### To customize a cookie name or other cookie parameters like a domain or a path you can use the code below - just remember that this code must be used before you include deviceatlas-X.X.min.js file. ```javascript var DeviceAtlas = { cookieName: 'DAPROPS', // the cookie name cookieExpiryDays: 1, // the time the cookie expires in days cookieDomain: '.yourdomain.tld', // custom domain cookiePath: '/' // custom path } ``` ### Sending cookie via URL ### In a restricted environment where cookies are not allowed it is possible to get the cookie content using the javascript getPropertiesAsString() method and pass it as a URL parameter. NOTE: When integrating with a web application, the value should be fetched from the URL and passed to the DeviceAtlas API properly. **Example:** ```javascript <script type="text/javascript"> window.onload = function() { var img = document.createElement('img'); img.setAttribute('id', 'ad-banner'); img.setAttribute('src', './ads.php?DAPROPS=' + encodeURIComponent(DeviceAtlas.getPropertiesAsString())); document.body.appendChild(img); } </script> ``` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _(c) 2021 DeviceAtlas Limited. All rights reserved. https://deviceatlas.com _ <!-- HTML+JS for document formatting when opened in browser --> <div class="btn-group" id="main-menu" style="float:right"><a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Menu<span class="caret"></span></a><ul class="dropdown-menu"><li><a href="README.html">Main</a></li><li><a href="README.DeviceApi.html">Device Detection API</a></li><li><a href="README.Upgrade.html">Device Detection API Upgrade</a></li><li><a href="DeviceApiDocs/Mobi/Mtld/Da/Device/DeviceApi.html">Device API docs</a></li><li class="divider"></li><li class="disabled"><a href="README.ClientSide.html">Client Side Component</a></li><li><a href="README.ConnectivityAnalyser.html">Connectivity Analyser</a></li><li class="divider"></li><li><a href="README.CarrierApi.html">Carrier Identification API</a></li><li><a href="CarrierApiDocs/Mobi/Mtld/Da/Carrier/CarrierApi.html">Carrier API docs</a></li></ul></div>