Variables allow you to personalize the viewing experience. There are two primary functions:
- Customizing text shown in an annotation, e.g:
- Using with Display Rules to control whether or not future annotations are displayed.
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.
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:
example: 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.
example: 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 Test Preview 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.