Storyline & JavaScript
Let's continue to explore how to use various JavaScript snippets within Articulate Storyline 360. In this video, we cover query strings. Query strings allow us to pass new information into a course just by adding additional content to the URL. With this information, your course can adapt and change based on the information you give it.
You could set up your course to branch to different locations based on the information that is updated from the URL. In this video, I walk you through how to create the JavaScript that will read the query string and then update your Storyline Variables; once the Storyline variable is updated, you can add conditions to do whatever you want within the course. Knowing how to use query strings is handy when capturing the actor information for xAPI.
let player = GetPlayer();
let urlValues = window.location.search;
let searchParams = new URLSearchParams(urlValues);
let name = searchParams.get('name');
let age = searchParams.get('age');
let testVar = searchParams.get('testVar');
player.SetVar("queryName", name)
player.SetVar("queryAge", age)
player.SetVar("testVar", testVar)
// ?name=Jeff&age=20&testVar=Sample