Hi, I plan to collect device information from the anonymous survey link. Meta Info cannot work when using the anonymous link. Therefore, I tried to load the ua-parser java library (Here is the package link: https://github.com/faisalman/ua-parser-js/tree/gh-pages) into Qualtrics JavaScript.
However, the function doesn’t work. How to set up the external JS library work? I am a beginner in JavaScript. Below is my code. I appreciate any help.
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
jQuery.getScript("https://github.com/faisalman/ua-parser-js.git", function(){
//src = "https://github.com/faisalman/ua-parser-js.git";
//src="https://cdnjs.cloudflare.com/ajax/libs/ua-parser-js/0.7.28/ua-parser.min.js";
// Create an instance of UAParser
var parser = new UAParser();
// Parse the user agent string
var result = parser.getResult();
// Access parsed information
var deviceModel = result.device.model || "Unknown";
var deviceType = result.device.type || "Unknown";
var browserName = result.browser.name || "Unknown";
var browserVersion = result.browser.version || "Unknown";
var osSystem = result.os.name || "Unknown";
Qualtrics.SurveyEngine.setJSEmbeddedData("DeviceModel", deviceModel);
Qualtrics.SurveyEngine.setJSEmbeddedData("DeviceType",deviceType);
Qualtrics.SurveyEngine.setJSEmbeddedData("BrowserName", browserName);
Qualtrics.SurveyEngine.setJSEmbeddedData("BrowserVersion", browserVersion);
Qualtrics.SurveyEngine.setJSEmbeddedData("OperatingSystem", osSystem);
});
});