Skip to content

Tagging Overview

After initiating the Tag Manager and setting up the current page with the init function, you can register video ad slots with the registerSlot function.

API Reference

registerSlot(options)

Registers a video ad slot with a slot-specific options object

★ Attention: the two targetings sound and autoplay are mandatory!

Example code
javascript
admTagMan.q.push(function() {

    // minimal config    
    admTagMan.registerSlot({
        slot: 'preroll_1',
        container: 'apn-ad-slot-preroll_1',
        duration: 121,
        events: {
            adReady: function(data) {
                // you can access the vastURL form the data object to use it in your player configuration
                console.log('vastUrl is ready to be use in the player', data.vastUrl);

            }
        },
        targeting: {
            sound: '0', //mandatory! set '0' or '1' ('0' for video-content starts with sound muted, '1' for video-content starts with sound on)
            autoplay: '0' //mandatory! set '0' or '1' ('0' for click to play, '1' for autoplay)
            // pagetype: 'overview', // optional if set on init already!  Set to overview or article according to current page
            // examplekey: ['set', 'multiple', 'values', 'like', 'this'], // optional
        }
    });

    // additional registerSlot calls can be added here
    // [...] 

    admTagMan.loadSlots();
});
Possible options properties for registerSlot(options)
KeyRequiredTypeDescription
slotrequiredstringShould match one of your slots in our system like preroll_1 etc.
containerrequiredstringMust match the unique container ID of the element inside your DOM, which will be used to render the ad into.
durationrequired for instreamobjectMust match the video-content's duration in seconds. Set it as integer.
eventsrequired for instreamobjectThe callback adReady can be registered here. In case of a PREROLL or other video ad slot, the vastUrl property in the adReady event is available in the data object which contains the VAST URL for further player configuration, for example:
{vastUrl: 'https://vast.adserver.com/preroll...'}
targetingoptional & requiredobjectAdditional targeting based on the current ad slot can be provided here as key-value pairs in lowercase. For instream the two targetings 'sound' and 'autoplay' are required.

Attention: Re-using of the same container ID when registering a slot on the same page is not

permitted. This will result in ads not being delivered!

loadSlots()

This function must be called after the queue is filled with all needed ad slots on a page. Please also refer to loadSlots().