Motivation
The main reason why you would want to insert multiple ad spaces with one ad server request is to get full de-duplication of advertisers for all of the ad spaces.
Setup
To insert two (or more) ad spaces with the same ad server request, you must:
-
Gather all the existing tags on the page
-
Combine the tags into one tag
Limitations
-
You can combine any number of normal ad space tags and any number of ad space tags using render templates, but you currently cannot combine a mix of ad space tags where some use render templates and some do not.
Suggested solution to combine render template with non-render template adspaces
Use the Example 8a - Using the default renderer to use custom render code and dispatch all other ads to the default render functionality.
-
You currently cannot use insertMultipleAdSpaces with templates hosted in other locations than on *.cxpublic.com domains.
-
You currently cannot use insertMultipleAdSpaces with just a render function. Either normal HTML responses or render templates must be used to render the ads.
Example
Here is an example of how this is done.
On a page, there are two ad space tags:
Tag 1:
|
Tag 2:
|
Each of the tags consist of three elements:
-
A target element
-
The code that inserts the ads at the target element
-
The loading of the cx.js script
To combine the two tags:
-
Put the first target element into the page where you want the first ad space to be rendered
|
-
Put the second target element into the page where you want the seconds ad space to be rendered
|
-
Copy the parameter blocks of the two tags into a new tag using the "insertMultipleAdSpaces" function, and insert this common tag after the two target tags in the HTML:
|
It is important that this last code block is placed after all of the target elements in the HTML page. This is because all of the targets must exist when the script tries to look them up and insert ads at those positions.
Optional common arguments object
As the multiple ad spaces are now all served by just one ad server request, most of the single ad server options can't be set to different values for the different ad spaces. E.g. we can't set 'backend: sandbox' on one adspace and 'backend: production' on the other, because there is only one ad server request, and it can only go one place.
The per-request options must therefore be set in an optional common arguments object that is added as an extra paramter to the call:
|
The rule is that options that are set for each ad space must go into the settings object for the ad space in question. Options that are only possible to be set once per ad server request must go into the optional arguments object.
Note: There is no logic that distributes options set in the optional arguments object out to the individual ad space settings objects, thus even if two ad spaces use the same setting, it still must be set on the individual ad space settings objects and not on the common options object:
|