Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introduction

The AdTag Management System simplifies the integration of ad server JavaScript Tags by means of a central library. Instead of integrating multiple AdTags into the HTML documents of your site individually, it assumes the function of the deployment and control of the AdTags based on predefined parameters.

By way of an example, the present documentation will guide the reader through a complete integration process for the system.
You can use code examples from this documentation in a test site at any time.

Note

Please note, that these code examples will not work in a production/live site.

Glossary

This documentation will use some recurring technical terms.

ad slot/Slot
Anchor
adslot
adslot

This term describes a location on an HTML site which can be filled with advertising media. The ad slot will have a name assigned to it depending on its position on the website. This name (which is often an abbreviation consisting of a few letters only) is the same for all ad slots throughout the website which are placed in the same way.
Example: An ad slot is placed centrally preceding the content and even preceding the navigation structure. The ad slot will receive the abbreviated designation of “banner” (short for “Superbanner”).  Independently of whether it will be placed on the homepage of the website or in articles, this slot will always be named “banner”.

AdServer
Anchor
adserver
adserver

A web server whose function is the administration and delivery of advertising campaigns. The ad server waits for a user request, often based on additional information such as the website visited, user interests and so forth, and responds by delivering a suitable advertising campaign for that user.

AdTag

Refers to a request of the ad server, usually via JavaScript. After communication with the ad server, the AdTag delivers the content for the ad slot in which the AdTag was placed. MetaTag will automatically generate all the AdTags for the different ad slots on the basis of different kinds of information, without any additional assistance from the website.

Advertising format

An advertising format is composed of one or two media (Image- Flash, Video) of a particular size. The sizes are, as a rule, standardized, which means that a medium of a certain size is always designated to be a certain advertising format.
Example: An image of a pixel size of 728x90 is designated as a “Leaderboard”. A combined format consisting of the sizes 728x90 and 160x600 pixels placed next to each other is known as a “Hockeystick” or a “Wallpaper”.
A list of all possible “desktop” formats can be found under: Formatspezifikationen (Ad Format Specifications)

HeaderBidding

When using a so called "HeaderBidder", all ad slots of a page will be analyzed by an auction in realtime, before the slots are fully loaded. Advertisers have the possibility to decide how much money the display of an ad on the site is worth to them and place a bid accordingly. This leads to a better, targeted utilization of all possible ad slots and improves the loading speed of the site and all displayed ads.

Single Request Architecture

Instead of sending a separate request for each ad slot to the ad server, SRA will use a single, bundled request for all ad slots at once. This will improve the load speed of the website and decrease the workload on the device and browser of the user caused by ads. SRA is incompatible with a few advertising formats, therefore usage of SRA should be discussed up front with us, so we can depict any negative impact clearly.

Table of Contents

Table of Contents
maxLevel3

Integration of metaTag.min.js


Please implement the provided JavaScript file (ending in metaTag.min.js) in the <HEAD> tag of your website. The file either can be served by the domain of your website or be loaded directly from our CDN.
The library is created for each website individually and will only work correctly on this specific site.

Request from our CDN (Content Delivery Network)

You will receive the path to the file from a Partner Manager responsible for your account (and, as a rule, with the same E-Mail as this documentation).

Code Block
languagehtml
<!-- Integrating metaTag.min.js into the <head> of your website --!>
<!DOCTYPE html>
<html>
  <head>
    ...
    <script async src="https://cdn.stroeerdigitalgroup.de/metatag/live/beispielseite/metaTag.min.js" type="text/javascript" fetchpriority="high"></script>
    ...
  </head>
  <body>
    ...
  </body>
</html>

Cache time of file: 900 sec
Size: ~ 25 kB
Employed CDN: Cloudfront
Server locations used: closest to user, see map
Compression: gzip, brotli

For integrations via javascript it could look like this:

Code Block
languagejs
(function() {
  var channel = !!document.location.href.match(/sdgmt=preview/i) ? 'preview' : 'live';
  var script = document.createElement('script');
  script.type = 'text/javascript';
  script.async = true;
  script.setAttribute('fetchpriority', 'high');
  script.src = 'https://cdn.stroeerdigitalgroup.de/metatag/' + channel + '/beispielseite/metaTag.min.js';
  document.head.appendChild(script);
})();
Tip

You can view the human-readable version of our code by enabling “source maps” in your prefered browsers “Development tools”. Please see your browsers documentation on how to enable this.
The library will receive new features and updates regularly. Please see our Release Log for in-depth information about those changes.

Hosting on your domain

For performance and data-privacy reasons, it might be beneficial to host all MetaTag2 files on your own domain.
Examples on how to update MetaTag2 files regularly and host on your CDN, can be found in our documentation: Metatag2 hosting on a publisher webserver

Integration of Ads.txt file


In order to participate safely in an automatic (programmatic) auctioning network environment, it is possible to lodge an additional file in the domain of the website. This file contains a list of all approved and certified parties, that are eligible for the sale of advertisements on your website. During the auction process, advertisers can scan the file and check if they are negotiating with an authorized party. This assures that the relation between seller, buyer, and the website is established. In addition, unauthorized parties will be strictly excluded.

We already offer a prepared file ready to use via the following URL https://cdn.stroeerdigitalmedia.de/Ads/adstxt/ads.txt
Please download this file and place it in the root domain of your website, for example //mydomain.com/ads.txt

Note

Please make sure this file stays updated. We recommend a synchronization every 24 hours (e.g. via Cronjob).  This guarantees that changes will be applied as soon as possible for your website.
A missing or faulty file, will result in revenue loss.

Feel free to add further entries to this file, e.g. if you like to include any of your own marketing partners. Please make sure that on automatic retrivial of our version of adx.txt, your changes are applied regularly to your version of the file.
You can check your version of the file for errors or problems, with several freely available, online validators. For example: https://adstxt.guru/validator/

Further Information about Ads.txt can be found on the website of the Interactive Advertising Bureau, initiator of the Ads.txt initiative.

Configuration of your website


In order to be able to allocate the correct AdTags to your website, our library requires further information.
This information varies depending on which HTML page the advertisements are being called from. For instance, the library needs different information for the start page of your website than for an article in the category “Fashion”.

There are several JavaScript methods available, which you can call and fill with information, to allow our TagManager to render the correct AdTags to your website. See “Publisher Api” further below for a list of available methods.

In order to fill the functions with content, we will provide a file detailing the marketing structure of your website in table form. You should have received this with the same e-mail as your documentation, or you may request this table from your Ströer Partner Manager.

PublisherApi
Anchor
interfacetabelle
interfacetabelle


Calling these methods should always be wrapped inside a JavaScript “command queue”, please use the namespace “window.SDG.cmd”.
This will allow you to send commands, even if “metaTag.min.js” file is not fully loaded yet.

Code Block
<script>
  window.SDG = window.SDG || {};
  window.SDG.cmd = window.SDG.cmd || [];
  window.SDG.cmd.push(function() {
      SDG.Publisher.setZone('homepage')
      SDG.Publisher.setPageType('rubrik')
  })
</script>

SDG.Publisher.setZonezone )

Sets the zone for all ad slots of the HTML page to the same indicated value.

SDG.Publisher.addKeywordskeyWords )

Transfers multiple words to the ad server for which specific advertising media can be booked.

SDG.Publisher.addKeywordkeyWord )

Transfers a word in the form of a string, for which specific advertising media can be booked, to the ad server.

SDG.Publisher.removeKeywordskeyWords )

Removes multiple previously added “keywords”.

SDG.Publisher.removeKeywordkeyWord )

Removes a single previously added “keyword”.

SDG.Publisher.addKeyValuekey, value )

Transfers a key and a single value assigned to it to the ad server.

SDG.Publisher.addKeyValueskeyValuesObject )

Transfers a key and multiple values assigned to it.

SDG.Publisher.removeKeyValuekey )

Removes a key and all of the assigned value.

SDG.Publisher.removeKeyValues( keyChain )

Removes multiple keys and all their assigned values.

SDG.Publisher.registerSlotslotName, container )

Creates a new ad slot on the HTML page.

SDG.Publisher.finalizeSlots()

Should be executed as soon as all relevant ad slots of a page have been registered.

SDG.Publisher.unregisterSlotslotName, deleteAdContent )

Removes a specific ad slot from the page.

SDG.Publisher.unregisterAllSlotsdeleteLoadedAds )

Removes all ad slots from the page.

SDG.Publisher.loadSlotslotName )

Requests new advertising media from the ad server for a particular ad slot and displays them on the page.

SDG.Publisher.loadMultipleSlots( slotNames )

Request new ad media from the ad server for a given amount of ad slots and displays them on the page.

SDG.Publisher.loadAllSlotsredoLoadedSlots )

Requests new ad media for all existing ad slots on the page from the ad server and displays them on the page.

SDG.Publisher.generateVastUrlsvastPositions )

Requests VAST-Adtags from the video ad server.

SDG.Publisher.generateVastUrlsPromisevastPositions )

Request VAST-AdTags and return them as a Promise.

SDG.Publisher.setAdServerConsent ( perzonalizedAdsAllowed )

Will notify the tag manager if you, as the Publisher of your website, object to using personalized advertisments on your site.
This can be used if the content of the page (texts, url) will allow to draw privacy sensitive conclussion from the users (ex: illnesses, religious or sexual orientation).

SDG.Publisher.transitionAdvertisements()

Allows “Interstitial” ads to be loaded when the user is navigating the website.


SDG.cmd
Anchor
cmd
cmd

cmd: Array<Function => void>

Reference to MetaTag command queue for asynchronous execution of interface methods.
Will be initalized as an empty JavaScript array, exposing cmd.push with standard Array.push method.

Wrap all your commands send to MetaTag inside a function, pushing it into cmd.

Example

Code Block
<script>
  window.SDG = window.SDG || {};
  window.SDG.cmd = window.SDG.cmd || [];
  window.SDG.cmd.push(function() {
      SDG.Publisher.setZone('homepage')
      SDG.Publisher.setPageType('rubrik')
  })
</script>

> back to method list


SDG.Publisher

Publisher: PublisherApi

Returns a reference to the PublisherApi, containing all interface methods to interact with metaTags gloabl commands, described below.

Returns

  • PublisherApi


SDG.Publisher.setZone( zone )
Anchor
setZone
setZone

setZone(zone: string): boolean

Sets the AdTag Zone for the HTML page.
A zone allows ad systems to differentiate the current section of your website, making it possible to target ad campaigns to one or more specific zones/sections.

For a detailed view, which zones can be used on your website, please consult the “marketing structure” file.

Example

Code Block
languagejs
SDG.Publisher.setZone('homepage');

> back to method list

Argument(s)

  • zone: string - The zone for the matching web site category from the marketing structure provided in table form

Returns

  • boolean - true if successful, otherwise false


SDG.Publisher.addKeywords( keywords )
Anchor
addKeywords
addKeywords

addKeywords(keywords: Array<string>): boolean

Transfers multiple keywords to the ad server. These can be used to describe the content of a website. Be it keywords for optimizing the search engine, or specific information contained in your site (such as the ingredients for a recipe displayed on the site).

Note

Please bear in mind that keywords may not contain any special characters, blanks or vowel mutations and must be completely written in lower-case letters.
Vowel mutations have to be changed into ae, ue and oe and blanks and special characters into underscores.

Example

Code Block
languagejs
SDG.Publisher.addKeywords(['auto','auto_news','naesse','reifen']);

> back to method list

Argument(s)

  • keywords: Array<string> -  An array in which keywords are arranged one after the other in the form of a string, separated by commas. It can consist of 15 words maximum.

Returns

  • boolean - true if successful, otherwise false


SDG.Publisher.addKeyword( keyword )
Anchor
addKeyword
addKeyword

addKeyword(keyword: string): boolean

Transfers a single keyword to the ad server.

Note

Please bear in mind that keywords may not contain any special characters, blanks or vowel mutations and must be completely written in lower-case letters.
Vowel mutations have to be changed into ae, ue and oe and blanks and special characters into underscores.

Example

Code Block
SDG.Publisher.addKeyword('autobahn');

> back to method list

Argument(s)

  • keyword: string =  The keyword to be transferred.

Returns

  • boolean -  true if successful, otherwise false


SDG.Publisher.removeKeywords( keywords )
Anchor
removeKeywords
removeKeywords

removeKeywords(keyword: Array<string>): boolean

Removes multiple previously added keywords. Useful in Single-page-applications, where the content (and its descriptive keywords) change on user navigation.

Example

Code Block
languagejs
SDG.Publisher.removeKeywords(['auto','auto_news','naesse','reifen'])

> back to method list

Argument(s)

  • keywords: Array<string> -   Array in which the keywords are arranged one after the other in the form of a string, separated by commas. It can consist of 15 words maximum.

Returns

  • boolean -  true if successful, otherwise false


SDG.Publisher.removeKeyword( keyword )
Anchor
removeKeyword
removeKeyword

removeKeyword(keyword: string): boolean

Removes a single previously added keyword.

Example

Code Block
languagejs
SDG.Publisher.removeKeyword('autobahn')

> back to method list

Argument(s)

  • keyword: string - The keyword to be deleted.

Returns

  • boolean -  true if successful, otherwise false


SDG.Publisher.addKeyValue( key, value )
Anchor
addKeyValue
addKeyValue

addKeyValue(key: string, value: string): boolean

Transfers a pair of parameters consisting of a key and a value to the ad server.
You can use so-called “key values” to transfer further information to the ad server.

These can be data referring to the website or to the user, such as the interests of the user or the location of a request for a weather forecast.

Please consult your Partner Manager before using this function. The data to be used should be coordinated before the implementation, and should be in conformity with current data protection laws.

Note

Please note that keys and values may not contain any special characters, blanks or vowel mutations and must be completely written in lower-case letters.
Vowel mutations have to be changed into ae, ue and oe and blanks and special characters into underscores.

Example

Code Block
languagejs
SDG.Publisher.addKeyValue('stadt','hamburg')

> back to method list

Argument(s)

  • key: string - The key to be transferred.

  • value: string - The value to be transferred for the keyword

Returns

  • boolean -  true if successful, otherwise false


SDG.Publisher.addKeyValues( keyValues )
Anchor
addKeyValues
addKeyValues

addKeyValues(keyValues: Object<string, string[]>): boolean

Transfers a pair of parameters to the ad server which consists of a key and multiple words surrounded by a JavaScript Literal-Object. The values are arranged in a sequence in an array and separated by commas. A maximum of 15 values can be transferred at a time.
You can use so-called “key values” to transfer further information to the ad server. These can be data referring to the website or to the user, such as the interests of the user or the location of a request for a weather forecast.

Note

Please consult your Ströer representative before using this function. The data to be used should be coordinated before the implementation and should be in conformity with data protection laws of your country and the country of your users.

Note that the keys and values may not contain any special characters, blanks or vowel mutations and must be completely written in lower-case letters.
Vowel mutations have to be changed into ae, ue and oe and blanks and special characters into underscores before the transfer.

Example

Code Block
SDG.Publisher.addKeyValues({ 'interessen': ['finanzen', 'autosport', 'mode', 'kosmetika'] })

> back to method list

Argument(s)

  • keyValues: Object<string, string[]> - An object of keys consisting of arrays, each containing multiple values as string

Returns

  • boolean -  true if successful, otherwise false


SDG.Publisher.removeKeyValue( key )
Anchor
removeKeyValue
removeKeyValue

removeKeyValue(key: string): boolean

Removes a previously added key and all its assigned values.

Example

Code Block
languagejs
SDG.Publisher.removeKeyValue('age')

> back to method list

Argument(s)

  • key: string -  The key to be removed.

Returns

  • boolean -  true if successful, otherwise false


SDG.Publisher.removeKeyValues( keyChain )
Anchor
removeKeyValues
removeKeyValues

removeKeyValues(keyChain: Array<string>): boolean

Removes multiple previously added keys and all of their assigned values.

Example

Code Block
SDG.Publisher.removeKeyValues(['age', 'interests', 'segments'])

> back to method list

Argument(s)

  • keyChain: Array<string> - A chain of key names as array

Returns

  • boolean -  true if successful, otherwise false


SDG.Publisher.registerSlot( slotname, container )
Anchor
registerSlot
registerSlot

registerSlot(slotname: string, container: string | HTMLElement): PublisherSlotApi | null

Creates a new ad slot in the container indicated.

The container can be any HTML element capable of accepting multiple further child elements. For the best results, <div> elements are recommended as containers.
When executing the method registerSlot, the container does not have to be rendered fully by the browser.

In the section Integration of the different advertising formats, we have provided a summary of the best practice for creating the different containers dependent on the advertising format.

Tip

We recommend to register the slots as early as possible, ideally in the <head> of the site. In this case, the container of the ad slot might not been fully loaded/rendered by the browser. Instead of passing the container as DOM-Node, you can also pass the "ID" of the future container as string. Please make implicitly sure that the "ID" passed is correct and will be used at some point in the page. Otherwise errors might occur in the page.

Note

An ad slot can only be registered once per HTML page. Example: If the ad slot with the Name “mrec” has already been registered, the same name cannot be registered a second time.
Should you need multiple advertising media of the same advertising format on you site, we can provide you with additional ad slots (such as "rectangle2", “rectangle3”, and so on).

Please consult the marketing structure available to you for your website. There you will find all available ad slot names for the categories existing in your website. Not all slot names are available in each category.

This method only serves to register the slot with the system. To enable the slot to start requesting an advertising medium from the ad server afterwards, please use the slot methods or the Publisher methods loadSlot() and loadAllSlots().

Example

Code Block
SDG.Publisher.registerSlot('banner', 'myBannerContainerId');
SDG.Publisher.registerSlot('sky', document.getElementById('mySkyContainerId'));
SDG.Publisher.registerSlot('rectangle', document.querySelector('.myCssClass'));

> back to method list

Argument(s)

  • slotname: string - The name for the desired slot

  • container: string | HTMLElement - The container for the slot either as string of its "ID" attribute, or as a DOM node (such as using document.getElementById(), document.querySelector(), etc.)

Returns

  • PublisherSlotApi | null = If successful, this method will return an interface object, allowing further interaction with the created AdSlot, called PublisherSlotAPI.
    In case of an error, the return value will be null.


SDG.Publisher.finalizeSlots()
Anchor
finalizeSlots
finalizeSlots

finalizeSlots(): void

Will signal the system that all relevant ad slots for the HTML page have been registered.

Tip

Please make absolutely sure to execute this method after registering your initial AdSlots.

The system will prepare all registered slots and bundle them for the request to the ad server and collect data concerning the page environment and user data. This will enhance load performance of your website and ensures that all slots are known to connected ad systems.

You can register additional slots, even after executing finalizeSlots(). Additional slots will execute their ad delivery as soon as they receive a load command.

Example

Code Block
SDG.Publisher.registerSlot('banner', 'myBannerContainer').load()
SDG.Publisher.registerSlot('sky', 'mySkyContainer').load()
SDG.Publisher.registerSlot('rectangle', 'myRectangleContainer').load()
SDG.Publisher.finalizeSlots()

> back to method list

Argument(s)

  • no further arguments needed

Returns

  • no return value


SDG.Publisher.unregisterSlot( slotName, deleteAdContent )
Anchor
unregisterSlot
unregisterSlot

unregisterSlot(slotName: string, deleteAdContent: boolean): boolean

Deletes a specific ad slot from the page. On request, the method will also delete all advertising media loaded by the slot up to that point.
This will free up the ad slot, making it available for re-registering if needed.

Example

Code Block
SDG.Publisher.unregisterSlot('sky', true);

> back to method list

Argument(s)

  • slotname: string - The name for the desired slot

  • deleteAdContent: boolean - If true, all advertising media already loaded by the slot will be deleted from the page. If false, the advertising media continue to be available. If no value has been entered, the system will use the value "true" by default.

Returns

  • boolean - true if successful, otherwise false


SDG.Publisher.loadSlot( slotName )
Anchor
loadSlot
loadSlot

loadSlot(slotName: string): boolean

Initiates a request to the ad server for a single, previously registered ad slot. This method serves to load an ad slot at a later point in time after registration, for example if the user has interacted with the site and a single slot should display new ads.
When using this method, the ad slot will be loaded independently of all other slots on the page. It might miss additional features like competitor exclusions or lack functionality to display ads spanning over multiple slots.

Example

Code Block
SDG.Publisher.loadSlot('sky');

> back to method list

Argument(s)

  • slotname: string - The name for the desired slot

Returns

  • boolean - true if successful, otherwise false


SDG.Publisher.loadMultipleSlots( slotNames )
Anchor
loadMultipleSlots
loadMultipleSlots

loadMultipleSlots(slotNames: Array<string>): boolean

Initiates request to the ad server for all stated and registered ad slots. You can use this method to load ad slots at a later point in time after registration. For example, if the user has interacted with the site and multiple slot should display new ads.

All slots loaded via this method will act together. They can use additional features like competitor exclusions or use functionality to display ads spanning over multiple slots.
The order of the slotnames inside the array has a direct influence on the load sequence of the slots. Please make sure to consider our "Guidelines for integrating advertising spaces" and the recommended load sequence within.

Example

Code Block
SDG.Publisher.loadMultipleSlots(['banner', 'sky', 'rectangle']);

> back to method list

Argument(s)

  • slotnames: Array<String> - The names of the ad slots to load. The order of the names is relevant (look above).

Returns

  • boolean - true if successful, otherwise false


SDG.Publisher.loadAllSlots( redoLoadedSlots )
Anchor
loadAllSlots
loadAllSlots

loadAllSlots(redoLoadedSlots: boolean): boolean

Initiates a request to the ad server for all hitherto registered ad slots. This method serves to load all ad slots at a later point in time after registration, for example in SinglePage Webapplications, as soon as the user is provided with new content.

This method will automatically load the slots in correct sequence and lets all slots act together. Additional features like competitor exclusions and the ability to display ads spanning over multiple slots are provided.

Example

Code Block
SDG.Publisher.loadAllSlots(true);

> back to method list

Argument(s)

  • redoLoadedSlots: boolean -  If true, all ad slots will be loaded, even if they have already been loaded previously. Already existing advertising media will be deleted from the page and new ones will be delivered by the ad server. Will be automatically assigned the value “false” by default.

Returns

  • boolean- true if successful, otherwise false


SDG.Publisher.generateVastUrls( vastPositions )
Anchor
generateVastUrls
generateVastUrls

This method returns a JSON formatted object, containing a VAST-Adtag for each requested video ad format.

Info

VAST (short for Video AdServing Template) is a XML based interface between a video player and ad servers.
Video players that support VAST can process and display a variety of video formats.
For each format the video player needs a different URL, which will be provided by this method.

Parts of these URLs are created dynamically and for each user differently, therefor resulting in time-consuming developments in your Content/Video Management System.
Instead, Metatag will create these URLs and provide them on run-time for your website.

Call this method once you know that the video player should deliver an advertisement.
The URLs that get returned from this method can be passed directly to your video player. Please see the documentation of your video player on how to pass VAST URLs on run-time.

Here you will find example documentations for the most used VAST-components or publically available players. Your video player might differ, please contact your player provider in case of questions or problems.
Google IMA SDK: https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side#6.-initialize-the-adsloader-and-make-an-ads-request
JW Player: https://developer.jwplayer.com/jwplayer/docs/jw8-schedule-vast-ads#section-add-multiple-ad-breaks-to-a-player

Note

Please do not insert the returned URLs statically in your CMS/VMS. All VAST-URLs generated are coined to the current visitor of your webpage and will differ from user to user.

Example

Code Block
languagejs
SDG.Publisher.generateVastUrls({"preroll":true,"midroll":true,"postroll":true,"videozone":"news-contentPartnerA"}

returns 
{
  "preroll": "https://vastURL.adserver.de?format=preroll&userid=1234&zone=news-contentPartnerA",
  "midroll": "https://vastURL.adserver.de?format=midroll&userid=1234&zone=news-contentPartnerA",
  "postroll": "https://vastURL.adserver.de?format=postroll&userid=1234&zone=news-contentPartnerA",
}

If you like to test your video player with an PreRoll ad, you can call the generateVastUrls() method with these arguments:

Code Block
SDG.Publisher.generateVastUrls({'preroll':true,'videozone':'test'})

> back to method list

Additional Types

  • videoFormats: "preroll" | "midroll" | "postroll" | "overlay" - video format name, for which a VAST URL can be requested.

  • videoZone: string - dependend on the zone, different VAST URLs can be generated. Used to differentiate sections of your website from each other and to allow campaigns to deliver only on specific sections.

Argument(s)

  • vastPositions: Record<videoFormats: boolean>, videoZone - The formats you wish to get VAST-adtags for. Every entry within the object is optional. Each entry that gets passed through this method will return a value. If a format does not get passed in the argument, there will be no return value.

Code Block
languagejs
{
    "preroll": true //(Boolean) set this value if you would like a URL for the "Preroll" format
    "midroll": true //(Boolean) returns a URL for the "MidRoll" format 
    "postroll": true //(Boolean)returns a URL for the "PostRoll" format
    "overlay": true //(Boolean) returns a URL for the "Overlay" format
    "videozone": "myZone" //(String) Overwrites the current Zone only for the video formats from the already set zone (check setZone() for more information) in case the zone from the video format needs to differ from the
									 pages current zone.
}

Returns

  • object - Returns a JSON formatted object with the position names as values and the corresponding VAST-adTag as keys which were passed within the argument.

    Code Block
    {
        "preroll": "https://vastURL.adserver.de?format=preroll&userid=1234&zone=news-contentPartnerA",
        "midroll": "https://vastURL.adserver.de?format=midroll&userid=1234&zone=news-contentPartnerA",
        "postroll": "https://vastURL.adserver.de?format=postroll&userid=1234&zone=news-contentPartnerA",
    }

SDG.Publisher.generateVastUrlsPromise( vastPositions )
Anchor
generateVastUrlsPromise
generateVastUrlsPromise

Returns a Promise resolving into a JSON formatted object, containing a VAST-Adtag for each requested video ad format.
To learn about the way promises work and how you can use them, we advise you to read Using promises first.

A common good practice for displaying a video player with ads:

  • Insert your video player in the website and let it render.

  • Disable autoplay, so the user needs to start the video player by clicking on a “start” button.

  • As soon as user wants to start video, use generateVastUrlsPromise()

  • When Promise resolves, use returned VAST Urls and configure your video player accordingly.

    • Please see the documentation of your video player on how to pass VAST URLs on run-time.

This Promise will never reject, making it necessary to implement a fallback. Otherwise, your player might wait indefinitely for the Promise to settle.

Examples

Code Block
languagejs
//Example 1: get VAST-Urls without a fallback
const vastUrls = await SDG.Publisher.generateVastUrlsPromise({ 'preroll': true, 'midroll': true, 'postroll': true, 'videozone': 'news-contentPartnerA' })

returns 
{
  "preroll": "https://vastURL.adserver.de?format=preroll&userid=1234&zone=news-contentPartnerA",
  "midroll": "https://vastURL.adserver.de?format=midroll&userid=1234&zone=news-contentPartnerA",
  "postroll": "https://vastURL.adserver.de?format=postroll&userid=1234&zone=news-contentPartnerA",
}



//Example 2: get VAST-Urls with a fallback. If Urls are not returned after 1000 millisecond, proceed with control flow and log an error
await Promise.race([
    SDG.Publisher.generateVastUrlsPromise({ 'preroll': true, 'midroll': true, 'postroll': true, 'videozone': 'news-contentPartnerA' }),
    new Promise((resolve, reject) => setTimeout(reject, 1000))
])
.then(vastUrlsObject => configureYourVideoPlayer(vastUrlsObject))
.catch(() => console.log('no VAST-Urls after 1000 ms'))

If you like to test your video player with an PreRoll ad, you can call the generateVastUrlsPromise() method with these arguments:

Code Block
SDG.Publisher.generateVastUrls({'preroll':true,'videozone':'test'})

> back to method list

Additional Types

  • videoFormats: "preroll" | "midroll" | "postroll" | "overlay" - video format name, for which a VAST URL can be requested.

  • videoZone: string - dependend on the zone, different VAST URLs can be generated. Used to differentiate sections of your website from each other and to allow campaigns to deliver only on specific sections.

Argument(s)

  • vastPositions: Record<videoFormats: boolean>, videoZone - The formats you wish to get VAST-adtags for. Every entry within the object is optional. Each entry that gets passed through this method will return a value. If a format does not get passed in the argument, there will be no return value.

Code Block
languagejs
{
    "preroll": true //(Boolean) set this value if you would like a URL for the "Preroll" format
    "midroll": true //(Boolean) returns a URL for the "MidRoll" format 
    "postroll": true //(Boolean)returns a URL for the "PostRoll" format
    "overlay": true //(Boolean) returns a URL for the "Overlay" format
    "videozone": "myZone" //(String) Overwrites the current Zone only for the video formats from the already set zone (check setZone() for more information) in case the zone from the video format needs to differ from the
									 pages current zone.
}

Returns

  • Promise<object> - Returns a JSON formatted object with the position names as values and the corresponding VAST-adTag as keys which were passed within the argument.

    Code Block
    {
        "preroll": "https://vastURL.adserver.de?format=preroll&userid=1234&zone=news-contentPartnerA",
        "midroll": "https://vastURL.adserver.de?format=midroll&userid=1234&zone=news-contentPartnerA",
        "postroll": "https://vastURL.adserver.de?format=postroll&userid=1234&zone=news-contentPartnerA",
    }

SDG.Publisher.setAdServerConsent( personalizedAdsAllowed )
Anchor
setAdServerConsent
setAdServerConsent

setAdserverConsent(personalizedAdsAllowed: boolean): void

Will notify the tag manager if, as the Publisher of your website, you reject the usage of personalized user data in the delivery process of advertisements. As a default, we assume your permission.

Site visitors can allow the usage of personalized data on your site through a Consent Management Platform (CMP). However, you as the publisher can digress from this decision and mark the content of the page as especially relevant for protection of data privacy and explicitly forbid the usage of personalized data.

This can be useful if the content of your site (texts, URL, etc.) allows to drawing privacy-sensitive conclusion from the visitor (ex: illnesses, religious or sexual orientation).
While the visit of a user to such content will never be directly or permanently linked to the profile of the user, visited URLs and content keywords might be used in the selection of personalized ads as long as the user visits the page.

Note

If you wish to object to personalized ads, please execute this method as your very first command to the tag manager.

Example

Code Block
SDG.Publisher.setAdServerConsent(false)

> back to method list

Argument(s)

  • personalizedAdsAllowed: boolean - Use false if you want to object to personalized ads

Returns

  • no return value


SDG.Publisher.transitionAdvertisements()
Anchor
transitionAdvertisements
transitionAdvertisements

transitionAdvertisements(): boolean

This enables interstitial advertisement to be displayed on both mobile and desktop environments depending on user device type.

Example

Code Block
SDG.Publisher.registerSlot('banner', 'myBannerContainer').load()
SDG.Publisher.registerSlot('sky', 'mySkyContainer').load()
SDG.Publisher.registerSlot('rectangle', 'myRectangleContainer').load()
SDG.Publisher.transitionAdvertisements();
SDG.Publisher.finalizeSlots()

> back to method list

Argument(s)

  • no further arguments needed

Returns

  • boolean - true if successful, otherwise false

Example for a complete configuration
Anchor
examplecompleteconfiguration
examplecompleteconfiguration


In this example, three ad slots "banner", "sky" and "mrec" will be registered directly in the <head> of the page, after all relevant site parameters have been configured.
We know these ad slots should always be loaded, no matter how the user interacts with the site. Therefor, we execute the finalizeSlot() method as soon as all "save" ad slots are registered. During registration, we mark all ad slots for loading, via .load(). Slots will only be loaded as soon as their respective containers are rendered by the browser. The ads will not interfere with the loading of the site, since all slots are loaded "asynchronous", meaning parallel, to the site.

The user has furthermore the possibility to load further content, if he clicks on the site. This content should also include ads, but it might happen that the content is never loaded by the user. It makes no sense to send the content (as well as the ads) to the user, as long as he/she does not wish so. Suitably, we only register the 4th slot "posterad", after the user has clicked the content.

Additionally, the ads should be reloaded after 60 seconds. This would never be done in a live environment, but illustrates the use of the Publisher.loadAllSlots() method for this example.

Example for a complete configuration
Code Block
languagehtml
<!DOCTYPE html>
<html>
<head>
    <!-- library at the end of <head> -->
    <script>
        window.SDG = window.SDG || {};
        window.SDG.cmd = window.SDG.cmd || [];
        window.SDG.cmd.push(function() {
            SDG.Publisher.setZone('beauty');
            SDG.Publisher.addKeywords(['auto','auto_news','naesse','reifen']);
            SDG.Publisher.addKeyValue('gender', 'woman');
            SDG.Publisher.addKeyValues({ 'interest' : ['finance', 'automotive', 'fashion'] });
            SDG.Publisher.registerSlot('banner', 'headerBeforeNavigation').load();
            SDG.Publisher.registerSlot('rectangle', 'adInContent').load();
            SDG.Publisher.registerSlot('sky', 'adInSidebar').load();
            SDG.Publisher.transitionAdvertisements();
            SDG.Publisher.finalizeSlots();
        });
    </script>
    <script src="http://cdn.stroeerdigitalgroup.de/metatag/live/beispielseite/metaTag.min.js" type="text/javascript"></script>
</head>
<body>
<div id="contentWrapper">
    <div id="headerBeforeNavigation"> <!-- "banner" slot will be displayed here -->
        
    </div>
    <nav>Navigation</nav>
    <main id="mainContent" class="contentWidth floatsLeft">
        Content<br>
        Content<br>
        <div id="adInContent"> <!-- "rectangle" slot will be displayed here -->
            
        </div>
		Content<br>
		Content<br>
		Content which will be loaded on user interactive (scrolling, click, etc) <br>
		<div id="adInAsynchronContent" onclick="showContentAndAds"> <!-- "posterad" slot will be displayed here -->

		</div>
    </main>
    <aside class="sidebar floatsRight">
        <div id="adInSidebar"> <!-- "sky" slot will be displayed here -->
            
        </div>
    </aside>
</div>
<script type="text/javascript">
    //This function registers and loads the adlot "posterad", as soon as the user has loaded additional content successfully.
	function showContentAndAds() {
		loadAsychronContent().set('isContentLoaded', true);
		
		if(isContentLoaded){
			window.SDG.cmd.push(function() {
                SDG.Publisher.registerSlot('posterad', document.getElementById('adInAsynchronContent')).load()
            });
		}
	}

	//after 60 seconds all ad slots will be loaded anew. Since all slots were already loaded once, we pass true as argument.
	window.setTimeout(function() {
			window.SDG.cmd.push(function() {
                SDG.Publisher.loadAllSlots(true)
            });
	},60000);
</script>
</body>
</html>

PublisherSlotApi
Anchor
slotmethods
slotmethods


These methods are available to you for all registered ad slots.

Slot.load()

Will start the call to the ad server for this specific ad slot.

Slot.setTargetingobject )

Passes a given key and its value/s just to this ad slot.

Slot.blockFormats( formatList )

Excludes an amount of formats from this ad slot.

Slot.configure( configObject )

Change settings for this ad slot.

Slot.nativeBackfill( fallbackAd )

Will render an advertisement when no ad is returned from the adserver

You can combine or “chain” methods with each other:

Code Block
SDG.Publisher.registerSlot('sky', 'mySkyContainer')
.setTargeting({'interesse': ['sport','finanzen']})
.load()

All methods will return the “Slot” object itself, which in turn can be saved as a variable, so you can easily access the ad slot later on.

Code Block
var mySlotvar = SDG.Publisher.registerSlot('sky', 'mySkyContainer');
mySlotVar.setTargeting({'interesse': ['sport','finanzen']}).load();

Slot.load()
Anchor
Slotload
Slotload

load(): AdSlotClass

Initiates a request to the ad server for a single ad slot, as soon as the container of the slot is rendered by the browser. The purpose of this method is to mark the ad slot for loading directly upon registration.

You don't have to send any further commands for the slot to load. It will automatically monitor the page and only send the request to the ad server as soon as the container becomes available. If the container is already present on the site, the slot will start the request at once. Therfore, you can use this method already in the <head> of the page. Neither the slot will be loaded (until the container is available), nor the site be influenced negatively.

Should you want to load the slot again, for example because the content of the site was changed and, the user should receive new ads, you can use the PublisherApi methods loadMultipleSlots() or loadAllSlots().

Example

Code Block
SDG.Publisher.registerSlot('sky', 'mySkyContainer').load()

> back to method list

Argument(s)

  • no arguments required

Returns

  • AdSlotClass- The ad slot for calling up further methods of the slot


Slot.setTargeting( keyValues )
Anchor
SlotsetTargeting
SlotsetTargeting

setTargeting(keyValues: Object<string, string[]>): AdSlotClass

Transfers a pair of parameters to the ad slot which consists of a key and multiple words bracketed by a JavaScript Literal-Object. The values are arranged in sequence in an array and separated by commas. A maximum of 15 values can be transferred at a time.

You can use so-called “key values” to transfer further information to the ad server. These can be data referring to the website or to the user, such as the interests of the user or the location of a request for a weather forecast.
As opposed to the method Publisher.addKeyValues() the pair is only transferred to the respective slot.

Info

Please consult your Ströer representative before using this function. The data to be used should be coordinated before the implementation and should be in conformity with data protection laws of your country and the country of your users.

Note that the keys and values may not contain any special characters, blanks or vowel mutations and must be completely written in lower-case letters. Vowel mutations have to be changed into ae, ue and oe and blanks and special characters into underscores before the transfer.

Example

Code Block
SDG.Publisher.registerSlot('sky', document.getElementById('mySkyContainer')).setTargeting({'technicalData': ['fotoshow','stickyEnabled']})

> back to method list

Arguments(s)

  • keyValues: Object<string, string[]>- An object consisting of multiple keys as arrays, each containing multiple values as string

Returns

  • AdSlotClass- The ad slot for calling up further methods of the slot


Slot.removeTargeting ( key, value )
Anchor
SlotremoveTargeting
SlotremoveTargeting

removeTargeting(key: string, value:string?): AdSlotClass

Removes a key value pair from an ad slot

Should you pass a key and value, only the given value will be removed from the key. Should you pass only a key, without the value argument, the whole key including all values will be deleted.

Example

Code Block
//delete the whole key "interests":
SDG.Publisher.registerSlot('sky', document.getElementById('mySkyContainer')).removeTargeting('interests')
 
//only delete the value "finance" from key "interests":
SDG.Publisher.registerSlot('sky', document.getElementById('mySkyContainer')).removeTargeting('interests','finance')

> back to method list

Argument(s)

  • key: string - the key you like to edit / remove

  • value: string? [optional] - the value that should be removed

Returns

  • AdSlotClass- The ad slot for calling up further methods of the slot


Slot.blockFormats( formatList )
Anchor
Slotblockformats
Slotblockformats

blockFormats(formatList: Array<string>): AdSlotClass

Excludes multiple ad formats from delivering on the current HTML page, only for the used ad slot.

During the initial set up of your website in our system, we will make sure to only serve formats fitting to your website. Therefor, you will only need to block a format, if a given HTML page deviates significantly from your normal website design and the format (otherwise causing no trouble) will not work correctly.

Should you wish a block a format for your whole website for good (for example: after you made some changes to the design of your site) please contact your Ströer representative, so we can exclude the format permanently.

Note

Will only block formats when used before an ad slot is loaded.

Example

Code Block
SDG.Publisher.registerSlot('banner', 'myBannerContainer') 
.blockFormats(['wallpaper', 'advancedfireplace']) //removing formats "Wallpaper" & "Fireplace" from "banner" ad slot
.load()

> back to method list

Argument(s)

  • formatList: Array<String>- An array which contains the to be blocked format names as a string.
    The following format names can be used : 

Expand
titleList of available formats to block (click to expand)

advancedfireplace
banderole
billboard_770
billboard_800
billboard_970
brandbooster
bridgead
cubead
directionad
doubledynamicsitebar
doublehalfpagead
doubleleaderboard
fireplace
flex1x1
flex1x2
flex1x3
flex1x4
flex2x1
flex3x1
flex3x4
flex4x1
flex6x1
flex8x1
flex9x16
flex10x1
floorad
fullframead
halfpagead
intextspot
largeinline
leaderboard
maxiad
mediumrectangle
mobilead2x1
mobilead3x1
mobilead4x1
mobilead6x1
mobilebrandbooster
mobiledirectionad
mobiledockerad
mobileexpandablestickyfooter
mobilehalfpagead
mobilemrec
mobilepresenter2x1
mobilepresenter3x1
mobilepresenter4x1
mobilepresenter6x1
mobilepresentermrec
mobilesitebar
mobilestickyad
posterad
posterad_billboard
qualityfooter
sitebar
skyscraper_120
skyscraper_160
skyscraper_200
stickybillboard
tickeraddisplay
topscroller
wallpaper
videotakeover
videowall

Returns

  • AdSlotClass- The ad slot for calling up further methods of the slot


Slot.configure ( configObject)
Anchor
SlotConfigure
SlotConfigure

configure(configObject: Record <string, number | boolean>): AdSlotClass

Changes how the ad slot behaves on your website. You are able to control features like “Cumulative Layout Shift” avoidance, showing advertisements labels, showing loading animations or how and when to position or load ads inside the slot.

If you do not use this function, default settings from our base configuration are used without any further need to intervene.

Example

Code Block
languagejs
/** As a publisher we want to integrate a slot capable of delivering ads in 728x90 and 800x250.
*   However we do not want to reserve 250px height everytime since 728x90 is more likely to be delivered.
*   To avoid a massive CLS if 800x250 is actually delivered, reserve 150p height.
*
*   We like to indicate to the visitor that this is an advertisement, therefor show an advertisement label.
*
*   We do want to position the ads in the center of the slot, since our content is also centered inside the browser window.
*   Left sided ads look ugly on our site.
* 
*   We like to give the visitor an indication, that some content is still loading, therefor we use loading animations.
* 
*   We like to boost loading performance on our website, therefor the ad slot should load "lazy"
*   and only require resources when the visitor scrolls it into view.
*
*/

const myAdSlot = SDG.Publisher.registerSlot('banner', document.getElementById('myBannerContainer'));
myAdSlot.configure({
	reserveSpace: true,
	fixedHeight: 150,
	showAdvertLabel: true,
	centerAds: true,
	showLoadingAnimation: true,
	lazyLoad: true
}).load()

> back to method list

Argument(s)

  • configObject: Record <string, number | boolean> - All properties of the object are optional. Available options:

    • reserveSpace: boolean - slot will reserve space on the site, to avoid Cumulative Layout Shift (CLS). If no fixedHeight is set, the slot will reserve the largest height of all formats it's capable of.
      For more information on CLS, please see: Avoiding "Layout Shifts"

    • fixedHeight: number - slot will reserve this height on the site, to avoid Cumulative Layout Shift (CLS).

    • showAdvertLabel: boolean - slot will show a label on the site next to the slot, indicating an advertisement to the site visitor. Advertisement labels are shown by default.

    • showLoadingAnimation: boolean- Shows a small loading animation, when slot will reserve space. Animations will help the site visitor to recognize that content is still loading and gaps inside the site will be filled in due time.

    • centerAds: boolean - slot will position all advertisement elements in its center. By default, ads are positioned on the left side of the slot.

    • lazyLoad: boolean - When you send a load command to the slot, it will be delayed until the slot is scrolled into view by site visitor. For more information on lazy loading ad slots, please see: Loading Speed Optimization of Webpages and Advertisements .
      Depending on the website, “lazyLoad” might have significant impact on your advertisement revenue. Please reach out to your Ströer contact before implementing LazyLoad for further information.

    • pinToBottom: boolean - Ads delivered in this slot will be positioned at the bottom of the browser window, scrolling along with the user. A highly visible close button will remove the ad slot when clicked by the user. Mostly used for the mobile ad slot “stickyfooter”.

Returns

  • AdSlotClass- The ad slot for calling up further methods of the slot


Slot.nativeBackfill ( fallbackAd )
Anchor
SlotnativeBackfill
SlotnativeBackfill

nativeBackfill(fallbackAd: Function() => HTMLElement): AdSlotClass

If an ad slot does not receive an advertisement from any ad server, you can pass an “fallback” advertisement to render instead.

Example

Code Block
//with an anonymous function
SDG.Publisher.registerSlot('banner', document.getElementById('myBannerContainer')).nativeBackfill(function() {
  var ad = document.createElement('div');
  ad.style.width = '728px';
  ad.style.height = '90px';
  ad.style.border = '1px solid';
  ad.style.backgroundColor = 'red';
  return ad;
}).load();
 
//with a declared function
function myAd(){
  var ad = document.createElement('div');
  ad.style.width = '728px';
  ad.style.height = '90px';
  ad.style.border = '1px solid';
  ad.style.backgroundColor = 'red';
  return ad;
}
 
SDG.Publisher.registerSlot('banner', document.getElementById('myBannerContainer')).nativeBackfill(myAd).load();

> back to method list

Argument(s)

  • fallbackAd: Function() => HTMLElement - Passed function must return an HTMLElement. The slot will then render the element inside the ad slot, treating it as an advertisement.

Returns

  • AdSlotClass- The ad slot for calling up further methods of the slot

Guidelines for integrating ad slots


In the following guidelines, we will give you a short collection of tips and best practices for handling ad slots.
These guidelines are not compulsory, but they do help to prepare your page or site for the different forms of advertising formats as efficiently as possible.

General guidelines for integrating ad slots

  • An ad slot must always be bracketed by an HTML tag, preferably a <div>, which has been assigned a unique ID value.
    The ID can be chosen freely and can be used in the registerSlot() method.

Note

The tag should not have any further content apart from the script containing the method registerSlot(). Any further content it will be removed when ads are loaded.

Example using the ad slots “banner” and “banner2”

Code Block
languagehtml
<div id="Site_superbanner_pos1">
    <script type="text/javascript">
          SDG.Publisher.registerSlot('banner','Site_superbanner_pos1');
    </script>
</div>
.
.
.
<div id="Site_superbanner_pos2">
    <script type="text/javascript">
          SDG.Publisher.registerSlot('banner2','Site_superbanner_pos2');
    </script>
</div>

  • The HTML tags surrounding the ad slot should in no way hinder the visibility of the advertising material.
    Please avoid CSS attributes such as “overflow:hidden” or “clip:rect()”.

  • When having to position the advertising spaces, please avoid the CSS attribute “text-align” in the directly surrounding HTML tags. The interpretation of this attribute is browser specific and can be different from one browser to the next. Particularly in special advertising forms such as Wallpaper or Fireplace, imprecise positioning can lead to errors. As contrasted with that, the CSS attributes “position:relative”, “left” and “top” are implemented in exactly the same way in all browsers.

  • If you want to mark your advertising spaces with the label “Anzeige”, we can do this for you. The label can, in general, be freely designed and be seamlessly integrated into the rest of your typographical and color design.
    Please send us a sample design for the label, together with the desired CSS rules. If you do not want to use a self-designed label, we can employ a standard label for all ad slots inserted automatically.

  • In order to ensure a clean delivery of special advertising forms which are delivered via multiple advertising spaces at the same time, the three slots “banner”, “sky” and “out_of_page” should be delivered in a fixed sequence. Before, between or after these three types of ad slots it is possible to integrate additional ad slots without further difficulties as long as the sequence of these three locations is not changed.

    Code Block
    languagejs
    //first "banner" is registered, afterwards "sky", finally "out_of_page". Other slots can be inserted at will.
    SDG.Publisher.registerSlot('banner','myBannerContainer');
    SDG.Publisher.registerSlot('banner2','myBanner2Container');
    SDG.Publisher.registerSlot('banner3','myBanner3Container');
    SDG.Publisher.registerSlot('sky','mySkyContainer');
    SDG.Publisher.registerSlot('rectangle','myRectangleContainer');
    SDG.Publisher.registerSlot('out_of_page','myOOPContainer');

Guidelines for integrating specific ad slots

“banner” Ad Slot

Info

The “banner” or Leaderboard is the most frequently used ad slot for realizing large special formats and is often used in connection with other slots in order to serve and position large formats correctly on the page.
For that reason, it is important that the Leaderboard never changes its position and always remains in the same place, even if parts of the design of some HTML pages within the website differ from each other (such as the difference between the start pages and the article pages).

In case of centered pages or so-called “responsive design” pages, in which the width of the page or the distance between the left margin of the content and the left margin of the browser window changes depending on the screen resolution set by the user, you should make sure that the distance between the left margin of the Superbanner and the right margin of the content always remains the same.

The following example shows a solution for this problem using the Hockeystick/Wallpaper format for visualization. This format wraps around the outer upper and right margins of the content of the page and as such can easily collide with the content of the page in responsible web pages.
In order to avoid this, we have the browser calculate the most favorable position for the slot automatically, while at the same time setting fixed distances in order to make the positioning, albeit dynamic, always clearly predictable at the same time.

For this purpose, we will always leave a 300 pixel margin on the right-hand side of the content, while at the same time still allowing the Skyscraper slot to deliver all formats.
To emphasize this, the most important CSS rules have been written inline, directly to the elements, while the less important rules have been relegated to <style> tags.

Example: Hockeystick, left-justified
Code Block
languagehtml
<!DOCTYPE html>
<body>
<style>
    #contentWrapper{background-color:yellow;height:800px;margin:auto;}
    #leaderboard {background-color:red;width:728px;height:90px;}
    #Hockeystick_1 {width:728px;height:90px;left:0px;background-color:orange;position:absolute;}
    #Hockeystick_2 {width:120px;height:600px;background-color:orange;left:728px;position:absolute;}
    #Content {height:500px;background-color:lightgreen;}
</style>
<div id="contentWrapper" style="min-width:1038px;"><!--min-Width is calculated from the minimal content width (here 728) plus right gap (310)-->
    <div id="leaderboard" style="position:relative;margin:0px 300px 0px auto;">
        <div id="Hockeystick_1">Hockeystick</div>
        <div id="Hockeystick_2" style="">Hockeystick</div>
    </div>
    <div id="Content" style="margin:10px 310px 0px 0px; ">Content</div>
</div>
</body>
</html>

“sky” Ad Slot

Info

The “Skyscraper” advertising space is often used to deliver special formats with very high widths.

Some formats, such as the “Dynamic Sidebar”, for instance, reserve the complete space between the left beginning of the skyscraper and the right browser margin. When integrating the Skyscraper it is therefore advisable to avoid the use of the attribute “float” in the surrounding HTML tags. This attribute positions elements in keeping with their height and width depending on the rest of the page and can result in the Skyscraper not being displayed on the right-hand side of the content anymore from a certain value onwards. This problem, however, is strongly related to the structure of the website and does not have to occur every time the attribute “float” is used.

“rectangle” Ad Slot

The ad slot “rectangle” is usually filled with advertising media from 300 x 250 up to 300 x 600 pixels.
To realize this, please ensure that the ad slot embedded within the content, is able to change its height dynamically without covering up the surrounding content or otherwise rendering it illegible.

“stickyfooter” Ad Slot

The “stickyfooter” ad slot is a mobile slot, in which small mobile formats (often 320x50 or 320x100 pixel) are rendered at the bottom corner of the users browser. Ads will scroll along with the user, and are permanently visible. The user can close the format via a small button.
When integrating this slot, please pass the “pinToBottom” option in the Slot.configure() method. The sticky effect as well as the close button will be delivered automatically, no further set up is required.

Code Block
SDG.Publisher.registerSlot('stickyfooter','myStickyFooterContainer')
.configure({pinToBottom: true})
.load();

Event System
Anchor
eventsystem
eventsystem

MetaTag has its own set of JavaScript-Events which can be listened to over the JavScript method “addEventListener”. The system differentiates between two types of events:

  • system events

  • slot events

System Events

All system events use the "window" object, in where the metatag library is implemented under, as the "eventTarget".
Each event passes information about itself within the first argument given within the listener method.

Example for a system event:

Code Block
languagejs
window.addEventListener('metaTagSystemBeforeLoadAll', function (eventObject) {
    console.log('system Event "metaTagSystemBeforeLoadAll", event information can be found here %o',eventObject)
});

Available events on the window object:

Event

Description

metaTagSystemBeforeLoadAll

Gets triggered before the first call from an ad slot is send to the ad server.

metaTagSystemContentLoaded

Gets triggered once the event DOMContentLoaded has fired

metaTagSystemAdServerModuleLoaded

Gets triggered once MetaTag has decided which ad server to use on the website.

metaTagSystemContentElementLoaded

Gets triggered when an Element has been found on the page which measurements coincide with the width and height of the content. Some formats do not start loading until this event has been fired.

metaTagSystemPrebidResponded

Gets triggered once all real time auctions have finished from the open source solution "Prebid". Prebid is not active on all websites

metaTagSystemZoneSet

Gets triggered once our interface method setZone() has been completed

metaTagSystemPageTypeSet

Gets triggered once our interface method setPageType() has been completed

metaTagSystemSlotRegistered

Gets triggered as soon as an ad slot is registered. This event contains general information for the ad slots. For more specific information about an ad slot please use the slot events

metaTagSystemSlotDeleted

Gets triggered as soon as an ad slot is deleted or unregistered. This event contains general information for the ad slots.
For more specific information about an ad slot please use the slot events

metaTagSystemSlotPrepared

Gets triggered once an ad slot has received all information needed to start a call to the ad server.
This event contains general information for the ad metaTagSystemSlotCallingslots. For more specific information about an ad slot please use the slot events

metaTagSystemSlotCalling

Gets triggered once an ad slot starts a call to the ad server. This event contains general information for the ad slots.
For more specific information about an ad slot please use the slot events.

metaTagSystemSlotResponded

Gets triggered once an ad slot receives an answer from the ad server. This event contains general information for the ad slots.
For more specific information about an ad slot please use the slot events.

metaTagSystemSlotDone

Gets triggered once an ad slot has received an answer from the ad server and the slot has finished rendering an advertisement. This event contains general information for the ad slots. For more specific information about an ad slot please use the slot events.

metaTagSystemSlotEmpty

Gets triggered once an ad slot receives an answer from the ad server that no advertisement is available.
This event will not necessarilly fire consistently. It can depend on if the impression gets passed to another system from our original system. The 3rd system might deliver an empty repsonse but not pass it on to us.

metaTagSystemCmpConsentAvailable

Gets triggered once the user has set his/her consent for all vendors (IAB/Non IAB). At this point in the systems process you are able to get the consent information pro vendor from our publisher interface methods: SDG.Publisher.getIABVendorConsent() or SDG.Publisher.getCustomVendorConsent().
This event only gets fired once per page impression even if a user changes his consent while on the page.
(for example by opening the privacy manager)

metaTagSystemCmpChoiceUiShown

This event signals that the user is being shown a message layer from the consent manager. This layer covers most of the elements from the webpage. It is encouraged that
certain load processes from the website, which are not initially essential, only load once the user can see/interact with them. In the case that a vendor relies on legitimate interest (some vendors are essential for the use of a website), this vendor will be classified as 'allowed' at this point.
Keep in mind that the user has the possibility to decline his/her consent for legitimate interest.
Once the message gets accepted or closes, the event: metaTagSystemCmpChoiceSelected gets fired.

metaTagSystemCmpChoiceSelected

Gets triggered once the user has finished interacting with the communication layer of the consent manager platform.
At this point not all the necessary information will be available. In order to listen for the complete available consent information please use the event: metaTagSystemCmpConsentAvailable
Attention: A deprecated version of MetaTag used the event: "metaTagSystemChoiceSelected". This event as the now updated event: metaTagSystemCmpConsentAvailable are still both available

Slot Events

These events use the DOM node in which the ad slot was registered as the "eventTarget".
Aside from the information available about the event itself, additionally you can access information about the ad slot. For this use the first argument given through the listener method.
The data from the ad slot is available in "eventObject.detail". Since the ad slot starts firing multiple events after its registration it is advised to set your listeners before the ad slot gets registered.

Example for a slot event:

Code Block
languagehtml
<div id="mySkySlot"></div> 
  <script> 
    document.getElementById('mySkySlot').addEventListener('metaTagSlotCalling', function (eventObject) { 
        console.log('system Event "metaTagSlotCalling", event information can be found here %o',eventObject); 
        console.log('additionally the name of the ad slot is saved here %o',eventObject.detail.slot);
    }); 
    SDG.Publisher.register('sky', document.getElementById('mySkySlot')).load(); 
  </script>

Available slot events:

Event

Description

metaTagSlotRegistered

The slot beeing listend on has been registerd and is available

metaTagSlotDeleted

The slot beeing listend on has been unregistered/deleted and will not fire any more events.

metaTagSlotCalling

The slot being listened on got the command to load an advertisement and will call the ad server

metaTagSlotResponded

The slot being listened on has received and answer from the ad server, slot has not been rendered yet.

metaTagSlotDone

The slot being listend on has completed its process. It has received an answer from the ad server and the slot has finished rendering an advertisement

metaTagSlotEmpty

The slot being listened on did not receive an advertisement from the ad server. The slot removes itself from the webpage and does not reserve any more space on the page. This event will not necessarily fire consistently.
It can depend on if the impression gets passed to another system from our original system. The 3rd system might deliver an empty response but not pass it on to us.

Additional Features

MetaTag brings a few additional features helping with the day to day handling of ad formats.
If you have any questions concerning which options are available, please consult your Account Manager at Ströer.

Labeling ad slots with "Anzeige" (advertisements)

MetaTag can label your ad slots with the word "Anzeige" (advertisements). This label can be localized to your needs or changed for example into "promotion" if this is preferred.
Ad labels should always be attached and are required under certain circumstances by law.
Per default MetaTag will always deliver ad labels, this can be turned off if you would like to take care of the labeling yourself.
If you wish to change/remove/add these labels, please see the Slot.configure() method

Define local ad slots

For your website you can define your own ad slots (for example: to book your own local advertisements). Please contact us before implementing a local ad slot.
In order to create and register a local ad slot you will need to use a different method than usual.

Code Block
languagejs
SDG.Publisher.registerModularSlot(position, container, width, height, adServerSizes, isMobile, useSubzone)

Method arguments for registerModularSlot()

Code Block
@param {String} position - the self selected name of the new position. This name will be extended with the prefix "local_" by the tag manager, to avoid collision with other ad slots.
If your self selected name is "rectangle", the slot will be registered as "local_rectangle"

@param {String||Object} container - the container of the ad slot, either as ID string or as DOM Node Object if the container already exists
@param {Number} width - the width of the ad slot, how it is rendered on the page
@param {Number} height - the height of the ad slot, how it is rendered on the page
@param {Array.<Array>} adServerSizes - nested array of the adserver sizes used for the new position
@param {Boolean} isMobile - true/false if the slot is a mobile slot
@param {String} useSubzone - the name which an ad slot will use as subZone. Can be used to create an artifical "sub section" for this ad slot (optional)

When accessing the local ad slot at a later time, please make sure to always include the automatically added prefix.

Code Block
SDG.Publisher.registerModularSlot('my-rectangle', 'myContainer', 300, 250, [[300,250]], false)
SDG.Publisher.loadSlot('local_my-rectangle');

MetaTag Video-Ads

MetaTag-Video provides the Publisher with the possibility to easily setup a connection to any video ad server per VAST or VPAID. Formats like "Pre-Roll", "Mid-roll" or "Post-Roll" can be implemented into your video player.
Your video player must support the IAB standard VAST (Video Ad Serving Template). In order to receive VAST URLs from MetaTag, please see the PublisherApi method Publisher.generateVastUrls()

We can gladly discuss an individual integration in your current video system. Questions regarding IAB-Standards, Video formats or popular video-SDK's for desktop or mobile. Feel free to contact your Publisher Account Manager at Ströer.

Lazy Load
Anchor
lazyLoad
lazyLoad

When an ad slot is “lazy loaded”, the slot will contact the Ad Server as soon as you indicate that you like the Ad Slot to load. For example, by using the /wiki/spaces/SDGPUBLIC/pages/51578793 interface. Rendering of the content of the ad slot however, will only start shortly before the user scrolls the ad into view.

Tip

This will help use as little resources as possible on the users devices and might improve the loading performance of your website tremendously.
Secondly, the ad will have a “high visibility rate” since it is only rendered shortly before it comes into view. Advertisers prefer to book placements & campaigns on slots that have a high visibility rate.

Note

An Ad Slot is only eligible for counting towards “guaranteed traffic” if the Ad Slot starts to render. Subsequently, only a rendered ad will be paid for by the advertiser. This feature might have impacts on the revenue of your website. We strongly recommend testing the effect of “Lazy Load” and weight the results against the gains of website load performance and layout shift reduction.

If you are interested in using this feature, please contact your Account Manager at Ströer. We will check the possible impact on your website's revenue and help you discover the best implementation strategies.
You can test and activate lazy loading for an ad slot at any time, using our Slot.configure() method.

Expand
titleScreenshot of lazy loaded ad slots. Click to show.

Avoiding Cumulative Layout Shift
Anchor
layoutShift
layoutShift

So-called “Layout shifts” are, in short, height changes to a website, after the user is interacting with the site.
This might lead to content changing positions while the user reads it, or interactive elements vanishing shortly before the user wanted to interact with them.
Layout shifts will also have a negative impact on Googles “Web Vitals Score” of your website, potentially causing your website being penalized in Googles Search ranking.

Height changes to the content are often introduced by loading large-dimensioned parts of the website asynchronously, for example advertisements.
While loading ads asynchronously helps tremendously with the performance of the website, it introduces many forms of “layout shifts”

  • Ad Slots inside the pages can support multiple, different formats, each with a unique height.
    When loading those Ad Slots, information about the delivered formats and their height are only available after ads are already rendered to the page (causing the shift).

  • Ad Slots can be reloaded during longer sessions. Removing old ads and inserting new ads might lead to different heights being reserved by the Ad Slot.

  • Ad Slots might not deliver an ad on each Page Impressions, because campaigns and advertisements might not be available.
    Nevertheless, the Ad Slot has to perform a call to the Ad Server to check for ads, causing a possible reservation of space on the site.

Solutions

To lessen the impact of ads to the content of the website, without sacrificing revenue potentials, MetaTag supports multiple distinct solutions.
Solutions can be combined with one another, potentially removing layout shifts completely.

Registering AdSlots on start of the website

MetaTag is able to receive all relevant information for “Ad Slots” inside the <head> HTMLElement of the website. Using the interface methods/wiki/spaces/SDGPUBLIC/pages/51578793 and /wiki/spaces/SDGPUBLIC/pages/51578793 early, the TagManager is able to reserve needed space for the ad slots as soon as the browser starts to render your website. Use our command queue to register ad slots as soon as possible.

Load processes of your site will not be impacted by registering Ad Slots inside the <head> HTMLElement. However, loading the Ad Slot (and automatically rendering the ad contents) will impact the performance of your site negatively.
Consider using “LazyLoad AdSlots” to remedy this.

Strict AdSlots

An ad slot consists of different “Formats”, which may be displayed by the slot. Each possible format has a pixel “width” and “height”.

When employing “strict ad slots”, MetaTag will reserve the largest possible height, of all available formats, on the ad slot. Reservation will take place before the user scrolls the Ad Slot into view or an ad is delivered.
This will avoid layout shift completely but will lead to large “empty spaces” on your site, until ads are finally delivered.
Ads inside the slot will be centered and scrolled alongside with the user, should the delivered ad be smaller than the reserved space.
You can watch a demonstration of this behavior

Alternatively you can set a fixed height by employing the Slot.configure() method. This is helpful if you like to reserve some space for an adslot, but like to have control about the exact height used.

Please note: If the Ad Slot can not be filled with an ad, with strict mode enabled the slot will remain empty and will not be hidden.
To remedy this you can can fill the Ad Slot with your own content, for example an image/text teaser, for more details see the “Native Backfills” section.

This feature can be activated by contacting your Ströer representative or sending us a ticket via our Publisher Support Center (separate account required).
Detailed information about how MetaTag is calculating/handling how much space to reserve, can be found in our documentation: TagManager guidelines for avoiding "Layout Shift"

Loading Animations

When employing “Strict Ad Slots”, it may happen that the user already will see a slot, that is not filled with an ad yet. Since strict ad slots will reserve a fixed height and width for the slot, this empty space might be jarring to look at or signal to the user that the website is not functioning correctly.
To solve this, we can activate icon animations inside the Ad Slot, that will imply that the content is still loading. As soon as an ad is delivered, the animations will be removed.

Loading animations can be activated for the whole site, with 3 different options available. Please contact your Ströer representative or send us a ticket via our Publisher Support Center (separate account required) to start the process.

Expand
titleAvailable loading animations. Click to show.

Option 1 - Bounce

Iframe
marginwidth0
scrollingno
srchttps://cdn.stroeerdigitalgroup.de/metatag/documentation/layoutShift/bounce.html
width180
frameborderhide
marginheight0
height180

Option 2 - Circle

Iframe
marginwidth0
scrollingno
srchttps://cdn.stroeerdigitalgroup.de/metatag/documentation/layoutShift/circle.html
width180
frameborderhide
marginheight0
height180

Option 3 - Wave

Iframe
marginwidth0
scrollingno
srchttps://cdn.stroeerdigitalgroup.de/metatag/documentation/layoutShift/wave.html
width180
frameborderhide
marginheight0
height180

Consent Management Platform

Expand
titleScreenshot of a Consent Management Layer
Screenshot of a Consent Management Platform

A Consent Management Platform (CMP) allows to collect users decisions, how their personalized data can be processed by the website and connected service providers. For more information about how to integrate such a CMP, please see our documentation: Consent Management for Websites

The consent of the user for processing personalized data is informed by an categorisation of different, possible usages of this data. Each service provider integrated into a website might use some or all data in diverse ways (deliver personalized content, display only relevant ads, etc). To allow the user to give a well-informed decision, these usages are clustered into a manageable amount of categories, which in turn the user can consent or decline.
By consenting or declining a category, all service providers inside such a category will be allowed or blocked,

Classification and categorisation of service providers is done by the industry association “Interactive Advertising Bureau (IAB)” based upon the advertising industry-standard “Transparency & Consent Framework (TCF)” . Service providers, which already have been classified, are named “IAB vendors” in the upcoming guide. Non-classified service providers are used as “non-IAB vendors”.

After the user chooses whether to give consent or not, we (Ströer) block/allow all IAB-vendors, which are related and responsible for advertisement. You will not need to do anything for managing these vendors.

Should you use any vendors yourself (IAB or Non-IAB), you will need to ask your users for permission to send personalized data to these vendors.
In case the user does not wish to consent to specific service providers or whole categories, you will have to block these vendors and make sure they will not be activated or delivered to the user.
This might have different impacts for each vendor. Some can still function without any form of personalized data, some will not function at all.
Please contact your vendors / service providers to understand the full technical implementation.

TagManager behaviour with user consent

As soon as a Consent Management Platform is detected on your website, MetaTag will not deliver any advertisements, until the user has decided how their personalized data should be handled.

Some scripts and or vendors, which do not collect any personalized data, might be loaded before the user gives their consent. These scripts are rigorously tested and monitored, to always ensure full compliance.
Other vendors or scripts, which might collect personalized data, are delayed until the user’s decision.

To subsequently deliver any ads (even non-personalized), the user needs at minimum allow the following IAB Transparency & Consent Framework data usages for all involved vendors:

  • Select basic ads (Purpose 2)

  • Measure ad performance (Purpose 7)

  • Apply market research to generate audience insights (Purpose 9)

  • Develop and improve products (Purpose 10)

These purposes need to be either consented to by the user (user opts-in to the purposes), or the website needs to claim “legitimate interest” for these purpose (meaning the user does not explicitly refuse / opt-out)

Note

Should the user refuse these purpose (opt-out), no ads will be delivered on the website and no ad impression will be generated or counted.

For delivering personalized ads and to allow for full monetization of a website, users need to consent fully to the above purposes and additionally to:

  • Store and/or access information on a device (Purpose 1)

  • Create a personalized ads profile (Purposes 3)

  • Select personalized ads (Purposes 4)

CMP interfaces for user consent

When trying to build complex logic based on the consent or refusal of the user (especially when you try to determine which data usage categories specifically where declined), interfacing directly with the CMP is the fastest and safest way.

Each IAB TCF compatible CMP provides a JavaScript interface method called “__tcfapi()” present on the main window object, to which the CMP was delivered.
Extensive documentation for this interface is available on the GitHub page of the IAB: InteractiveAdvertisingBureau / GDPR-Transparency-and-Consent-Framework / Consent Management Platform API

Simplified Example

Code Block
languagejs
/**
 * We like to check multiple data purposes at once, and based on the result, load vendors if consent was available for data purpose 1,2,4,7.
 * For in-depth explanation what the purposes are and do, see: https://iabeurope.eu/iab-europe-transparency-consent-framework-policies/#Appendix_A_Purposes_and_Features_Definitions
 *
 * First we make sure to only get a consent status, when the user has decided and closed the CMP layer.
 * We register an eventListener with the tcfapi() and will react only when the returned eventStatus is "tcloaded" or "useractioncomplete"
 *
 * Secondly we will parse the returned consent status from the tcfapi() and check if the purpose 1,2,4,7 have consent from the user.
 * If consent for 1,2,4,7 is granted, continue with our logic loadPublisherVendors() and remove the eventListener from the tcfapi()
 *
 */
__tcfapi('addEventListener', 2, function (consentData, callbackSuccessfull) {
	let status = consentData.eventStatus,
	    purposeConsents = consentData.purpose.consents;

	if (callbackSuccessfull && (status === 'tcloaded' || status === 'useractioncomplete')) {
		if(purposeConsents['1'] === true && purposeConsents['2'] === true && purposeConsents['4'] === true && purposeConsents['7'] === true) {
			publisherScript.loadPublisherVendors()
			window.__tcfapi('removeEventListener', 2, function () {}, consentData.listenerId);
		}
	}
});

Another use case might be to pass the complete consent information to another system / vendor, so these systems can decide for themselves which usages of personalized data are allowed and react on their own.
For this the __tcfapi() provides a “base-64” encoded string, which includes information about all vendors, purposes and the users decision in a compact, easily transmittable format. To signal a vendor that the user is originating from an GDPR relevant country, most vendors require an indicator, often a boolean switch called “gdprApplies”. These “tcString” and “gdprApllies” parameters are recognized and useable by most vendors in the web eco-system. Please consult the documentation of you vendor to see how you can specifically pass along this information.

Subsequenly the following example shows calling the tcfapi(), requesting “tcString” and “gdprApplies” and forwarding them to a video player.

Code Block
languagejs
/**
 * The setupPlayer method will take 2 optional arguments. Should we be able to recover consent data, make the data available inside the setupPlayer method.
 * Other functions inside the video player will be able to use the consent data, for example when constructing a video advertisement request.
 * If no consent data is available, setup the player normally.
 */
 
let setupPlayer = function(gdprApplies, tcString) {
	let GDPR = gdprApplies ? 1 : 0;
	let GDPR_CONSENT = tcString ? tcString : '';

	// setup your player here, use GDPR and GDPR_CONSENT variables when constructing the VAST-URL
};
if( typeof window.__tcfapi !== 'undefined' ) {
	window.__tcfapi('addEventListener', 2, function (tcData, success) {
		if (success && tcData && (tcData.eventStatus === 'tcloaded' || tcData.eventStatus === 'useractioncomplete') && tcData.tcString && tcData.tcString.length > 0) {
			setupPlayer(tcData.gdprApplies, tcData.tcString);
			window.__tcfapi('removeEventListener', 2, function () {}, tcData.listenerId);
		}
	});
} else {
	setupPlayer();
}

Embedding social media plugins

In some cases users might decline consent for some data usages or vendors, but later would like to see content from these vendors (for example: User refused Twitter to use personalized data, but the content of your website includes a Twitter plugin. The user likes to change their decision.)

Most CMPs allow the change of consent for a single vendor on the fly.
Depending on your used CMP, the necessary steps might be different. Please see the documentation of your CMP.
Example for SourcePoint CMP (allowing CustomVendor “Twitter Inc”, internal Id: “5ec85c9cb8e05c4a2002f42e”) after the user clicked some kind of “I accept Twitter Inc.” button:

Code Block
/**
* Method takes 4 arguments:
* callback {function}
* vendorIds {Array<string>}
* consent data purposes {Array<string>}
* legitimate interest data purposes {Array<string>}
* documentation for this method can be found at Sourcepoints documentation hub: https://documentation.sourcepoint.com/web-implementation/web-implementation/sourcepoint-gdpr-and-tcf-v2-support/the-__tcfapi-gettcdata-api-overview/__tcfapi-postcustomconsent-api
*/ 
__tcfapi('postCustomConsent', 2, function(data) {console.log(data)}, ["5ec85c9cb8e05c4a2002f42e"],[],[])

Documentation for other CMPs: