Adding AdinPlay Ads to Your Site

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.

The JavaScript snippet

Adding the following code (known as the "JavaScript snippet") to your site's templates is the easiest way to get started using AdinPlay Ads. The code should be added near the top of the <head> tag and the string 'XXXXX' should be replaced with the property ID (also called the "AIP ID").
<!-- AdinPlay Ads -->
<script>
var aiptag = aiptag || {};
aiptag.cmd = aiptag.cmd || [];
aiptag.cmd.display = aiptag.cmd.display || [];
aiptag.cmd.player = aiptag.cmd.player || [];
</script>
<script async src="//api.adinplay.com/libs/aiptag/pub/XXXXX/tag.min.js"></script>

The above code does two main things:

  1. Starts asynchronously downloading the AdinPlay Ads JavaScript library from api.adinplay.com, always use async mode to download the AdinPlay Ads JavaScript library for better user experience.
  2. Initializes a global aiptag.cmd function (called the aiptag.cmd command queue) that allows you to schedule commands to be run once the AdinPlay Ads JavaScript library is loaded and ready to go.
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.

Displaying and Refreshing Display Ads

The string 'XXXXX_placement' should be replaced with the placement ID (also called the "AIP PLACEMENT ID").

Displaying Display Ads

<div id='XXXXX_placement'>
    <script type='text/javascript'>
    aiptag.cmd.display.push(function() { aipDisplayTag.display('XXXXX_placement'); });
    </script>
</div>

Refreshing Display Ads

aiptag.cmd.display.push(function() { aipDisplayTag.display('XXXXX_placement'); });

Displaying Video Ads

Create a container to display the Video Ad
<div id="preroll"></div>
Initialize the Video player, this should be done only once per page load.
aiptag.cmd.player.push(function() {
	adplayer = new aipPlayer({
		AD_WIDTH: 960,
		AD_HEIGHT: 540,
		AD_FULLSCREEN: false,
		AD_CENTERPLAYER: false,
		LOADING_TEXT: 'loading advertisement',
		PREROLL_ELEM: function(){return document.getElementById('preroll')},
		AIP_COMPLETE: function ()  {
			// Please do no remove the PREROLL_ELEM from the page at this point
			alert("Ad Completed");
		},
		AIP_REMOVE: function ()  {
			// If needed it's save to remove the PREROLL_ELEM from the page at this point.
		}
	});
});
Show the Video Ad
//check if the adslib is loaded correctly and not blocked by adblockers.
if (typeof adplayer !== 'undefined') {
	aiptag.cmd.player.push(function() { adplayer.startPreRoll(); });
} else {
	//Adlib didnt load this could be due to an adblocker.
	//Please add your script here that starts the content.
	alert("load your content here");
}

GDPR Consent tool settings

Enable or disable the AdinPlay GDPR tool based on the boolean value of aiptag.gdprShowConsentTool
<!-- AdinPlay Ads -->
<script>
var aiptag = aiptag || {};
aiptag.cmd = aiptag.cmd || [];
aiptag.cmd.display = aiptag.cmd.display || [];
aiptag.cmd.player = aiptag.cmd.player || [];

aiptag.gdprShowConsentTool = true;
</script>
<script async src="//api.adinplay.com/libs/aiptag/pub/XXXXX/tag.min.js"></script>

When using the Consent Tool aiptag.gdprShowConsentTool = true; you can use the following functions to:

Change the position of the Consent Tool to display on the bottom of the page.
<!-- AdinPlay Ads -->
<script>
var aiptag = aiptag || {};
aiptag.cmd = aiptag.cmd || [];
aiptag.cmd.display = aiptag.cmd.display || [];
aiptag.cmd.player = aiptag.cmd.player || [];

aiptag.gdprShowConsentTool = true;
aiptag.gdprConsentToolPosition = "bottom";
</script>
<script async src="//api.adinplay.com/libs/aiptag/pub/XXXXX/tag.min.js"></script>
Show or hide the AdinPlay GDPR tool settings button based on the boolean value of aiptag.gdprShowConsentToolButton
<!-- AdinPlay Ads -->
<script>
var aiptag = aiptag || {};
aiptag.cmd = aiptag.cmd || [];
aiptag.cmd.display = aiptag.cmd.display || [];
aiptag.cmd.player = aiptag.cmd.player || [];

aiptag.gdprShowConsentTool = true;
aiptag.gdprShowConsentToolButton = true;
</script>
<script async src="//api.adinplay.com/libs/aiptag/pub/XXXXX/tag.min.js"></script>

Important: If you choose not to use the Consent tool button its important to implement aipAPItag.showConsentToolSettings(); as described below. To comply with the GDPR

Show the Consent tool settings menu, to revoke or change your consent settings.
Important: The implementation of the code below is required by the GDPR when using aiptag.gdprShowConsentToolButton = false;
<a href="javascript:;" onclick="aipAPItag.showConsentToolSettings();">Change your Consent</a>
When using the Consent Tool and aiptag.gdprShowConsentToolButton = true; you can use the following functions to:
Show or hide the settings button. (this can be useful when in game for example.)
aipAPItag.hideConsentToolButton();
aipAPItag.showConsentToolButton();

Testing the GDPR consent tool for none EEA users

For testing purposes you can append the following parameter to the end of your url: ?forceUserFrom=EEA to force you are from EEA country and test the implementation for EEA users

Using your own GDPR Consent tool

If aiptag.gdprShowConsentTool = false; you should use your own GDPR consent tool for users from within EEA countries. Please set aiptag.gdprAlternativeConsentTool = true; this is very important because this will make sure that the Ads will handle the consent correctly. Once you will have the consent of the alternative consent tool you are using please set aiptag.gdprConsent accordingly meaning:
  • If a user has declined: aiptag.gdprConsent = false;
  • If a user has accepted: aiptag.gdprConsent = true;
  • If not set the library will handle aiptag.gdprConsent = true;
<!-- AdinPlay Ads -->
<script>
var aiptag = aiptag || {};
aiptag.cmd = aiptag.cmd || [];
aiptag.cmd.display = aiptag.cmd.display || [];
aiptag.cmd.player = aiptag.cmd.player || [];

aiptag.gdprShowConsentTool = false;
aiptag.gdprAlternativeConsentTool = true;
</script>
<script async src="//api.adinplay.com/libs/aiptag/pub/XXXXX/tag.min.js"></script>