Dynamic data
This tutorial sends 4 independant xAPI statements using 2 syntax structures, by using a string variable.
If you know Hype and know your way around JavaScript, you have seen a few ways of how to dynamically update data for the statements by now. But for the other people like me, I need to show you a few methods of how to dynamically update data.
Variables are stored in hypeCustomData. I try to identify the variables that I will use upfront and declare default values for the variables in the HypeXAPI() document. Something like this:
Once they are declared here, you can adjust them in the GUI.
To add a string variable somewhere in your dictionary, add it in place like this:
To create placeholders for the boolean and number variables:
When you have loaded the HypeXAPI export script, you have the ability to set/change the variable values from the actions panel. Changing the values of a string, boolean or a number variable happens the exact same way. For example:
The Run Expression choice in the actions HypeXAPI export script is a special one. Especially for a non-coder like me. If you have declared a value for a variable in hypeDocument.customData, you can do things with Run Expression.
For example, you can change a number variable with some maths:
Here we take the variable 'raw' that was set in hypeCustomData and we are adding 5 to its number value.
Now we take the same vaiable and subtracted the number value 2 from it.
Now we multiplied the same 'raw' variable and multiplied it by 2.
You can also run some basic JavaScript in Run Expression as well.
Something else to consider when using Run Expression, is to pass basic Hype specific JavaScript like this into it:
Here we take the innerHTML value of 'myText' and pass it into the variable myResponseVariable.
The rest is up to you. Have fun with the dynamic data options with the Hype Export script.
The following tutorial shows how to use and update Boolean and number variables, using the Result object as a use-case.