Tag integration V2

Live Targeting API (new API)

Should you want to use our API for user data and/or contextual with Prebid, please consider using our official Prebid Real Time Data Submodule

Add this tag to you header or directly to the ad placement where you would like to access user segments cookies & consent based user-centric segments, cookieless and/or contextual categories.

THIS TAG WILL NOT DROP OR ACCESS TO ANY COOKIE. PRIVACY CHECKS WILL BE PERFORMED BY SIRDATA, AND THE CALL MAY BE REDIRECTED TO OUR COOKIE-BASED API WHEN RELEVANT.

In UE, the UK, Iceland, Liechtenstein and Norway, unless specifically and by written authorized not to, do call this tag ONLY on websites working with a TCF compliant CMP.

The tag will automatically perform relevant checks, but you can perform these tests on your own and earn precious milliseconds : call the tag when a valid consent CHOICE for Purposes 1 & 3 and Vendor IDs 53 (cookie-based) and/or 916 (cookieless) has been made by the user, with the mandatory gdpr=[gdpr_applies]&gdpr_consent=[tc_string] parameters in the URL.

Use this script to get user-centric segments and contextual categories and use them in the callback function :

function sddanCallback(result){
   //Do stuff here e.g. load adserver/ssp with key/value data in result
   console.log(result);
   console.log(JSON.stringify(result.segments));
   console.log(JSON.stringify(result.contextual_categories));
   console.log(JSON.stringify(result.shared_taxonomy));
}

var sddanPid = 1; //USE 1 FOR TESTS, GET YOUR OWN ID
var sddanKeyId = 1; //USE 1 FOR TESTS, GET YOUR OWN ID

var sddanTag = document.createElement('script');
var sddanUrl;
try { sddanUrl = '&url='+encodeURIComponent(window.top.location.href); } catch (e) {}
sddanTag.src = 'https://kvt.cookieless-data.com/api/v1/public/p/'+sddanPid+'/d/'+sddanKeyId+'/s?callback=sddanCallback'+sddanUrl;
sddanTag.async = true;
sddanTag.setAttribute('referrerpolicy','unsafe-url');
document.getElementsByTagName('body')[0].appendChild(sddanTag);

gdpr and gdpr_consent are collected automatically, but you can earn precious milliseconds by sending them directly on the relevant endpoint like that :

<script>
var sddanPid = 1; //USE 1 FOR TESTS, GET YOUR OWN ID
var sddanKeyId = 1; //USE 1 FOR TESTS, GET YOUR OWN ID
var sddanWaitUserChoice = true; //True if you want to wait user choice or false if not
var sddanSegments = new Object;

function sddanCallback(result){
   //Do stuff here e.g. load adserver/ssp with key/value data in result
   console.log(result);
   console.log(JSON.stringify(result.segments));
   console.log(JSON.stringify(result.contextual_categories));
   console.log(JSON.stringify(result.shared_taxonomy));
}

function getSddanTargeting(tcData,isCookiebased) {
	var sddanTag = document.createElement('script');
	var sddanHost = (isCookiebased===true?'sddan.com':'cookieless-data.com');
	var sddanTcString = (tcData?'&gdpr='+tcData.gdprApplies+'&gdpr_consent='+(tcData.tcString?tcData.tcString:''):'');
	var sddanUrl;
	try { sddanUrl = '&url='+encodeURIComponent(window.top.location.href); } catch (e) {}
	sddanTag.src = 'https://kvt.'+sddanHost+'/api/v1/public/p/'+sddanPid+'/d/'+sddanKeyId+'/s?callback=sddanCallback'+sddanUrl+sddanTcString;
	sddanTag.async = true;
	sddanTag.setAttribute('referrerpolicy','unsafe-url');
	document.getElementsByTagName('body')[0].appendChild(sddanTag);
}

(function () {
  if (typeof window.__tcfapi === 'function') {
    window.__tcfapi('addEventListener', 2, function (tcData, success) {
        if (!success || (!tcData.eventStatus && tcData.gdprApplies)) {
            return
        }
        if (!tcData.gdprApplies || (tcData.tcString && tcData.vendor.consents[53] && tcData.purpose.consents[1] && tcData.purpose.consents[4])) {
            getSddanTargeting(tcData,true);
            __tcfapi('removeEventListener', 2, function () {}, tcData.listenerId);
        }
        else if (tcData.eventStatus === "tcloaded" || tcData.eventStatus === "useractioncomplete" || sddanWaitUserChoice !== true) {
        	 getSddanTargeting(tcData,false);
            __tcfapi('removeEventListener', 2, function () {}, tcData.listenerId);
        }
    });
  }
  else {
  	getSddanTargeting(null,null);
  }
})();
</script>

PLEASE REMBER TO HAVE YOUR DOMAIN(S) WHITELISTED WHEN REQUESTED PRODUCTION PARTNER ID AND KEY ID, OTHERWIZE THE TAG WILL GET NOW ANSWER

Whenever you want to work accordingly to the SDA specification, please refer to the official segtax ID taxonomies.

Last updated