(function (d, w) { // eslint-disable-line max-statements function imgSrcToElement(src) { var img = d.createElement('img'); img.height = 1; img.width = 1; img.style.display = 'none'; img.src = src; img.alt = ''; return d.body.appendChild(img); } function iframeSrcToElement(src) { var ifrm = d.createElement('iframe'); ifrm.width = 1; ifrm.height = 1; ifrm.style.display = 'none'; ifrm.src = src; return d.body.appendChild(ifrm); } function scriptSrcToElement(src, async) { var isAsync = async === null ? true : async; var script = d.createElement('script'); script.type = 'text/javascript'; script.src = src; script.async = isAsync; return d.body.appendChild(script); } function dropPixel(src, type) { if (type === 'img') { return imgSrcToElement(src); } if (type === 'script') { return scriptSrcToElement(src); } if (type === 'iframe') { return iframeSrcToElement(src); } return false; } var aupixels = { // eslint-disable-line no-implicit-globals, no-unused-vars pageload: [ ], linkfire: { // INSERT LINKFIRE PIXELS HERE /* ex: 'itunes': [ ['https://secure.adnxs.com/px?id=911725&t=2&adgt=true', 'img'], ['https://ad.doubleclick.net/ddm/activity/src=8005553;type=invmedia;cat=hs0rirok;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=1?', 'img'], ], 'google-play': [ ['https://secure.adnxs.com/px?id=911726&t=2&adgt=true', 'img'], 'https://ad.doubleclick.net/ddm/activity/src=8005553;type=invmedia;cat=bphkhwr5;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=1?' ], */ // END LINKFIRE PIXELS HERE }, ec: { // INSERT ECOMMERCE PIXELS HERE /* ex: 'view': [ ['https://secure.adnxs.com/px?id=911725&t=2&adgt=true', 'img'], ['https://ad.doubleclick.net/ddm/activity/src=8005553;type=invmedia;cat=hs0rirok;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=1?' ], 'add': [ ['https://secure.adnxs.com/px?id=911725&t=2&adgt=true', 'img'], ['https://ad.doubleclick.net/ddm/activity/src=8005553;type=invmedia;cat=hs0rirok;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=1?', 'img'], ], 'checkout': [ ['https://secure.adnxs.com/px?id=911725&t=2&adgt=true', 'img'], ['https://ad.doubleclick.net/ddm/activity/src=8005553;type=invmedia;cat=hs0rirok;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=1?', 'img'], ], 'transaction': [ ['https://secure.adnxs.com/px?id=911725&t=2&adgt=true', 'img'], ['https://ad.doubleclick.net/ddm/activity/src=8005553;type=invmedia;cat=hs0rirok;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=1?', 'img'], ] */ }, buttonClickPixels: [ // INSERT CUSTOM BUTTON CLICK PIXELS HERE // for adding custom button click pixels unique to one or very few sites/campaigns. if more common implementation, use profiler service // example: // { // selector: 'SOME querySelectorAll-STYLE SELECTOR', // pixels: [['pixel-1-src', 'img|script|iframe'], ['pixel-2-src', 'img|script|iframe']], // }, ], hashchange: [ // INSERT CUSTOM HASH-BASED CLICK PIXELS HERE // for adding custom pixels unique to one or more location hash values, e.g. google.com/#some-text // example: // { // hash: '#example-hash', // pixels: [['pixel-1-src', 'img|script|iframe'], ['pixel-2-src', 'img|script|iframe']], // }, ], }; // set window.aupixels to store for async use by profiler service or this service var linkfire = aupixels.linkfire; var ec = aupixels.ec; var hc = aupixels.hashchange; if (!hc) { hc = []; } w.aupixels = { linkfire: linkfire, ec: ec, hashchange: hc }; // drop pageload pixels aupixels.pageload.forEach(function(item) { dropPixel(item[0], item[1]); }); // check hash pixels against current hash, and add event listener for hash changes function compareAndDropHashPixel(e) { var hashString = e.hash; if (hashString.indexOf('#') !== 0) hashString = '#' + hashString; var pix = e.pixels; if (w.location.hash === hashString) { pix.forEach(function(item) { dropPixel(item[0], item[1]); }); } } hc.forEach(compareAndDropHashPixel); function hashChangeHandler() { var hashChangePixels = w.aupixels.hashchange; hashChangePixels.forEach(compareAndDropHashPixel); } w.addEventListener("hashchange", hashChangeHandler); // add event listeners for button click pixels var buttonClickPixels = aupixels.buttonClickPixels; function buttonClickHandlers(selectors) { selectors.forEach(function(e) { // eslint-disable-line var selector = e.selector; // eslint-disable-line var pix = e.pixels; var els = d.querySelectorAll(selector); for (var i = 0; i < els.length; i++) { // eslint-disable-line var button = els[i]; pix.forEach(function(item) { // eslint-disable-line button.addEventListener('mousedown', function() { // eslint-disable-line dropPixel(item[0], item[1]); }); button.addEventListener('touchstart', function() { // eslint-disable-line dropPixel(item[0], item[1]); }); }) } }); } buttonClickHandlers(buttonClickPixels); // eslint-disable-line no-undef function createEvent() { if (typeof window.CustomEvent === 'function') { return new CustomEvent('aupixels'); // eslint-disable-line } var p = { bubbles: false, cancelable: false, detail: undefined // eslint-disable-line }; var evt = document.createEvent('CustomEvent'); // eslint-disable-line evt.initCustomEvent('aupixels', p.bubbles, p.cancelable, p.detail); return evt } var event = createEvent(); w.dispatchEvent(event); })(document, window);