
![]() |
|
Information |
Tagging guide 2 - implementation | |
Tagging-guide-2-implementation |
Details |
For more details about the render mode, see section “Set up the ad manager – sas.setup(options)” in the Tagging guide 1 - overview article. The example below renders the formatId 14968. <script type="application/javascript">
sas.render('14968'); // Format : myformat </script> The example below calls the method sas.render without any parameter. This triggers the rendering when renderMode is set to 2 (render ad on demand). // will render the format id 12345
sas.render(12345); // will trigger the rendering if renderMode is 2 (render ad on demand) sas.render(); The callback beforeRender(data) is called before the format rendering (sas.render method). The callback is only called if the oneCall has produced a successful response. beforeRender(data) could be used to execute javascript in case of empty ad responses (noad). However, the onNoad(data) callback function is the recommended method for this purpose (read the "Managing empty ad responses (noad)" chapter below).
Setting global and tagId specific keyword targeting in OneCallsIn OneCalls, you can set keyword targeting criteria on two levels:
sas.call("onecall", {
siteId: 1234, pageId: 5678, formats: [{ id: 84313, tagId: "sas_tag_001" target: 'keywordA=value1' }, { id: 84313, tagId: "sas_tag_002" target: 'keywordB=value2' }], target: 'keywordA=value3' }); The following rules apply:
The example mentioned above would generate the following request: "ads": [{
"formatId": 84313, "tagId": "sas_tag_001", "target": "keywordA=value1", "headerBidding": {}, "isLazy": false, "isAdRefresh": 0 }, { "formatId": 84313, "tagId": "sas_tag_002", "target": "keywordA=value3;keywordB=value2", "headerBidding": {}, "isLazy": false, "isAdRefresh": 0 }], Standard taggingStandard ad tags are not recommended for new integrations. Use OneCall ad tags instead.
To use standard tagging, you need to:
ExamplesExample of a Standard tagging generic script to be placed into the <head> of the page:
<script type="application/javascript" src="https://ced.sascdn.com/tag/73/smart.js" async></script> <script type="application/javascript"> var sas = sas || {}; sas.cmd = sas.cmd || []; sas.cmd.push(function() { sas.setup({ networkid: 73, domain: "https://diff.smartadserver.com", async: true }); }); </script> Example of a Standard ad tag to be placed into the <body> of the page: <div id="sas_146032"></div> <script type="application/javascript"> sas.cmd.push(function() { sas.call("std", { siteId: 46374, // pageId: 3648932, // Page : my_site/my_page (PageID=3648932) formatId: 146032, // Format : myformat 1x1 target: '' // Targeting }); }); </script> <noscript> <a href="https://diff.smartadserver.com/ac?jump=1&nwid=73&siteid=46374&pgname=mypage&fmtid=146032&visit=m&tmstp=[timestamp]&out=nonrich" target="_blank"> <img src="https://diff.smartadserver.com/ac?out=nonrich&nwid=73&siteid=46374&pgname=mypage&fmtid=146032&visit=m&tmstp=[timestamp]" border="0" alt="" /> </a> </noscript> Calling a format multiple timesNote: for OneCall tagging see the “Rendering a format” chapter above.
In some cases you may want to call the same format multiple times on a given page. For instance, you may want to call two medium rectangles (with the same formatId) on a page: one at the top and one at the bottom of the page. Use the tagId option in the sas.call method to make sure that the ads appear in the correct <div> containers. In this method, you specify the Ids of the containers, where the format is supposed to be displayed. Warning
Calling a format multiple times with standard call is not recommended if your setup is using insertion links, exclusions or multi-format insertions (insertions activated on multiple formats) — the proper functioning of these features cannot be guaranteed. In these cases, use OneCall instead of standard call. The example below calls the formatId 146032 and displays it in the div with id 'medrec-top'.
<script type="application/javascript">
sas.cmd.push(function() {
sas.call("std", {
siteId: 46374, //
pageId: 3648932, // Page : my_site/my_page (PageID=3648932)
formatId: 146032, // Format : myformat 1x1
target: '' // Targeting
tagId: 'medrec-top'
});
});
</script>
To call the format and display it in another div, simply replace the tagId (e. g. replace 'medrec-top' by 'medrec-bottom').
Other operationsCleaning adsNote: This option is available for both OneCall and Standard tagging types.
To clean a specific format, use the sas.clean([formatId]) method. Calling the method without any specified formatId will clean all the formatIds of the page. Example// clean the format 300 sas.clean(300); // clean all formats sas.clean(); When using the sas.clean method, the callback onClean(formatId, element) in the sas.call method will be triggered:
You can register a function to be warned when a clean has been executed.
Calling ads in an iframeTo call ads in an iframe, change the callType from "std" to "iframe" and specify the width and height of the iframe.
Example<script type="application/javascript"> sas.call("iframe", { siteId: 53008, pageName: 'mypage', formatId: 23028, tagId: 'sas_23028', height:300, width:250 }); </script> Managing ad responses (onAd)The onAd(data) callback function is triggered when Equativ returns an ad to be displayed for a given format. You can use this callback function to execute javascript code on your website when Equativ's response contains an ad.
The onAd(data) callback function has the properties:
OneCall tagging example<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>DEMO TAGS</title> <script src="//ced.sascdn.com/tag/620/smart.js" type="application/javascript" async></script> <script type="application/javascript"> var sas = sas || {}; sas.cmd = sas.cmd || []; sas.cmd.push(function () { sas.setup({ networkid: 174, domain: "//[subdomain].smartadserver.com", async: true }); }); sas.cmd.push(function () { sas.call("onecall", { siteId: 86374, pageId: 609161, formats: [{ id: 36780 }], target: '' }, { onAd: function (data) { if (data.formatId) { console.log(data); console.log("FORMAT ID : " + data.formatId); console.log("TAG ID : " + data.tagId); } } }); }); </script> </head> <body> <div id="sas_36780"></div> <script type="application/javascript"> sas.cmd.push(function () { sas.render("36780"); // Format : billboard 750x300 }); </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>DEMO TAGS</title> <script src="//ced.sascdn.com/tag/620/smart.js" type="application/javascript" async></script> <script type="application/javascript"> var sas = sas || {}; sas.cmd = sas.cmd || []; sas.cmd.push(function() { sas.setup({ networkid: 620, domain: "//[subdomain].smartadserver.com", async: true }); }); </script> </head> <body> <div id="sas_36780"></div> <script type="application/javascript"> sas.cmd.push(function() { sas.call("std", { siteId: 86374, pageId: 609161, formatId: '36780', target: '' }, { onAd: function(data){ if (data.formatId) { console.log(data); console.log("FORMAT ID : "+data.formatId); console.log("TAG ID : "+data.tagId); } } }); }); </script> </body> </html>
The onNoad(data) callback function is triggered if there is no ad to display for the given format (empty ad response). You can use this callback function to execute javascript code on your website when an ad request does not return any ad.
In case of callType="onecall", the callback will be triggered for each empty format. The onNoad(data) callback function has the properties:
Standard tagging example<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>DEMO TAGS</title> <script src="//ced.sascdn.com/tag/620/smart.js" type="application/javascript" async></script> <script type="application/javascript"> var sas = sas || {}; sas.cmd = sas.cmd || []; sas.cmd.push(function() { sas.setup({ networkid: 620, domain: "//[subdomain].smartadserver.com", async: true }); }); </script> </head> <body> <div id="sas_36780"></div> <script type="application/javascript"> sas.cmd.push(function() { sas.call("std", { siteId: 86374, pageId: 609161, formatId: '36780', target: '' }, { onNoad: function(data){ if (data.formatId) { console.log(data); console.log("FORMAT ID : "+data.formatId); console.log("TAG ID : "+data.tagId); } } }); }); </script> </body> </html> Calling ads over HTTPSThe ad tags you can export from the user interface are already HTTPS compatible. They use a schema-less URI model and can be used on HTTP and HTTPS websites directly.
If your website (page) is loaded over HTTPS, browser security requires the following:
Equativ ad tags must be called with HTTPS third party ad tags (agency scripts pasted on the Creatives tab of insertions) must be called with HTTPS the landing pages (clickURLs) must be secure (HTTPS) Failing to do so leads to a security error in the browser (negative impact on user experience)! CNAME security warningYou can use a CNAME to have an advertising subdomain on your own domain (e. g. ads.mydomain.com) while still pointing to Equativ's servers; when doing so, make sure that your advertising subdomain does not get access to your first party cookies; especially, the advertising subdomain (ads.mydomain.com) must not get access to any authentication token stored on your main domain (mydomain.com). |
||||||||||||||||||||||||||||||||||||||