Start by doing these
- Define options and pass it in "new Application(options)"
- When the window loads (and this is important!) you can call application.initialize()
- Now you can register any event handler and call application.openPlayer() to play ads
<script type="text/javascript">
const options = {
gameId: xxxxx,
zoneId: xxxxx,
accountId: xxxxx,
injectionElementId: "some-id" // This is the ID of the div from step 1.
adStatusCallbackFn: (status) => {
console.log("OUTSIDE Ad status: ", status);
},
adErrorCallbackFn: (error) => { // This is how you can listen for errors
console.log("Error: ", error.getError().toString());
},
};
var application = new Application(options);
window.onload = () => {
application.initialize();
document.getElementById("start").addEventListener("click", () => {
application.openPlayer();
});
};
</script>
Note: You must provide a valid UUID value in options.userId
for each user (UUID4 is recommended). Without this, the ad servers won't bid on your ads during mediation, which will greatly reduce your fill rate and CPM rates. This is a standard requirement for all ad networks to participate in ad mediation. If you don’t pass a valid UUID in the userId
field, you’ll see the message “Value in options.userId not a valid UUID!” in the dev-tools console, which needs to be fixed to ensure you receive high CPM rates.