// to be removed when deactivated in CMS document.cookie = "cookieDisclaimer=seen; max-age=" + 60*60*24*365*2; // to be removed when deactivated in CMS function getCookie(name) { var value = "; " + document.cookie; var parts = value.split("; " + name + "="); if (parts.length == 2) return parts.pop().split(";").shift(); } // Google Consent Mode v2 - set defaults window.gtagDataLayer = window.gtagDataLayer || []; function gtag() {window.gtagDataLayer.push(arguments);} gtag('consent', 'default', { ad_storage: _satellite.getVar("Google Ad Storage Consent"), analytics_storage: _satellite.getVar("Google Analytics Storage Consent"), ad_user_data: _satellite.getVar("Google Ad User Data Consent"), ad_personalization: _satellite.getVar("Google Ad Personalization Consent"), wait_for_update: 0 }); function OptanonWrapper() { // Hide the banner as we start directly with the consent modal /* if (!getCookie('OptanonAlertBoxClosed')) { if((_satellite.getVar("PAGE NAME TEMPLATE") != "Local Privacy Notice | DHL") && (_satellite.getVar("PAGE NAME TEMPLATE") != "Privacy Notice | DHL")){ // hide Consent Modul on Privacy Notice Pages Optanon.ToggleInfoDisplay(); } } */ //var eOT = new Event('OneTrustGroupsUpdated'); //document.dispatchEvent(eOT); document.dispatchEvent(new CustomEvent("dataLayer.push", {detail:{ "event": "OneTrustGroupsUpdated"}})) _satellite.track("OneTrustGroupsUpdated", {$rule:{name:"Page Top"}}) _satellite.logger.log(OnetrustActiveGroups); _satellite.cookie.set("OnetrustActiveGroups", OnetrustActiveGroups, {expires: 365}); } // dataLayer.push noop - fix for one trust consent update push //window.dataLayer = window.dataLayer || {}; //window.dataLayer.push = function() {}; /** * This function will load and trigger the one trust cookie banner. This is done by including * the one trust scripts into the DOM. A data-domain-script data-attribute will determine which * version is loaded from the assets. */ ;(function(){ var script = document.createElement("script"); script.setAttribute("src", "https://cdn.cookielaw.org/scripttemplates/otSDKStub.js"); script.setAttribute("text", "text/javascript"); script.setAttribute("charset", "UTF-8"); // below is the environment id from one trust ui. change it in order to display different visuals script.setAttribute("data-domain-script", _satellite.getVar("Config | OneTrust Environment")); script.setAttribute("data-document-language", "true"); script.setAttribute("data-dLayer-ignore", "true"); //script.setAttribute("data-dLayer-name", "OTDataLayer"); document.head.appendChild(script); }()); /** * This function adds a cookie settings button to the logistics footer * Footer list is not available at script execution. Therefore we loop * until available */ ;(function(){ var to = setInterval(function(){ var footer_list = document.querySelector("#wcag-footer nav ul"); if(footer_list){ var li = document.createElement("li"); li.classList.add("l-grid--w-50pc-s"); var button = document.createElement("button"); button.setAttribute("id", "onetrust-pc-btn-handler"); button.setAttribute("data-document-language", "true"); button.textContent = "Cookie Settings"; button.classList.add("link"); button.classList.add("ot-sdk-show-settings"); li.appendChild(button); footer_list.appendChild(li); clearInterval(to); } }, 200); }()); /** * @file DHLTrackingHelper.js * @description This file contains functions related to tracking and analytics for DHL tracking. * The functions include sending data via image pixel, appending scripts asynchronously, * loading and initializing meta pixel, tracking meta pixel, loading and initializing Google (Ads) Tag, * tracking Google Ads conversion, loading and initializing LinkedIn Insights Tag, and tracking LinkedIn Insights Tag conversion. * These functions are part of the DHLTrackingHelper namespace. */ window.DHLTrackingHelper = {}; /* * Function to send data via an image pixel * @param {string} pixelUrl URL that will be requested via image pixel */ window.DHLTrackingHelper._sendImagePixel = function (pixelUrl) { var imageTag; imageTag = document.createElement("img"); imageTag.width = 1; imageTag.height = 1; imageTag.src = pixelUrl; }; /* * Function to append a script to a page asynchronously * @param {string} scriptUrl URL of the JavaScript file that will be appended to the page * @param {function} callback optional callback function to trigger onload */ window.DHLTrackingHelper._requestAsyncScript = function (scriptUrl, callback) { var scriptTag, firstScript; scriptTag = document.createElement("script"); firstScript = document.getElementsByTagName("script")[0]; scriptTag.type = "text/javascript"; scriptTag.onload = callback; scriptTag.async = !0; scriptTag.src = scriptUrl; firstScript.parentNode.insertBefore(scriptTag, firstScript); }; /* * Function to load Meta Pixel */ window.DHLTrackingHelper.loadMetaPixel = function () { if (!window.DHLTrackingHelper.metaPixelLoaded) { var libraryUrl = "https://connect.facebook.net/en_US/fbevents.js"; this._requestAsyncScript(libraryUrl, function () { window.DHLTrackingHelper.metaPixelLoaded = !0; _satellite.logger.log("Meta Pixel loaded"); }); } }; /* * Function to initialize Meta Pixel * @param {string} pixelId ID of the meta pixel */ window.DHLTrackingHelper.initializeMetaPixel = function (pixelId) { if (!window.DHLTrackingHelper.metaPixelLoaded) { this.loadMetaPixel(); } if (!window.DHLTrackingHelper.metaPixelInitiated) { metaPixel = window.fbq = function () { metaPixel.callMethod ? metaPixel.callMethod.apply(metaPixel, arguments) : metaPixel.queue.push(arguments) }; window._fbq || (window._fbq = metaPixel); metaPixel.push = metaPixel; metaPixel.loaded = !0; metaPixel.version = "2.0"; metaPixel.queue = []; window.fbq("init", pixelId); window.DHLTrackingHelper.metaPixelInitiated = !0; } _satellite.logger.log("Meta Pixel initialized - ID: " + pixelId); }; /* * Function to track Meta Pixel * @param {string} pixelId ID of the meta pixel * @param {string} eventType type of the event * @param {string} conversionProp optional property of the meta pixel */ window.DHLTrackingHelper.trackMetaPixel = function (pixelId, eventType, conversionProp) { pixelId = pixelId.toString(); // make sure we have a string - number is often passed eventType = eventType || "PageView"; // make sure we have a conversionType - PageView is default if (!window.DHLTrackingHelper.metaPixelInitiated) { this.initializeMetaPixel(pixelId); } if ("PageView" === eventType) { window.fbq("trackSingle", pixelId, eventType, conversionProp); } else { window.fbq("trackSingleCustom", pixelId, eventType, conversionProp); } _satellite.logger.log("Meta Pixel tracked - ID: " + pixelId + " | Event: " + eventType + (conversionProp ? " | Prop : " + JSON.stringify(conversionProp) : "")); }; /* * Function to load Google (Ads) Tag * @param {string} accountId ID of the Google Tag */ window.DHLTrackingHelper.loadGoogleTag = function (accountId) { if (!window.DHLTrackingHelper.googleTagLoaded) { var googleTagUrl = "https://www.googletagmanager.com/gtag/js?id=AW-" + accountId + "&l=gtagDataLayer"; this._requestAsyncScript(googleTagUrl, function () { window.DHLTrackingHelper.googleTagLoaded = !0; _satellite.logger.log("Google Tag loaded - ID: " + accountId); }); } }; /* * Function to initialize Google (Ads) Tag * @param {string} accountId ID of the Google Tag */ window.DHLTrackingHelper.initializeGoogleTag = function (accountId) { if (!window.DHLTrackingHelper.googleTagInitialized) { window.gtagDataLayer = window.gtagDataLayer || []; window.gtag = function () { window.gtagDataLayer.push(arguments); }; gtag("js", new Date()); gtag("config", "AW-" + accountId); window.DHLTrackingHelper.googleTagInitialized = !0; _satellite.logger.log("Google Tag initialized - ID: " + accountId); } if (!window.DHLTrackingHelper.googleTagLoaded) { this.loadGoogleTag(accountId); } }; /* * Function to track Google Ads Conversion * @param {string} accountId ID of the Google Tag * @param {string} conversionId ID of the specific conversion * @param {string} redirectUrl optional URL to redirect to after the conversion has been tracked */ window.DHLTrackingHelper.trackGoogleAdsConversion = function (accountId, conversionId, redirectUrl) { if (!window.DHLTrackingHelper.googleTagInitialized) { this.initializeGoogleTag(accountId); } if (typeof conversionId !== "undefined") { gtag("event", "conversion", { send_to: "AW-" + accountId + "/" + conversionId, event_callback: function () { "undefined" != typeof redirectUrl && (window.location = redirectUrl) } }); _satellite.logger.log("Google Ads Conversion tracked - ID: " + accountId + " | Label : " + conversionId); } }; /* * Function to load LinkedIn Insights Tag * @param {string} linkedInPartnerId */ window.DHLTrackingHelper.loadLinkedInInsightTag = function (linkedInPartnerId) { if (!window.DHLTrackingHelper.linkedInInsightTagLoaded) { this._requestAsyncScript("https://snap.licdn.com/li.lms-analytics/insight.min.js", function() { window.DHLTrackingHelper.linkedInInsightTagLoaded = !0; _satellite.logger.log("LinkedIn Insights Tag loaded - ID: " + linkedInPartnerId); }); } }; /* * Function to initialize LinkedIn Insights Tag * @param {string} linkedInPartnerId */ window.DHLTrackingHelper.initializeLinkedInInsightTag = function (linkedInPartnerId) { if (!window.DHLTrackingHelper.linkedInLibraryLoaded) { window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || []; window._linkedin_data_partner_ids.push(linkedInPartnerId); (function (l) { if (!l) { window.lintrk = function (a, b) { window.lintrk.q.push([a, b]) }; window.lintrk.q = [] } if (!window.DHLTrackingHelper.linkedInInsightTagLoaded) { this.loadLinkedInInsightTag(linkedInPartnerId); } })(window.lintrk); _satellite.logger.log("LinkedIn Insights Tag initialized - ID: " + linkedInPartnerId); } }; /* * Function to track LinkedIn Insights Tag Conversion * @param {string} linkedInPartnerId * @param {string} conversionId */ window.DHLTrackingHelper.trackLinkedInInsightsConversion = function (linkedInPartnerId, conversionId) { if (!window.DHLTrackingHelper.linkedInLibraryInitialized) { window.DHLTrackingHelper.initializeLinkedInInsightTag(linkedInPartnerId); } window.lintrk('track', { conversion_id: conversionId }); _satellite.logger.log("LinkedIn Insights Tag Conversion tracked - ID: " + conversionId); };