Grab variable from parent URL

Jul 23, 2013

This may be a very odd question.. but i'm going to ask it anyway

Let's say i have a course that resides at:

If i needed to pass variables in that url.. for instance i wanted the url to be:

is there anyway to grab that vairable coursename.. from the url so that i could use it within my course?

I'm trying redirect trainees at the end of the course to another page whose url i build on the fly based on the variable coursename

Has anyone had any success with anything like this?

18 Replies
Jason Johnson

You can use custom Javascript within the Storyline course to communicate with the document object model (DOM) which contains that information. The problem/trick is that you will need to understand Javascript and how to use it to read the DOM which contains the parent URL, etc and process it from there--probably add a variable in Storyline that you can push your query string into. Another trick might be to embed a web object and have that communicate with the parent document--this can work as long as the web object is from the same domain as the course, 'cause if it's not you get into a whole different cross-domain security issue.

Here's a sample line of code to retrieve GET data from the URL:

var query =;

It will definitely take some programming knowledge to get this accomplished but it's doable.

Helene Sobelman

That's awesome.. that is what i was thinking I might be able to do... use JavaScript.. but where I get stuck is.. if I use the line you (Jason) put above.. I then have what I need saved in the is variable query.. but how can I set a storyline variable to the value of query? Can I just use a storyline trigger to adjust variable mystorylinevar (defined within storyline) and set it equal to query (defined in is). 

Jason Johnson

it would look something like this (pseudo code, not to be taken literally):

var query =; //verify syntax is accurate for what you want to do; I didn't but it should be close

var slPlayer = GetPlayer(); //reference to SL player

var myStorylineVar = query;

slPlayer.SetVar("theNameOfYourStorylineDefinedVarHere", myStorylineVar );

Just make sure you send a variable with the correct data type that will match the setting for your SL variable or you might get unexpected results/errors. This example would be a "text" variable, or "string" in geek speak.

Jason Johnson

Helene, glad you got it to work! I know the code wasn't functional; just a concept to point you in the right direction. I've also been testing SL/Javascript communication over the last few weeks--translated: banging my head into the wall--so I know it can be frustrating and time-consuming but I'm glad you got your solution. =)

David Richmond

Figured it out: Here is a working code sample

URL is:

made a variable in storyline called StudentID type text

then on the first slide make a trigger that executes this javascript

function gup( name )
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
    return results[1];

var player = GetPlayer();

var sid = gup("StudentID");
var cid = gup("CourseID");


alert("Welcome back, " + player.GetVar("StudentID") + ".");

This will allow you to pass a URL parameter into your storyline project


David Richmond

I have one more question for the experts, I have successfully created a homegrown LMS that submits score,studentid,courseid, to mysql.  My problem comes from HTML5 conent.  When you hit story.html javascript redirects to the html5 conent but I use a parameter string that of course does not get preserved.



so I grab the courseId and name and studentid and put them in articulate then later pull them out to generate a certificate and submit via ajax to mysql.

Problem is when it redirects to html5 content (which i want to use badly for IOS) the javascript redirects without maintaining the variables can you guide me to what code to redirect to the html5 content but maintain the integrity of the entire parameter string with it?


Ian Hilder

Hi David,

I know this is a very old string so not sure if you are still around but...

What I want to do is add a unique identifier to a URL for a story, grab that from the identifier using something like your code and saving that as a variable in the story. Can I do that using your code and what would I need to change/add?

I had assumed that "StudentID" was the variable to be captured and the "365" in your URL was the unique identifier but adding something like "?Code=Trial" (the equivalent of "?StudentID=365") to the URL seems to break it (at least when using Articulate Online) and the "File Cannot be Found"

If you can help that would be great. Here's hoping


This discussion is closed. You can start a new discussion or contact Articulate Support.