Variables allow you to personalize the viewing experience. There are two primary functions:
- Customizing text shown in an annotation, e.g:
- To control whether future annotations are displayed or not, using Display Rules.
There are three types of variables:
- OnClick variables: Variables explicitly set when an annotation is clicked.
- Quiz variables: Variables automatically created by quiz annotations.
- Environment variables: Variables passed to HapYak from an external system.
Variable name must begin with a letter, _ or $. Use = for assignments, and double quotes for quoted strings. Delimit multiple variables with a comma.
example: product_id=256231, customer_type="lead"
You can make the video pause or play when the viewer clicks, using these variables.
Here's an example.
Every question defined in a Quiz annotation will automatically create two variables.
- The value of the answer provided by the viewer.
- Whether the answer provided by the viewer was correct.
These variables are automatically created and listed anywhere you can select a variable.
For reference they are named
ex/ quiz_123_1 is the answer to the first question in the quiz with id 123.
To indicate a correct answer add
To indicate an incorrect answer add
To only show an annotation if an incorrect answer is given use this for your display rule.
ex/ quiz_123_1 && !quiz_123_1_correct
Here is an example video of how to do that...
Developers using the HapYak Embed API can directly provide a JSON object when the player is instantiated that defines variables to be used by annotations.
Adding and Testing Variables
You can type a variable directly into your annotation. Here's an example in a text annotation.
To test it out, simply click "view landing page" then at the end of the URL add a query parameter that sets the variable. Make sure to prepend the variable with "
When you play the video the variables will dynamically populate.