document.writeln(''); document.writeln('var ctaTracking = { config: { category: "cta_buttons", loggingOnly: false }, helpers: {} }'); document.writeln('ctaTracking.data = { \'last_section\': \'none\', \'scroll_depth\': 0, \'url_path\': document.location.pathname }'); document.writeln('ctaTracking.helpers.getITM = function(elem) {'); document.writeln(' return /itm=([^&#]*)/.exec(elem.href)[1];'); document.writeln('}'); document.writeln('ctaTracking.helpers.getInnerText = function(elem) {'); document.writeln(' return elem.innerText.trim();'); document.writeln('}'); document.writeln('/* *** CONFIG: List of elements for single click tracking */'); document.writeln('ctaTracking.config.floatingCTAElems = ['); document.writeln(' // EH'); document.writeln(' { brand: \'eh\', cssSelector: \'.header.sticky a\', subcategory: \'floating_buttons\', targetID: \'fixed_navigation\' },'); document.writeln(' { brand: \'eh\', cssSelector: \'.fixed-navigation a[href*="#top"]\', subcategory: \'floating_buttons\', targetID: \'fixed_navigation\' },'); document.writeln(' { brand: \'eh\', cssSelector: \'.fixed-navigation a[href*="profile/registration"]\', subcategory: \'floating_buttons\', targetID: \'fixed_navigation\' },'); document.writeln(' { brand: \'eh\', cssSelector: \'.sticky-navigation a[href*="profile/registration"]\', subcategory: \'floating_buttons\', targetID: \'fixed_navigation\' },'); document.writeln(' // PS'); document.writeln(' { brand: \'ps\', cssSelector: \'.header.sticky a[href*="#psg-regform"\', subcategory: \'floating_buttons\', targetID: \'fixed_navigation\' },'); document.writeln(' { brand: \'ps\', cssSelector: \'nav.navigation a.button[href*="profile/registration"]\', subcategory: \'floating_buttons\', targetID: \'fixed_navigation\' },'); document.writeln(' { brand: \'ps\', cssSelector: \'.header-sticky a[href*="#top"\', subcategory: \'floating_buttons\', targetID: \'fixed_navigation\' },'); document.writeln(' { brand: \'ps\', cssSelector: \'nav .pg-register-button\', subcategory: \'floating_buttons\', targetID: \'fixed_navigation\' },'); document.writeln(' // EP'); document.writeln(' { brand: \'ep\', cssSelector: \'.header.sticky a\', subcategory: \'floating_buttons\', targetID: \'fixed_navigation\' },'); document.writeln(' { brand: \'ep\', cssSelector: \'#meta-navigation__registration\', subcategory: \'floating_buttons\', targetID: \'fixed_navigation\' },'); document.writeln(' { brand: \'ep\', cssSelector: \'#sticky-header a[href*="#top"]\', subcategory: \'floating_buttons\', targetID: \'fixed_navigation\' }'); document.writeln('];'); document.writeln('ctaTracking.config.staticCTAElems = ['); document.writeln(' // EH'); document.writeln(' { brand: \'eh\', path: \'/free-dating/\', cssSelector: \'.wp-block-group__inner-container a[href*="#top"]\', subcategory: \'static_buttons\', targetID: \'cta_button\', cd2: \'HOW FREE DATING WORKS WITH EHARMONY\', cd3: ctaTracking.helpers.getInnerText },'); document.writeln(' { brand: \'eh\', path: \'/tour/\', cssSelector: \'.hentry__inner a[href*="itm="]\', subcategory: \'static_buttons\', targetID: \'cta_button\', cd2: ctaTracking.helpers.getITM, cd3: ctaTracking.helpers.getInnerText },'); document.writeln(' { brand: \'eh\', path: \'/dating-advice/\', cssSelector: \'.hentry__content.page__content a[href*="itm="]\', subcategory: \'static_buttons\', targetID: \'cta_button\', cd2: ctaTracking.helpers.getITM, cd3: ctaTracking.helpers.getInnerText },'); document.writeln(' // PS'); document.writeln(' { brand: \'ps\', path: \'/tour/\', cssSelector: \'.hentry__inner a[href*="itm="]\', subcategory: \'static_buttons\', targetID: \'cta_button\', cd2: ctaTracking.helpers.getITM, cd3: ctaTracking.helpers.getInnerText },'); document.writeln(' { brand: \'ps\', path: \'/ratgeber/\', cssSelector: \'.hentry__content.page__content.hentry__content--is-content.page__content--is-content > div:nth-child(3) a\', subcategory: \'static_buttons\', targetID: \'cta_button_1\', cd2: \'Lasst uns Dating neu starten\', cd3: ctaTracking.helpers.getInnerText },'); document.writeln(' { brand: \'ps\', path: \'/ratgeber/\', cssSelector: \'.hentry__content.page__content.hentry__content--is-content.page__content--is-content > div:nth-child(6) a\', subcategory: \'static_buttons\', targetID: \'cta_button_2\', cd2: \'Lasst uns Dating neu starten\', cd3: ctaTracking.helpers.getInnerText },'); document.writeln(' // EP'); document.writeln(' { brand: \'ep\', path: \'/tour/\', cssSelector: \'.hentry__inner a[href*="itm="]\', subcategory: \'static_buttons\', targetID: \'cta_button\', cd2: ctaTracking.helpers.getITM, cd3: ctaTracking.helpers.getInnerText },'); document.writeln(' { brand: \'ep\', path: \'/tour/\', cssSelector: \'#sidebar a[href*="itm="]\', subcategory: \'static_buttons\', targetID: \'cta_button\', cd2: ctaTracking.helpers.getITM, cd3: ctaTracking.helpers.getInnerText },'); document.writeln(' { brand: \'ep\', path: \'/magazin/\', cssSelector: \'#sidebar a\', subcategory: \'static_buttons\', targetID: \'cta_button\', cd2: ctaTracking.helpers.getITM, cd3: ctaTracking.helpers.getInnerText },'); document.writeln(' { brand: \'ep\', path: \'/\', cssSelector: \'.wp-block-psg-slider a[href*="#psg-regform"]\', subcategory: \'static_buttons\', targetID: \'cta_button\', cd2: \'So funktioniert die Partnersuche mit ElitePartner.\', cd3: ctaTracking.helpers.getInnerText },'); document.writeln(' { brand: \'ep\', path: \'/\', cssSelector: \'main > div:nth-of-type(5) a[href*="#psg-regform"]\', subcategory: \'static_buttons\', targetID: \'cta_button\', cd2: \'Lerne ElitePartner-Singles kennen!\', cd3: ctaTracking.helpers.getInnerText },'); document.writeln(' { brand: \'ep\', path: \'/\', cssSelector: \'main > div:nth-of-type(6) a[href*="#psg-regform"]\', subcategory: \'static_buttons\', targetID: \'cta_button\', cd2: \'Unsere Erfolgsgeschichten\', cd3: ctaTracking.helpers.getInnerText }'); document.writeln(' '); document.writeln('];'); document.writeln('ctaTracking.config.observedSections = ['); document.writeln(' { cssSelector: \'h1, h2\', sectionName: ctaTracking.helpers.getInnerText }'); document.writeln('];'); document.writeln('/* *** Helper: Ledger for tracking status of elements */'); document.writeln('ctaTracking.trackingStatus = {'); document.writeln(' setTracked: function(trType, elem) {'); document.writeln(' ctaTracking.trackingStatus.trackedElems[trType].push(elem);'); document.writeln(' },'); document.writeln(' isTracked: function(trType, elem) {'); document.writeln(' return (ctaTracking.trackingStatus.trackedElems[trType].indexOf(elem) > -1);'); document.writeln(' },'); document.writeln(' trackedElems: { view: [], click: [], scroll: [] }'); document.writeln('}'); document.writeln('/* *** Helper: Add click listener for floating CTA*/'); document.writeln('ctaTracking.setFloatingCTAClickListener = function (elemSelector, subcategory, targetId) {'); document.writeln(' var elems = document.querySelectorAll(elemSelector);'); document.writeln(' elems.forEach(function(elem) {'); document.writeln(' elem.addEventListener(\'click\', function () {'); document.writeln(' ctaTracking.trackEvent(subcategory, targetId, \'click\', ctaTracking.data[\'last_section\'], ctaTracking.data[\'scroll_depth\'], elem);'); document.writeln(' })'); document.writeln(' });'); document.writeln('}'); document.writeln('/* *** Helper: Add click listener for static CTA */'); document.writeln('ctaTracking.setStaticCTAClickListener = function (elemSelector, subcategory, targetId, cd2, cd3) {'); document.writeln(' var elems = document.querySelectorAll(elemSelector);'); document.writeln(' elems.forEach(function(elem) {'); document.writeln(' elem.addEventListener(\'click\', function () {'); document.writeln(' var cd2_var;'); document.writeln(' var cd3_var;'); document.writeln(' if (typeof cd2 === \'function\') {'); document.writeln(' cd2_var = cd2(elem);'); document.writeln(' } else {'); document.writeln(' cd2_var = cd2 || \'\';'); document.writeln(' }'); document.writeln(' if (typeof cd3 === \'function\') {'); document.writeln(' cd3_var = cd3(elem);'); document.writeln(' } else {'); document.writeln(' cd3_var = cd3 || \'\';'); document.writeln(' }'); document.writeln(' ctaTracking.trackEvent(subcategory, targetId, \'click\', cd2_var, cd3_var, elem);'); document.writeln(' })'); document.writeln(' });'); document.writeln('}'); document.writeln('/* *** Helper: Observe sections */'); document.writeln('ctaTracking.observeSections = function (selector, sectionName) {'); document.writeln(' var domElems = document.querySelectorAll(selector);'); document.writeln(' domElems.forEach(function(elem) {'); document.writeln(' new IntersectionObserver(function(entry) {'); document.writeln(' if(entry[0].isIntersecting) {'); document.writeln(' if (typeof sectionName === \'function\') {'); document.writeln(' ctaTracking.data.last_section = sectionName(elem);'); document.writeln(' } else {'); document.writeln(' ctaTracking.data.last_section = sectionName;'); document.writeln(' }'); document.writeln(' }'); document.writeln(' }, { root: null, rootMargin: \'0px\', threshold: 0.5 }).observe(elem);'); document.writeln(' });'); document.writeln('}'); document.writeln('/* *** Helper: Track event */'); document.writeln('ctaTracking.trackEvent = function(subcategory, targetID, action, cd2, cd3, elem) {'); document.writeln(' if (!ctaTracking.trackingStatus.isTracked(action, elem)) {'); document.writeln(' /* Log only */'); document.writeln(' if (ctaTracking.config.loggingOnly) {'); document.writeln(' console.group("Event tracked:")'); document.writeln(' console.log("%c-- category:\\t\\t" + ctaTracking.config.category, "color:green");'); document.writeln(' console.log("%c-- subcategory:\\t\\t" + subcategory, "color:green");'); document.writeln(' console.log("%c-- action:\\t\\t\\t" + action, "color:green");'); document.writeln(' console.log("%c-- target_id:\\t\\t" + targetID, "color:green");'); document.writeln(' console.log("%c-- cd2:\\t\\t" + cd2, "color:green");'); document.writeln(' console.log("%c-- cd3:\\t" + cd3, "color:green");'); document.writeln(' console.groupEnd()'); document.writeln(' } else {'); document.writeln(' document.dispatchEvent(new CustomEvent("pegLogger-logTmsEvents", {'); document.writeln(' \'detail\': {'); document.writeln(' \'category\': ctaTracking.config.category,'); document.writeln(' \'subcategory\': subcategory,'); document.writeln(' \'targetId\': targetID,'); document.writeln(' \'action\': action,'); document.writeln(' \'cd1\': \'\','); document.writeln(' \'cd2\': cd2,'); document.writeln(' \'cd3\': cd3'); document.writeln(' }'); document.writeln(' }));'); document.writeln(' }'); document.writeln(' ctaTracking.trackingStatus.setTracked(action, elem);'); document.writeln(' }'); document.writeln('}'); document.writeln('/* Set up initial listeners */'); document.writeln('ctaTracking.init = (function () {'); document.writeln(' /* Set up single click listeners for floating CTAs */'); document.writeln(' ctaTracking.config.floatingCTAElems.forEach(function (elem) {'); document.writeln(' if (elem.brand == \'eh\') {'); document.writeln(' ctaTracking.setFloatingCTAClickListener(elem.cssSelector, elem.subcategory, elem.targetID);'); document.writeln(' }'); document.writeln(' });'); document.writeln(' /* Set up single click listeners for static CTAs */'); document.writeln(' ctaTracking.config.staticCTAElems.forEach(function (elem) {'); document.writeln(' if (elem.path == ctaTracking.data[\'url_path\'] && elem.brand == \'eh\') {'); document.writeln(' ctaTracking.setStaticCTAClickListener(elem.cssSelector, elem.subcategory, elem.targetID, elem.cd2, elem.cd3);'); document.writeln(' }'); document.writeln(' });'); document.writeln(' /* Set up obververs to update last seen section */'); document.writeln(' if(!!window.IntersectionObserver) {'); document.writeln(' ctaTracking.config.observedSections.forEach(function (elem) {'); document.writeln(' ctaTracking.observeSections(elem.cssSelector, elem.sectionName);'); document.writeln(' })'); document.writeln(' } '); document.writeln(' /* Scroll depth */'); document.writeln(' window.onscroll = function() {'); document.writeln(' var scrolledRoundedPercent;'); document.writeln(' var scrolled = document.body.scrollTop || document.documentElement.scrollTop;'); document.writeln(' var scrolledDecimal = (scrolled / (document.documentElement.scrollHeight - document.documentElement.clientHeight)) * 100;'); document.writeln(' scrolledRoundedPercent = Math.floor(scrolledDecimal);'); document.writeln(' if (Math.round(scrolledDecimal * 10) == 100) {'); document.writeln(' scrolledRoundedPercent = 100;'); document.writeln(' }'); document.writeln(' ctaTracking.data.scroll_depth = scrolledRoundedPercent.toString();'); document.writeln(' }'); document.writeln(' })();'); document.writeln('<\/scr'+'ipt>'); document.writeln('<\/scr'+'ipt>'); document.writeln(''); document.writeln('<\/scr'+'ipt>'); document.writeln(''); document.writeln('window.dataLayer = window.dataLayer || [];'); document.writeln('function gtag(){dataLayer.push(arguments);}'); document.writeln('gtag(\'js\', new Date());'); document.writeln('<\/scr'+'ipt>'); document.writeln(''); document.writeln(' var gtag_config = {};'); document.writeln(' gtag_config.conversion_event = \'page_view\';'); document.writeln(' if (\'\' == \'registration\' || \'\' == \'testfinish\') {'); document.writeln(' gtag_config.conversion_event = \'\';'); document.writeln(' }'); document.writeln(' if (\'\' === \'purchase\' && \'\' === \'ft\') {'); document.writeln(' gtag_config.conversion_event = \'purchase\';'); document.writeln(' }'); document.writeln(' if (\'\' !== \'\') {'); document.writeln(' gtag_config.conversion_event = \'login\';'); document.writeln(' }'); document.writeln(' gtag_config.is_attributed = /\\d+_\\d+_(3|1)2006_.+/.test(\'\');'); document.writeln(' gtag_config.trackGtagConversionEvent = function(conversion_string, conversion_event) {'); document.writeln(' var account_id = conversion_string.split(\'/\')[0];'); document.writeln(' conversion_event_prefix = { \'registration\': \'REG\', \'testfinish\': \'TF\', \'purchase\': \'SALE\' }[conversion_event];'); document.writeln(' '); document.writeln(' var gtag_config_params_ev = { \'send_to\': conversion_string, \'transaction_id\': conversion_event_prefix + \'-\' }'); document.writeln(' if(conversion_event == \'purchase\') {'); document.writeln(' gtag_config_params_ev[\'value\'] = parseFloat(\'\') || 0;'); document.writeln(' gtag_config_params_ev[\'currency\'] = \'\';'); document.writeln(' } '); document.writeln(' gtag(\'config\', account_id);'); document.writeln(' gtag(\'event\', \'conversion\', gtag_config_params_ev);'); document.writeln(' }'); document.writeln(' gtag_config.trackGtagPageViewEvent = function(account_id) {'); document.writeln(' gtag_config_params_view = {'); document.writeln(' \'data_psc\': \'\','); document.writeln(' \'data_lp\': \'\','); document.writeln(' \'data_red\': \'\','); document.writeln(' \'data_tfd\': \'\','); document.writeln(' \'data_pte\': \'\','); document.writeln(' \'data_oty\': \'\','); document.writeln(' \'data_pda\': \'\','); document.writeln(' \'data_st\': \'home\','); document.writeln(' \'data_ut\': \'firsttime_visitor\','); document.writeln(' \'data_rgid\': \'\''); document.writeln(' };'); document.writeln(' gtag(\'config\', account_id, { \'send_page_view\': false });'); document.writeln(' gtag(\'event\', gtag_config.conversion_event, gtag_config_params_view);'); document.writeln(' }'); document.writeln(' gtag_config.events = {};'); document.writeln(' gtag_config.events.registration = ['); document.writeln(' // eH_US_Registration_Pixel'); document.writeln(' [\'attributed\', \'AW-765290997/mZygCIK2uaMBEPXT9ewC\'],'); document.writeln(' // eh_US_Reg_Pixel_last_click'); document.writeln(' [\'attributed\', \'AW-765290997/zPuXCKrMt-kCEPXT9ewC\'],'); document.writeln(' // eh_US_Reg_alwaysserve_pixel'); document.writeln(' [\'all\', \'AW-765290997/1JBICMeT4okCEPXT9ewC\'],'); document.writeln(' // eh_US_Reg_Pixel_alwaysserved'); document.writeln(' [\'all\', \'AW-765290997/INw9CMzn3-kCEPXT9ewC\']'); document.writeln(' ];'); document.writeln(' gtag_config.events.testfinish = ['); document.writeln(' // eh_US_TF_pixel_DDA'); document.writeln(' [\'attributed\', \'AW-765290997/mUd2CMu1uOkCEPXT9ewC\'],'); document.writeln(' // eh_US_TF_pixel (YouTube)'); document.writeln(' [\'all\', \'AW-765290997/ZtO3CLfooYkCEPXT9ewC\']'); document.writeln(' ];'); document.writeln(' gtag_config.events.purchase = ['); document.writeln(' // eh_US_OEFT_pixel_ATTRIBUTION'); document.writeln(' [\'attributed\', \'AW-765290997/vbRpCPzCuOkCEPXT9ewC\'],'); document.writeln(' // eh_US_OEFT_pixel (YouTube)'); document.writeln(' [\'all\', \'AW-765290997/k56dCMDZ-IgCEPXT9ewC\']'); document.writeln(' ];'); document.writeln(' gtag_config.events.page_view = [\'AW-765290997\'];'); document.writeln(' // Conversions'); document.writeln(' if([\'registration\', \'testfinish\', \'purchase\'].includes(gtag_config.conversion_event)) {'); document.writeln(' gtag_config.events[gtag_config.conversion_event].forEach(function(conf) {'); document.writeln(' if(conf[0] == \'all\' || (conf[0] == \'attributed\' && gtag_config.is_attributed)) {'); document.writeln(' gtag_config.trackGtagConversionEvent(conf[1], gtag_config.conversion_event);'); document.writeln(' }'); document.writeln(' });'); document.writeln(' };'); document.writeln(' // Page views'); document.writeln(' gtag_config.events.page_view.forEach(function(acc_id) {'); document.writeln(' gtag_config.trackGtagPageViewEvent(acc_id);'); document.writeln(' });'); document.writeln(' '); document.writeln('<\/scr'+'ipt>'); document.writeln(''); document.writeln('var scrollTracking = { config: { category: \'content_page\', loggingOnly: false }, helpers: {}, customFunctions: {} }'); document.writeln('/* *** Helper: Ledger for tracking status of elements */'); document.writeln('scrollTracking.trackingStatus = {'); document.writeln(' setTracked: function(trType, elem) {'); document.writeln(' scrollTracking.trackingStatus.trackedElems[trType].push(elem);'); document.writeln(' },'); document.writeln(' isTracked: function(trType, elem) {'); document.writeln(' return (scrollTracking.trackingStatus.trackedElems[trType].indexOf(elem) > -1);'); document.writeln(' },'); document.writeln(' trackedElems: { view: [], click: [], scroll: [] }'); document.writeln('}'); document.writeln('/* *** Helper: Track event */'); document.writeln('scrollTracking.trackEvent = function(subcategory, targetID, action, cd1, cd2, cd3, elem) {'); document.writeln(' if (!scrollTracking.trackingStatus.isTracked(action, elem)) {'); document.writeln(' /* Log only */'); document.writeln(' if (scrollTracking.config.loggingOnly) {'); document.writeln(' console.group("Event tracked:")'); document.writeln(' console.log("%c-- category:\\t\\t" + scrollTracking.config.category, "color:green");'); document.writeln(' console.log("%c-- subcategory:\\t\\t" + subcategory, "color:green");'); document.writeln(' console.log("%c-- action:\\t\\t\\t" + action, "color:green");'); document.writeln(' console.log("%c-- target_id:\\t\\t" + targetID, "color:green");'); document.writeln(' console.log("%c-- cd1 (text):\\t\\t" + cd1, "color:green");'); document.writeln(' console.log("%c-- cd2 (URL):\\t\\t" + cd2, "color:green");'); document.writeln(' console.log("%c-- cd3 (custom):\\t" + cd3, "color:green");'); document.writeln(' console.groupEnd()'); document.writeln(' } else {'); document.writeln(' document.dispatchEvent(new CustomEvent("pegLogger-logTmsEvents", {'); document.writeln(' \'detail\': {'); document.writeln(' \'category\': scrollTracking.config.category,'); document.writeln(' \'subcategory\': subcategory,'); document.writeln(' \'targetId\': targetID,'); document.writeln(' \'action\': action,'); document.writeln(' \'cd1\': cd1,'); document.writeln(' \'cd2\': cd2,'); document.writeln(' \'cd3\': cd3'); document.writeln(' }'); document.writeln(' }));'); document.writeln(' }'); document.writeln(' scrollTracking.trackingStatus.setTracked(action, elem);'); document.writeln(' }'); document.writeln('}'); document.writeln('/* Set up initial listeners */'); document.writeln('scrollTracking.init = (function () {'); document.writeln(' /* Scroll depth */'); document.writeln(' window.onscroll = function() {'); document.writeln(' var scrolledRoundedPercent;'); document.writeln(' var scrolled = document.body.scrollTop || document.documentElement.scrollTop;'); document.writeln(' var scrolledDecimal = (scrolled / (document.documentElement.scrollHeight - document.documentElement.clientHeight)) * 10;'); document.writeln(' scrolledRoundedPercent = Math.floor(scrolledDecimal) * 10;'); document.writeln(' if (Math.round(scrolledDecimal * 10) == 100) {'); document.writeln(' scrolledRoundedPercent = 100;'); document.writeln(' }'); document.writeln(' scrollTracking.trackEvent("scroll", scrolledRoundedPercent.toString() + \'%\', "scroll", \'\', \'\', \'\', scrolledRoundedPercent);'); document.writeln(' }'); document.writeln('})();'); document.writeln('<\/scr'+'ipt>');