String replacement is a convenience that allows tokens to be defined in lieu of a hard coded configuration values. This has the benefit of dynamically changing the token values on the fly preventing the need for multiple unique player configurations.
Set a token in place of the hard coded config value:
config : {
propertyName : "${token}"
}String replacement will be done automatically by the player and will be performed at all levels of configuration.
Replacement data can be specified/retrieved in the following ways:
| Method | Description |
|---|---|
| JavaScript | On the page in JavaScript |
| Pre-defined | Generated data or data pulled from the player |
Token values can be defined in JavaScript using the token prefix javascript (see examples):
propertyName : "${javascript.myFunction()}" // Will be replaced with value returned by myFunctionAnd define a function myFunction which returns the value to be injected:
function myFunction() {
return "my-config-value";
}
Below is the list of pre-defined or generated tokens:
| Name | Token | Description |
|---|---|---|
| Content Id | ${content.id} |
Returns the id of the current content entry |
| Page Domain | ${page.domain} |
Returns the current page domain |
| Page Url | ${page.url} |
Returns the current page url |
| Random | ${random} |
Returns a random number between 0 and 2000 |