The AdinPlay library is a JavaScript library for displaying ads on your website. This document explains how to add the AdinPlay library to your site.
<!-- AdinPlay Ads --> <script> var aiptag = aiptag || {}; aiptag.cmd = aiptag.cmd || []; aiptag.cmd.display = aiptag.cmd.display || []; aiptag.cmd.player = aiptag.cmd.player || []; //CMP tool settings aiptag.cmp = { show: true, position: "centered", //centered or bottom button: true, buttonText: "Privacy settings", buttonPosition: "bottom-left" //bottom-left, bottom-right, top-left, top-right } </script> <script async src="//api.adinplay.com/libs/aiptag/pub/XXXXX/tag.min.js"></script>
The above code does two main things:
Custom implementations may require adding additional code to the last line of the JavaScript snippet. However, you should not change the order or the code that loads the AdinPlay Ads JavaScript library.
<div id='XXXXX_placement'> <script type='text/javascript'> aiptag.cmd.display.push(function() { aipDisplayTag.display('XXXXX_placement'); }); </script> </div>
aiptag.cmd.display.push(function() { aipDisplayTag.display('XXXXX_placement'); });
aiptag.cmd.display.push(function() { aipDisplayTag.destroy('XXXXX_placement'); });
aiptag.cmd.display.push(function() { aipDisplayTag.destroy(); });
<div id="videoad"></div>Initialize the Video player, this should be done only once per page load.
aiptag.cmd.player.push(function() { aiptag.adplayer = new aipPlayer({ AD_WIDTH: 960, AD_HEIGHT: 540, AD_DISPLAY: 'default', //default, fullscreen, center, modal-center, fill LOADING_TEXT: 'loading advertisement', PREROLL_ELEM: function(){return document.getElementById('videoad')}, AIP_COMPLETE: function (evt) { /******************* ***** WARNING ***** ******************* Please do not remove the PREROLL_ELEM from the page, it will be hidden automaticly. */ console.log("Video Ad Completed: " + evt); } }); });Show the Video Ad
//check if the adslib is loaded correctly or blocked by adblockers etc. if (typeof aiptag.adplayer !== 'undefined') { aiptag.cmd.player.push(function() { aiptag.adplayer.startVideoAd(); }); } else { //Adlib didnt load this could be due to an adblocker, timeout etc. //Please add your script here that starts the content, this usually is the same script as added in AIP_COMPLETE. console.log("Ad Could not be loaded, load your content here"); }
AIP_REWARDEDNOTGRANTED: function (state) { //This event is fired when a rewarded ad is: //timed out, empty, unsupported or closed by the user. //don't grand the reward here alert("Rewarded ad state: " + state); //state can be: timeout, empty, unsupported or closed. }, AIP_REWARDEDGRANTED: function () { alert("Reward Granted"); }like this
aiptag.cmd.player.push(function() { aiptag.adplayer = new aipPlayer({ AIP_REWARDEDNOTGRANTED: function (state) { //This event is fired when a rewarded ad is: //timed out, empty, unsupported or closed by the user. //don't grand the reward here alert("Rewarded ad state: " + state); //state can be: timeout, empty, unsupported or closed. }, AIP_REWARDEDGRANTED: function () { alert("Reward Granted"); }, AD_WIDTH: 960, AD_HEIGHT: 540, AD_DISPLAY: 'default', //default, fullscreen, center, modal-center, fill LOADING_TEXT: 'loading advertisement', PREROLL_ELEM: function(){return document.getElementById('videoad')}, AIP_COMPLETE: function () { /******************* ***** WARNING ***** ******************* Please do not remove the PREROLL_ELEM from the page, it will be hidden automaticly. */ console.log("Video Ad Completed: " + evt); } }); });Show the Rewarded Ad
//check if the adslib is loaded correctly or blocked by adblockers etc. if (typeof aiptag.adplayer !== 'undefined') { aiptag.cmd.player.push(function() { aiptag.adplayer.startRewardedAd(); }); } else { //Adlib didnt load this could be due to an adblocker, timeout etc. //Please add your script here that starts the content, this usually is the same script as added in AIP_REWARDEDCOMPLETE. console.log("Rewarded Ad Could not be loaded, load your content here"); }
//check if the adslib is loaded correctly or blocked by adblockers etc. if (typeof aiptag.adplayer !== 'undefined') { aiptag.cmd.player.push(function() { aiptag.adplayer.startAudioAd(); }); } else { //Adlib didnt load this could be due to an adblocker, timeout etc. //Please add your script here that starts the content. alert("Audio Ad Could not be loaded, load your content here"); }
//Interstitial ad available event document.addEventListener("aip_interstitialadavailable", function(e) { console.log("An interstitial ad is available"); });
// disable interstitial ads aiptag.disableInterstitialAd = true;
// mark ad requests to be treated as child-directed aiptag.COPPA = true;
aiptag.cmp = { show: true, position: "centered", //centered or bottom button: true, buttonText: "Privacy settings", buttonPosition: "bottom-left" //bottom-left, bottom-right, top-left, top-right }
If you choose not to use the Consent tool button its important to implement aipAPItag.showCMPScreen(); as described below. To comply with the GDPR to show the Consent tool settings menu to revoke or change your consent settings.
<a href="javascript:void(0)" onclick="aipAPItag.showCMPScreen()">Privacy settings</a>You can use the following functions to show or hide the settings button. (this can be useful when in game for example.)
aipAPItag.hideCMPButton(); aipAPItag.showCMPButton();Add the following querystring to your site to test the GDPR outside the EU.
http://www.yousite.com/?cmpscreen&cmpregulationkey=GDPR
Event |
Description |
"aip_consentnotrequired" |
No consent required, consent tool is not loaded. |
"aip_consentinit" |
CMP code is loaded and the stub code has been removed. At this stage the CMP has no information about the consent yet. |
"aip_consentsettings" |
CMP finished loading its settings. If a consent string existed already, the consent data can now be read from the CMP. |
"aip_consentscreen" |
CMP shows the consent screen |
"aip_consentscreenoff" |
CMP removes the consent screen |
"aip_consent" |
CMP has gathered consent or a preexisting cookie was found. Consent data can now be read from the CMP. |
"aip_consentapproved" |
Visitor gave positive consent to all vendors/purposes |
"aip_consentrejected" |
Visitor rejected all vendors and purposes |
"aip_consentliestablished" |
Consent screen is shown, legitimate interest has been established for this visitor. |
Examples
//CMP shows the consent screen document.addEventListener("aip_consentscreen", function(e) { console.log("CMP shows the consent screen"); }); //CMP removes the consent screen document.addEventListener("aip_consentscreenoff", function(e) { console.log("CMP removes the consent screen"); });
If you want the consent layer to show up (even for users that already gave consent), you can do so by simply loading the page with the parameter (?cmpscreen). For example: https://adinplay.com/?cmpscreen will force the consent screen to show.