Full reach - AdManager example
by romanych
HTML
<html>
<head>
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script>
(function(w) {
w.loadAudienceProjectPredictions = function(customerId, callback, timeout) {
timeout = timeout || 1000;
var sref = "";
var ref = document.referrer;
if (ref) {
var origin = w.location.origin || w.document.origin;
if (origin) {
if (ref.indexOf(origin) === -1) {
sref = ref;
try {
w.localStorage.setItem("apr_sref", sref);
} catch (e) {};
}
}
}
var dsu = "";
try {
dsuId = w.localStorage.getItem("apr_dsu");
sref = w.localStorage.getItem("apr_sref");
} catch (e) {};
var s = w.document.createElement('script');
s.src = "https://pdw-usr.userreport.com/js/v2/partner/" +
encodeURIComponent(customerId) + "/uid" +
"?med=" + encodeURIComponent(window.location.toString()) +
"&dsu=" + encodeURIComponent(dsu) +
"&ref=" + encodeURIComponent(ref || "") +
"&sref=" + encodeURIComponent(sref || "");
s.async = true;
var fallbackTimerId = setTimeout(function() {
callback && callback([]);
}, timeout);
s.onload = function() {
clearTimeout(fallbackTimerId);
callback && callback(w.apDataKeyValues);
};
s.onerror = function() {
clearTimeout(fallbackTimerId);
callback && callback({});
}
if (w.document.head) {
w.document.head.appendChild(s);
} else {
var fs = w.document.getElementsByTagName("script")[0];
fs.parentNode.insertBefore(s, fs);
}
};
})(window);
</script>
<script>
window.googletag = window.googletag || { cmd: []...