Some platforms do not allow video ads to be displayed because the game applications are being loaded into an iframe by the platform which does content aggregation and uses its own domain. In this case, it will not host your ads.txt file under their domain URL. Hence, you will only be able to show banners and rich media ads using the fallback option.
These situations can be handled using the z2 window option. This special window option allows you to track ads to your own game domain rather than the platform domain so that you can manage your own ads.txt file to enable high-CPM video ads.
In order to exchange data and callbacks between your integration and the z2 window, the z2 code and z2index.html work together to pass the option values to the z2window and return the local callback events to the integration code. This allows you to configure all options for the z2 window within your integration to simplify setup, especially the use of dynamic values.
When the z2 window opens, it creates a listener which sends a z2-ready message to tell the integration side that it’s open and ready to load the options. The integration receives the z2-ready message. It packages the options with JSON and sends them to the z2 window. The z2 window then, parses the JSON and places the options into the object that will be used by invokeApplixerVideoUnit. Once done the listener removes itself. As the video is displayed, events arrive at the callback and are relayed back to the integration by the postMessage call.
Use the code shown below in your integration. Please do not modify the code snippet except for the option values.
window.addEventListener('message', function initZ2(e) {
if (e.origin !== "https://my.gamedomain.com") { // Recommended
return;
}
if (e.data == 'sys-closing’) { // Remove the z2 window
window.removeEventListener('message', initZ2, false);
}
else if (e.data == 'z2-ready') {
var options2 = {
zoneId: nnnn,
devId: xxxx,
gameId: yyyy,
dMode: 1, // 1 for MD5 checksum, 0 for no MD5 checksum
fallback: n,
verbosity: n,
vtos: 2, // do not change unless placement adjustment is required
htos: 3, // do not change unless placement adjustment is required
}
// Recommended: replace "*" with "https://my.gamedomain.com" only after initial tests
e.source.postMessage("loadOptions=" + JSON.stringify(options2), "*");
return;
}
adStatusCallback(e.data);
}, false);
To enable z2 window in the application,
- Download file ‘z2index.html’ from the SDK package and copy it to the root directory of your game server.
- Launch a z2 window and create an event listener as shown above. This can be done only from a click event handler else it fails. Use the code shown above for reference.
- Add an additional option field to the function adStatusCallback in your game code. Replace the game domain with your game server host.
z2url: https://<my.gamedomain.com>/z2index.html
- Place your ads.txt in the root directory of your game server.
Note: Only invokeApplixirVideoUnit can be used with Z2 window, initApplixirVideoUnit and playApplixirVideoUnit methods cannot be used here.