This guide will cover how to dynamically display a learner's name on Storyline content.

Note: You won't need any Javascript knowledge, we've written the script for you, but you will need Storyline software.

In your Storyline software...

Add a trigger to "Execute Javascript".

https://cdn.elev.io/file/uploads/mOnuNauuhTyOz8kS_TfpzsZdQWgtfaaGn21LzGVf_fE/qxffdEVWyYHIDpRqDFdVKasDAlYCeOZv8arB0-QF7fs/9--eI.PNG


You will need to add a script that will read from the launcher URL to get the learner's name. It will then set a variable to the learner's name. The script we've written is below.

Paste in the below Script:

var actorParam = getQueryVariable('actor');

var player = GetPlayer();
if(player) {
var name = actorParam["name"];
player.SetVar("actorname", name);

}


function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){
return convertToJSON(pair[1]);
}
}
return undefined
}

function convertToJSON(v) {
if(!v) {
return {}
}
return JSON.parse(decodeURIComponent(v.replace(/\+/g, '%20')));
}

Add in a variable in Storyline by clicking on the (x) icon:

https://cdn.elev.io/file/uploads/mOnuNauuhTyOz8kS_TfpzsZdQWgtfaaGn21LzGVf_fE/pBycZzpQQoNyfq9gJEGWkFRUOU4mneqDYooT8WcAGXc/16-WBU.png


Create a "text" type variable, and call it "actorname".

Set the default value to whatever you like. We've set it to "learner". Ideally if the script is working properly, you shouldn't see this default value at all.

https://cdn.elev.io/file/uploads/mOnuNauuhTyOz8kS_TfpzsZdQWgtfaaGn21LzGVf_fE/uygyY7MALv45W7r5IvVLK1ZxaUPgCc5z_tdB500_G9A/17-UR0.png


On the Storyline slide you can display the learner's name by inserting a textbox and pasting in:

The learner’s name is: %actorname%

The %actorname% will be replaced by the learner's name.

https://cdn.elev.io/file/uploads/mOnuNauuhTyOz8kS_TfpzsZdQWgtfaaGn21LzGVf_fE/fCHfdTcLqKdUOhDAzBf9xyQxH1dHDNGBvvLMM95zYLI/10-UUE.PNG


A published Tin Can package to demonstrate how it works is attached below:

Storyline Tin Can package

To see how it works you can:

  1. Upload this package into xapiapps using the Storyline launcher
  2. Add to a pathway
  3. Assign the pathway to a learner
  4. Log in / impersonate this learner and start the task

You'll see the following on the Storyline slide.

https://cdn.elev.io/file/uploads/mOnuNauuhTyOz8kS_TfpzsZdQWgtfaaGn21LzGVf_fE/WpD7kzS5ufmIQHeIOpXDMNJGZzOhnEnfunVVxoBWEeE/11-YgM.PNG