AdGlareCallback ( ) Function

Last Updated:
AdGlare supports a JavaScript callback function which can pass on impression data of ads displayed on a page. It's an alternative to the traditional tracking pixel. Instead of loading a pixel, a JavaScript function is called. For every ad displayed, the engines will call the function AdGlareCallback(data); if present on the page where the ad is shown. It's then up to you what to do with that data.

A few things to remember:
1 Enable this feature via the Settings page in your AdGlare ad server portal.
2 The AdGlareCallback(data) function should be defined before the ads are loaded.
3 The parameter 'data' contains a JSON object.

Step #1: Enabling AdGlareCallback()

Click Settings => Global Settings => Engine Config and enable this feature:

Step #2: Write your callback function

The HTML Document on which the ad is shown should look like this:
... </body> <script> function AdGlareCallback(data) { console.log('Data received via AdGlareCallback()'); console.log(data); var cID = data.cID; var crID = data.crID; //etc... } </script> <!-- AdGlare Banner Zone --> <span id=zone123456789></span><script async src='//adglare-engine-local/?123456789'></script>

Step #3: Getting a readout

In Chrome or FireFox, press CTRL + SHIFT + J to show the developers panel. Click the Console tab. If you've set up the callback function correctly, your data is written to the console.

AdGlareCallback() in JSON ads

You can manually trigger the callback function for each JSON creative that you've shown. The JSON string returned by the engines contains the key/value pair 'AdGlareCallback'. Here's an example how you can implement this:
//'response' contains the JSON string returned by the engines var json = JSON.parse(response); var AdGlareCallback = json.response.campaign.AdGlareCallback; if(AdGlareCallback) { try { if(window[AdGlareCallback.functionName]) { window[AdGlareCallback.functionName](; } } catch(e) {} } // Note: if you've configured the engines to return multiple creatives, the // data is accessible via // json.response.campaigns[0].AdGlareCallback; // json.response.campaigns[1].AdGlareCallback; // json.response.campaigns[2].AdGlareCallback; // etc...

If you would like to discuss further technical details, feel free to contact us.

Share This

This article stays online on the following URL: