Enhancing Detection Results

The following notes apply to Cloud and Ultimate detection only ! Express Detection has this functionality built into it.

Handset Detection uses HTTP headers (user-agent and others) to detect devices. Unfortunately many devices, by Apple in particular, share the same HTTP headers which makes it difficult to tell them apart.

To differentiate between devices that have the same HTTP headers we've developed a small javascript snippet that collects a few pieces of hardware information. When passed to a detection request it radically improves the accuracy of the result.

The script does the following things

Collects the screen width Collects the screen height Collects the device pixel ratio Runs a micro benchmark (50 milliseconds) Sets the information in a cookie (hd41) The following script example loads a javascript at www.yourdomain.com/page.html with the results appended as a query string eg www.yourdomain.com/page.html?w=480&h=800&r=150&b=525

You could equally trigger a page reload with the string appended, include this inside any other script you have, or step new visitors through a temporary page.

Pass this information through to the detection engine by setting 'x-local-hardwareinfo' in the request body, and transforming the string into {width}:{height}:{ratio}:{benchmark} eg 480:800:150:525

See https://github.com/HandsetDetection/js-helper for more information.

Still need help? Contact Us Contact Us