👋 WELCOME to HypeXAPI
How are we doing it?

Dynamic data

12min

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:

JS


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:

JS


To create placeholders for the boolean and number variables:

JS



Set these variables in the GUI.

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:

boolean variable
boolean variable

number variable
number variable

string variable
string variable


Run expression...

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:

Document image


Here we take the variable 'raw' that was set in hypeCustomData and we are adding 5 to its number value.

Document image


Now we take the same vaiable and subtracted the number value 2 from it.

Document image


Now we multiplied the same 'raw' variable and multiplied it by 2.

You can also run some basic JavaScript in Run Expression as well.

Document image


Something else to consider when using Run Expression, is to pass basic Hype specific JavaScript like this into it:

JS


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.

Run expression tutorial with timer



ISO time conversion function

JS


Expanding on the result object

The following tutorial shows how to use and update Boolean and number variables, using the Result object as a use-case.