You can use the ADX Tag library to add functions to your tags and build ad requests dynamically. By using ADX Tag methods you can attach keywords, key-values, search words, and so forth to your tag. You can also adjust the ad placement format and set up ad rendering event notifications.
Tag Preload Function
Use this function to preload bid responses before the tag is actually rendered into a page. After the tag is inserted, the ad is rendered immediately without having to make a request to the server. It's useful for lazy-loaded ads.
adformtag.push({ preload: [ 'adx.adform.net/adx/?mid=12345', 'adx.adform.net/adx/?mid=12345' ] }); // push object which contains key 'preload' with value array of tag urls.
Note
When pushing a placement URL into the adformtag preloading function, it's important that all parameters match between the URL and the preload request, as well the Master Tag call on the page.
Library Methods
-
adformtag.setTargeting passes key-value or keywords targeting rules on a specific tag. All values are passed to the ad server, even duplicate ones.
adformtag.setTargeting(1, 'key', 'value'); //key-value targeting, args: (mid, key, value) adformtag.setTargeting(1, 'data'); //keywords targeting, args: (mid, keyword)
-
adformtag.setPrice passes price targeting rules on a specific tag. The last value you set is passed to the ad server.
adformtag.setPrice(1, 10.45); //price targeting, args: (mid, price)
-
adformtag.setCustomData passes additional data with a request on a specific tag. All values are passed to the ad server, even duplicate ones.
adformtag.setCustomData(1, 'key', 'data'); //additional data, args: (mid, key, data)
-
adformtag.disableSingleRequest prevents multiple tags from joining a single request.
adformtag.disableSingleRequest(); //multiple requests for each tag, no arguments needed
-
adformtag.setRequestLimit(count) limits the number of master tags that can be loaded with a single request.
adformtag.setRequestLimit(5); //number of tags to be loaded, args: (count)
-
adformtag.addRequestGroup( [ mid1, mid2, .., midN ] ) forces some master tags to be loaded together. This is useful if you are using setRequestLimit() to still be able to serve synched banners or wallpapers.
adformtag.addRequestGroup([55555, 45544]); //tags to be loaded together, args: (array of mids)
-
adformtag.resetTargeting(mid) removes the previous targeting settings.
adformtag.resetTargeting(55555); //targeting cleanup for specific mid, args: (mid)
-
adformtag.sticky(mid, options) changes the placement type to sticky. A sticky placement is a type of ad that doesn't move when the user scrolls down the page (until the 'sticky' ad encounters another ad).
adformtag.sticky( 123, // mid { top: 60 // offset from window in case of floated menu } // options });
-
adformtag.onLoaded(mid, callback) notifies you when the tag response came back from the adx server.
adformtag.onLoaded(123, function (adItem){ console.log(adItem); });
-
adformtag.onRendered(mid, callback) notifies you when the banner is rendered into the page.
adformtag.onRendered(123, function (adItem){ console.log(adItem); });
-
adformtag.floating(mid, options) creates a floating banner placement.
adformtag.floating(123, //mid - required { type: 'fixed', // optional, possible values - [ 'absolute', 'fixed' ], default - fixed position: 'MC', // optional, possible values - [ 'TL', 'TC', 'TR', 'ML', 'MC', 'MR', 'BL', 'BC', 'BR' ], default - MC overlay : { color: '#000', // optional, value - any CSS color value - default - #000 opacity: 0.5 //optional, value - [ 0 .. 1 ], default - 0.7 }, close: { html: '<div>CLOSE<div>', // string with html content, will be added on banner. Usable for custom close button or additional html elements url: './close.png', // image which will be used for close button width: 100, //close button width default 24px, only for image height: 100, //close button height default 24px, only for image align: 'left', //close button position, possible to choose 'left' or 'right' position, for image button and text button text: 'close', //will be created simple div with specified text inside, default - x } //optional, only one of [ html, url, text] will be used, html - most important, text - least improtant and default } // options, optional );
-
adformtag.setRequestParam(param, value) passes global parameters to the ad server.
adformtag.setRequestParam('param', 1); // added request (global) param, args: (param, value)
-
adformtag.removeRequestParam(param) removes a global parameter in the request to the ad server.
adformtag.removeRequestParam('param'); // removed request (global) param, args: (param)
-
adformtag.setSearchWord(mid, key, value); passes a key-value search word targeting rules on a specific tag. All values are passed to the server, even duplicate values.
adformtag.setSearchWord(1, 'key', 'value'); //key-value search word targeting, args: (mid, key, value)
-
adformtag.setGlobalSearchWord(key, value); passes key-value search word targeting rules at page scope. All values are passed to the server, even duplicate values.
adformtag.setGlobalSearchWord('key', 'value'); //key-value search word targeting, args: (key, value)
-
adformtag.setGlobalTargeting(key, value); passes a key-value pair or keywords targeting rules at page scope. All values are passed to the ad server, even duplicate values. This method does not work with out-stream tags.
adformtag.setGlobalTargeting('key', 'value'); //key-value page scope targeting, args: (key, value)
-
adformtag.resetGlobalTargeting(); removes the previous global targeting settings.
adformtag.resetGlobalTargeting(); //targeting cleanup for page scope; no args
-
adformtag.addStrictGroup( [ mid1, mid2, .., midN ] ) forces some master tags to load together only when all master tags are inserted on the page.
adformtag.addStrictGroup([55555, 45544]); //tags to be loaded together, args: (array of mids)
Note
While forcing master tags to load together, the request URLs shouldn't exceed 16,384 characters for the ADX tag to handle them properly.
To find these requests on your website:
-
Open the developer tools.
-
Click the Network tab.
-
Open one of the request’s Header section.
-
adformtag.setExtendedIDs([ { eids object } ]); passes first-party IDs to the SSP.
adformtag.setExtendedIDs([{ 'source': 'id-source.org', 'uids': [{ 'id': 'TTD_ID_FROM_USER_ID_MODULE', 'atype': 1 }] }, { 'source': 'webpage.com', 'uids': [{ 'id': 'COM_ID_FROM_USER_ID_MODULE', 'atype': 2 }, { 'id': 'COM_ID_FROM_USER_ID_MODULE', 'atype': 1 }] } ]); // array of openRTB eid format objects https://github.com/InteractiveAdvertisingBureau/AdCOM/blob/develop/AdCOM%20v1.0%20FINAL.md#object_eids
-
adformtag.clearExtendedIDs(); clears all IDs previously set using adformtag.setExtendedIDs()
adformtag.clearExtendedIDs();
Usage Example
<script type="text/javascript"> var adformtag = adformtag || []; adformtag.push({ preload: [ 'adx.adform.net/adx/?mid=4234' ] }); adformtag.push(function () { adformtag.setTargeting('4234', 'key1', 'value1') .setTargeting('4234', 'key3') .setPrice('4234', 10.25) .setCustomData('4234', 'key4', 'data1') .setRequestParam('param', 1) .setRequestParam('test', 2) .removeRequestParam('test') .disableSingleRequest(); }); </script> <script src="//s1.adform.net/banners/scripts/adx.js" data-adfscript="adx.adform.net/adx?mid=4234"></script>