Express Detection : Variable Substitution

Substitute detection results or URL fragments into redirection URLs

Express Detection : Variable Substitution

Variable substitution provides a simple and powerful way of creating custom redirects based on the source page and device detection results. You can preserve query parameters and include detection results in your redirects. Available variables are :

Variable What is it ?
$vendor$ The device vendor
$model$ The device model
$os$ The device operating system
$osversion$ The device operating system version
$browser$ The device browser
$browserversion$ The device browser version
$formfactor$ Bar, Clamshell, Slide, Dual Slide, Swivel, Tablet
$class$ Mobile, Tablet, Console, Camera, Glass
$width$ Screen width in normal orientation (pixels)
$height$ Screen height in normal orientation (pixels)
$country$ The country the device is being used in
$isp$ The ISP or Carrier the device is accessing the internet through
$scheme$ http or https (how the script was called)
$host$ The website that downloaded this detection script (eg www.example.com)
$path$ The path to the page that called this detection script. (eg /some/path/page.html)
$query$ Any query variables from the page that called this script (eg q=red+shoes&category=shoes)
$fragment$ Anything after the # from the page that called this script

This tutorial covers creating a simple redirect using the detection results in the redirection URL. It sounds a little bit tech, but it's actually pretty cool and easy too. Here are the steps on how to use detection variables in redirection URLs.

 

So let’s jump into handset detection, and add a Site by choosing Add Site.

Then click 'Add New Rule' and today we'll add a basic rule for redirecting All Mobile devices (via an isMobile is true condition).

Enter the basic site details, site name, desktop URL and ensure smart redirection is checked.

Finally, enter your redirection URL, placing the substitution variables directly in the URL itself and Save it.

Once its saved it takes you to a Site Set-up page. Choose the Express tab and select the Basic Detector.
Copy and paste that into your website.

Jump in to your website and paste the code. Use Safari with Developer Tools enabled or use Firefox with the User-Agent-Switcher installed to masquerade as an iPhone and refresh your page.

Test the site and verify that your redirection URLs are good. Job Done :-)

Get Started Today

Our free Express / Cloud plan has 20,000 detections per month. No credit card required. Upgrade when you're ready. We also have a free Community Edition for Ultimate Detection, our high performance local detection library, which you can build into community open source projects.


Get Started. Its Free