Variables

In this section you'll learn how to define and use your own ad configuration in your manifest.json file, as well as dynamic configuration like geographical location.

Every ad can be configured using variables defined in your manifest.json file. In it's simplest form you specify entries in the "variables" section that can later be read from within the ad using html5.getVariable(name).

"variables": {
  "background-color": "#FFD425"
}

This example reads the entry "background-color" from the above manifest.json file and sets the background color of the ad to that value.

<script type="text/javascript">
  html5.ready(function() {
    document.body.style.backgroundColor = html5.getVariable("background-color");
  });
</script>

Dynamic Variables

Apart from defining your own variables, our system can inject dynamic variables that can be read from your ad. The following example expose geographical information to an ad:

"variables": {
  "$latitude": "{{latitude}}",
  "$longitude": "{{longitude}}"
}
<script type="text/javascript">
  html5.ready(function() {
    document.getElementById("long").innerHTML = html5.getVariable("longitude");
    document.getElementById("lat").innerHTML = html5.getVariable("latitude");
  });
</script>
<p>Longitude: <span id="long">...</span></p>
<p>Latitude: <span id="lat">...</span></p>

Available macros

The following table lists all the available variable macros:

Parameter Type Example Description
{{longitude}} number 18.05 Longitude coordinate of the browser
{{latitude}} number 59.33 Latitude coordinate of the browser

Last modified: Mon Sep 23 2024 11:48:54 GMT+0200 (Central European Summer Time)

results matching ""

    No results matching ""