Functions in Hype xAPI
hypeDocument

hypeDocument.setCustomDataVariable

2min

The hypeDocument.setCustomDataVariable function is used to store custom data variables that can be used in the LRS notation. The function takes two parameters: the key of the custom data variable, and the value to be stored. The value can be either a string, number, or boolean. If the value is a string, it will be stored as-is. If the value is a number, it will be stored as a floating-point number. If the value is a boolean, it will be stored as either true or false. An example of using the hypeDocument.setCustomDataVariable function would be as follows:

JS


In this example, we are setting three custom data variables: userID, userAge, and userIsRegistered. The userID variable is being set to a string value of "User123456", the userAge variable is being set to a number value of 21, and the userIsRegistered variable is being set to a boolean value of true.

Hence, be aware that there is some variable casting going on when using the hypeDocuemt.etCustomDataVariable function. This function exists to provide the GUI version and mirror the functionality in code.

If you mainly use Hype custom data you can also use hypeDocument.customData directly:

JS