Request for help with device limitation on Qualtrics | XM Community
Skip to main content

Hi -
I am reaching out to request for help with device limitation using Qualtrics. I would like to restrict my participants to use only computers (i.e., laptops and desktops) and tablets, but not smartphones. I wondered how to make this function work.
I tried to use the built-in function using embedded data (i.e., end of study when the device type is mobile). However, I found if I use this function, both people using tablets and smartphones are unable to take part in the study. I was wondering what I can do to only exclude participants using smartphones?
Many thanks!

Hi there, I think this can be approached by using JavaScript to detect the size of the screen and then set an Embedded Data value if the screen size has a width of under 480px, which is what a lot of smartphones use.
To put that in place, first create an Embedded Data field called "IsPhoneScreen" and put it at the top of the Survey Flow. Next, create a Text/Graphic question that is seen by all respondents. In this question, the below JavaScript can be added in the OnReady section:
if (jQuery(window).width() < 480) {
Qualtrics.SurveyEngine.setEmbeddedData("IsPhoneScreen","1");
}
Back in the Survey Flow and after the Block with the Text/Graphic question, add a Branch element to direct respondents to an End of Survey message if they have an Embedded Data value of 1 for IsPhoneScreen.
--
Another bit of code that might be helpful (though I haven't tested) is the one discussed here. This uses the respondent user agent to see if it contains parts that are associated with tablets.
To put that in place, first create an Embedded Data field called "IsTablet" and put it at the top of the Survey Flow. Next, create a Text/Graphic question that is seen by all respondents. In this question, the below JavaScript can be added in the OnReady section:
const userAgent = navigator.userAgent.toLowerCase();
const isTablet = /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(userAgent);
if (isTablet == true) {
Qualtrics.SurveyEngine.setEmbeddedData("IsTablet","1");
}
Back in the Survey Flow and after the Block with the Text/Graphic question, add a Branch element to direct respondents to an End of Survey message if Device Type = Mobile and they do not have an Embedded Data value of 1 for IsTablet.


https://community.qualtrics.com/XMcommunity/discussion/comment/55274#Comment_55274Hi Tom, 
Thank you very much for your timely help and thorough explanation! I will test both codes you kindly provide!
I am now using the user agent strings and js library to differentiate different devices, while I will need to try different devices to see if it would work accurately.


Leave a Reply