In the onClick handler of the button your users click to watch reward videos, call invokeApplixirVideoUnit
. This will load and play the video. Use the following code inside the onClick handler, replacing the zoneId
, accountId
, and siteId
with the values from your site page:
<script type=’application/javascript’>
var options = {
zoneId: my-zoneID,(this needs to be 2050 for testing)
userId: this.userID, UUID4 value recommended
accountId: my-accountID,
siteId: my-siteID,
adStatusCb: adStatusCallback
};
<button type="button" id="showRewardAdButton">Show Reward Ad</button>
function adStatusCallback(status) {
console.log('Ad Status: ' + status);
}
showRewardAdButton.onClick =
function () {
invokeApplixirVideoUnit(options); //play the video ad
};
</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.
Recommended Best Practices
- To comply with browser rules for rewarded video ads, you must call
invokeApplixirVideoUnit
from within an onClick handler. If you don’t, your ads will be blocked, resulting in a 4xx error. - After receiving the 'sys-closing' event, wait at least 1-3 minutes before making another call to
invokeApplixirVideoUnit
. If you're using RMS (Reward Management System), follow the "time between callbacks" setting you selected.