console.log("events lookup, in reg case"); buildEventSend("registration", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'registrationComplete': //console.log("registration triggered"); var lastArticleInfo = _satellite.getVar('TMG Last Article Info'); if(typeof dataLayer.registration != "undefined" && dataLayer.registration != ""){ //s.eVar31 = dataLayer.registration.registrationType; //s.eVar32 = dataLayer.registration.emailOptIn; registrationType = dataLayer.registration.registrationType; emailOptIn = dataLayer.registration.emailOptIn; } //s.events = typeof s.events == 'undefined' || s.events == "" ? 'event22' : s.events + ',' + 'event22'; //if (typeof s.linkTrackEvents != "undefined" && s.linkTrackEvents != "") //{ //s.linkTrackEvents = s.linkTrackEvents + ",event22"; //} //else //{ //s.linkTrackEvents = "event22"; //} //s.eVar9 = _satellite.getVar('TMG Cookie customerID'); customerID = _satellite.getVar('TMG Cookie customerID'); if (typeof obApi != 'undefined') { obApi('track', 'Event Registration'); } // Add Mbox for target // adobe.target.trackEvent({ // 'mbox': 'tmg.registrationComplete' // }); /**window.tmgAdobeLaunchRules.mboxTracking({ 'mbox': 'tmg.registrationComplete' });**/ tags = ""; if(tmgFunctions.getCookie("artTags")) { tags = tmgFunctions.getCookie("artTags"); tags = tags.replace(/,/g, ";"); //s.list2 = tags; } eventInfo = { "registrationType": registrationType, "emailOptIn": emailOptIn, "articleTags": tags, "customerID": customerID }; buildEventSend("registrationComplete", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'registrationUpdate': if(!(new RegExp(/customer\/secure\/register/).test(window.location.href))){ //s.eVar31 = dataLayer.registration.registrationType; //s.eVar32 = dataLayer.registration.emailOptIn; registrationType = dataLayer.registration.registrationType; emailOptIn = dataLayer.registration.emailOptIn; //s.events = typeof s.events == 'undefined' || s.events == "" ? 'event148' : s.events + ',' + 'event148'; //if (typeof s.linkTrackEvents != "undefined" && s.linkTrackEvents != "") //{ //s.linkTrackEvents = s.linkTrackEvents + ",event148"; //} //else //{ //s.linkTrackEvents = "event148"; //} eventInfo = { "registrationType": registrationType, "emailOptIn": emailOptIn }; buildEventSend("registrationUpdate", eventInfo, subInfo, newsLetterInfo, pageInfo); } break; case 'newsletterSignup': var newsletterType = _satellite.getVar('TMG DL Newsletter Type'); eventInfo = { "newsletterInfoType": newsletterType }; //if(!(new RegExp(/customer\/secure\/register/).test(window.location.href))){ //s.events = typeof s.events == 'undefined' ? 'event14' : s.events + ',' + 'event14'; //s.events = typeof s.events == 'undefined' || s.events == "" ? 'event14' : s.events + ',' + 'event14'; //s.events = 'event14'; //s.linkTrackEvents = s.events; //} buildEventSend("newsLetterSignup", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'subscriptionCheckout': console.log("WEB SDK CHECK HERE start checkout fire"); tmgFunctions.setCookie('DtmSubIcid', _satellite.getVar('TMG icid'), (60 * 60 * 24 * 1000)); //s.events = 'event45'; //linkTrackEvents = "event45"; //s.events = typeof s.events == 'undefined' ? 'event45' : s.events + ',' + 'event45'; //s.linkTrackEvents = typeof s.linkTrackEvents == 'undefined' ? 'event45' : s.linkTrackEvents + ',' + 'event45'; //s.eVar61 = dataLayer.subscription.productID; productID = dataLayer.subscription.productID; if( new RegExp(/monthly/).test(_satellite.getVar("TMG Subscription Offer ID"))){ //s.eVar62 = "Monthly"; subDuration = "Monthly"; }else{ //s.eVar62 = "Annually"; subDuration = "Annually"; } //s.linkTrackVars += 'events,' + _satellite.getVar('TMG linkTrackVars'); //console.log("end checkout fire"); eventInfo = { "productID": productID, "subInfoSubDuration":subDuration }; buildEventSend("subscriptionCheckout", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'subscriptionAccount': //s.events = "event157,event45"; //s.linkTrackEvents = "event157,event45"; //s.events = "event45"; //s.linkTrackEvents = "event45"; //s.eVar61 = dataLayer.subscription.productID; //s.eVar61 = _satellite.getVar("TMG Sub Product ID"); productID = _satellite.getVar("TMG Sub Product ID"); //s.eVar62 = dataLayer.subscription.paymentPlan; subPaymentPlan = dataLayer.subscription.paymentPlan; //s.linkTrackVars += 'events,' + _satellite.getVar('TMG linkTrackVars'); eventInfo = { "productID": productID, "subPaymentPlan":subPaymentPlan }; buildEventSend("subscriptionCheckout", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'accordionClick': var rollupContentPath = _satellite.getVar('TMG DL rollupContentPath'); pageName = rollupContentPath ? rollupContentPath : window.location.pathname.replace(/\/$/, ''); //s.events = "event81"; //s.linkTrackEvents = "event81"; //s.eVar162 = dataLayer.faq; faq = dataLayer.faq; //s.linkTrackVars += 'events,' + _satellite.getVar('TMG linkTrackVars'); pageInfo = { "pageName": pageName }; eventInfo = { "faq": faq }; buildEventSend("accordionClick", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'subscriptionBilling': console.log("subscription billing fired"); //s.events = 'event155'; //s.linkTrackEvents = "event155"; //s.eVar61 = dataLayer.subscription.productID; //s.eVar61 = _satellite.getVar("TMG Sub Product ID"); //s.eVar62 = dataLayer.subscription.paymentPlan; //s.linkTrackVars += 'events,' + _satellite.getVar('TMG linkTrackVars'); productID = _satellite.getVar("TMG Sub Product ID"); subPaymentPlan = dataLayer.subscription.paymentPlan; eventInfo = { "productID": productID, "subPaymentPlan":subPaymentPlan }; buildEventSend("subscriptionBilling", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'subscriptionPayment': console.log("subscription payment fired"); //s.events = 'event156'; //s.linkTrackEvents = "event156"; //s.eVar61 = dataLayer.subscription.productID; //s.eVar61 = _satellite.getVar("TMG Sub Product ID"); //s.eVar62 = dataLayer.subscription.paymentPlan; //s.linkTrackVars += 'events,' + _satellite.getVar('TMG linkTrackVars'); productID = _satellite.getVar("TMG Sub Product ID"); subPaymentPlan = dataLayer.subscription.paymentPlan; eventInfo = { "productID": productID, "subPaymentPlan":subPaymentPlan }; buildEventSend("subscriptionPayment", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'cancellationStepWhy': //s.events = 'event216'; //s.linkTrackEvents = 'event216'; buildEventSend("cancellationStepWhy", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'cancellationStepOffer': var cancellationReasonA = dataLayer.cancelReason; var cancellationReasonB = dataLayer.cancelSubreason; var cancelReason = cancellationReasonA; if(typeof cancellationReasonB != "undefined" && cancellationReasonB != ""){ cancelReason = cancelReason+";"+cancellationReasonB; } //s.eVar19 = cancelReason; //s.events = 'event217'; //s.linkTrackEvents = 'event217'; eventInfo = { "cancelReason": cancelReason }; buildEventSend("cancellationStepOffer", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'cancellationStepStay': //s.events = 'event218'; //s.linkTrackEvents = 'event218'; buildEventSend("cancellationStepOffer", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'cancellationStepLeave': //s.events = 'event219'; //s.linkTrackEvents = 'event219'; buildEventSend("cancellationStepLeave", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'restartSubscription': //s.events = 'event220'; //s.linkTrackEvents = 'event220'; buildEventSend("restartSubscription", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'upgradeOptions': //s.events = 'event225'; //s.linkTrackEvents = 'event225'; buildEventSend("upgradeOptions", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'upgradePayment': //s.events = 'event226'; //s.linkTrackEvents = 'event226'; buildEventSend("upgradePayment", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'upgradeConfirmation': //s.eVar61 = dataLayer.subscription.productID ? dataLayer.subscription.productID : dataLayer.subscription.productId; //s.eVar62 = dataLayer.subscription.paymentPlan; //s.eVar63 = dataLayer.subscription.paymentType; productID = dataLayer.subscription.productID ? dataLayer.subscription.productID : dataLayer.subscription.productId; subPaymentPlan = dataLayer.subscription.paymentPlan; paymentType = dataLayer.subscription.paymentType; //s.events = 'event227'; //s.linkTrackEvents = 'event227'; eventInfo = { "productID": productID, "subPaymentPlan":subPaymentPlan, "paymentType": paymentType }; buildEventSend("upgradeConfirmation", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'subscriptionConfirmation': console.log("subscription confirmation triggered"); if(!(tmgFunctions.getCookie("dtm_subComplete3"))){ //s.eVar61 = dataLayer.subscription.productID ? dataLayer.subscription.productID : dataLayer.subscription.productId; //s.eVar62 = dataLayer.subscription.paymentPlan; //s.eVar63 = dataLayer.subscription.paymentType; productID = dataLayer.subscription.productID ? dataLayer.subscription.productID : dataLayer.subscription.productId; subPaymentPlan = dataLayer.subscription.paymentPlan; paymentType = dataLayer.subscription.paymentType; //if(tmgFunctions.getCookie('DtmSubIcid')) //{ //s.eVar202 = tmgFunctions.getCookie('DtmSubIcid'); //tmgFunctions.deleteCookie('DtmSubIcid'); //} tags = ""; if(tmgFunctions.getCookie("artTags")) { tags = tmgFunctions.getCookie("artTags"); tags = tags.replace(/,/g, ";"); //s.list2 = tags; } console.log("s.events here is: "+s.events); //s.events = typeof s.events == 'undefined'||s.events == "" ? 'event46' : s.events + ',' + 'event46'; //s.linkTrackEvents = s.events; console.log("s.events sub: "+s.events); console.log("s.linktrack sub: "+s.linkTrackEvents); // adobe.target.trackEvent({ // 'mbox': 'target-global-mbox', // 'params': { // 'productId': dataLayer.subscription.productID, // 'paymentPlan': dataLayer.subscription.paymentPlan, // 'paymentType': dataLayer.subscription.paymentType // } // }); _satellite.logger.info('Rule: TMG Page Events -> Action: WEB SDK - Custom Code: about to fire alloy(sendEvent) with "decisionScopes": ["__view__"]'); /**window.tmgAdobeLaunchRules.mboxTracking({ 'mbox': 'target-global-mbox', 'params': { 'productId': dataLayer.subscription.productID, 'paymentPlan': dataLayer.subscription.paymentPlan, 'paymentType': dataLayer.subscription.paymentType } });**/ console.log("after first target event"); // adobe.target.trackEvent({ // 'mbox': 'tmg.subscriptionComplete', // 'params': { // 'productId': dataLayer.subscription.productID, // 'paymentPlan': dataLayer.subscription.paymentPlan, // 'paymentType': dataLayer.subscription.paymentType // } // }); _satellite.logger.info('Rule: TMG Page Events -> Action: WEB SDK - Custom Code: about to fire alloy(sendEvent) with "decisionScopes": ["tmg.subscriptionComplete"]'); /**window.tmgAdobeLaunchRules.mboxTracking({ 'mbox': 'tmg.subscriptionComplete', 'params': { 'productId': dataLayer.subscription.productID, 'paymentPlan': dataLayer.subscription.paymentPlan, 'paymentType': dataLayer.subscription.paymentType } });**/ console.log("after second target event"); subType = _satellite.getVar('TMG Subscription Type'); expDate = new Date(); var year = expDate.getFullYear(); var month = expDate.getMonth(); var day = expDate.getDate(); var c = new Date(year + 2, month, day); eventInfo = { "productID": productID, "subPaymentPlan":subPaymentPlan, "paymentType": paymentType, "articleTags": tags }; buildEventSend("subscriptionConfirmation", eventInfo, subInfo, newsLetterInfo, pageInfo); //document.cookie = "tmgSubscriberType="+subType+";domain=.telegraph.co.uk;path=/;expires="+c+";"; document.cookie = "dtm_subComplete3=1;expire=; path=/; domain=telegraph.co.uk"; }else{ console.log("nosub"); } break; //HERE SAM THIS IS HOW FAR YOU GOT case "onClickDowngrade": //s.events = 'event238'; //s.linkTrackEvents = 'event238'; buildEventSend("subscriptionConfirmation", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case "oneClickDowngradeSuccess": //s.events = 'event239'; //s.linkTrackEvents = 'event239'; buildEventSend("onClickDowngradeSuccess", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case "paymentDetailsUpdated": //s.events = 'event210'; //s.linkTrackEvents = 'event210'; buildEventSend("onClickDowngradeSuccess", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case "newsLetterStep": //console.log("newsLetterstep Reached 666666666666666"); var rollupContentPath = _satellite.getVar('TMG DL rollupContentPath'); //s.pageName = rollupContentPath ? rollupContentPath : window.location.pathname.replace(/\/$/, ''); //console.log("pageName is currently: "+s.pageName); //s.eVar2 = s.pageName; //s.eVar223 = dataLayer.previousStepSkipped; pageName = rollupContentPath ? rollupContentPath : window.location.pathname.replace(/\/$/, ''); previousStepSkipped = dataLayer.previousStepSkipped; //s.events = "event263"; //s.linkTrackEvents = "event263"; //s.list1 = dataLayer.newsLetterType; newsletterType = dataLayer.newsletterType; //s.events = typeof s.events == 'undefined' ? 'event263, event266' : s.events + ',' + 'event263, event266'; //s.linkTrackEvents = typeof s.linkTrackEvents == 'undefined' ? 'event263, event266' : s.linkTrackEvents + ',' + 'event263, event266'; pageInfo = { "pageName": pageName }; eventInfo = { "previousStepSkipped": previousStepSkipped, "newsletterInfoType": newsletterType }; subInfo = ""; buildEventSend("newsLetterStep", eventInfo, subInfo, newsLetterInfo, pageInfo); //console.log("s.events news: "+s.events); //console.log("s.linktrack news: "+s.linkTrackEvents); break; case 'editionAppSMSLink': console.log("editionappstep Reached"); var rollupContentPath = _satellite.getVar('TMG DL rollupContentPath'); //s.pageName = rollupContentPath ? rollupContentPath : window.location.pathname.replace(/\/$/, ''); //console.log("pageName is currently: "+s.pageName); //s.eVar2 = s.pageName; //s.eVar223 = dataLayer.previousStepSkipped; pageName = rollupContentPath ? rollupContentPath : window.location.pathname.replace(/\/$/, ''); previousStepSkipped = dataLayer.previousStepSkipped; console.log("editionappstep Reached 2"); //if(new RegExp(/event46/).test(s.events)){ //s.events = s.events + ",event256"; //console.log("editionappstep Reached 3"); //s.linkTrackEvents = s.events; //console.log("editionappstep Reached 4"); //}else{ //s.events = "event256"; //console.log("editionappstep Reached 3"); //s.linkTrackEvents = "event256"; //console.log("editionappstep Reached 4"); //} pageInfo = { "pageName": pageName }; eventInfo = { "previousStepSkipped": previousStepSkipped }; newsletterInfo = ""; subInfo = ""; buildEventSend("editionAppSMSLink", eventInfo, subInfo, newsletterInfo, pageInfo); break; case 'podcastLink': //console.log("podcaststep Reached"); var rollupContentPath = _satellite.getVar('TMG DL rollupContentPath'); //s.pageName = rollupContentPath ? rollupContentPath : window.location.pathname.replace(/\/$/, ''); //console.log("pageName is currently: "+s.pageName); //s.eVar2 = s.pageName; //s.eVar223 = dataLayer.previousStepSkipped; //s.events = "event257"; //s.linkTrackEvents = "event257"; pageName = rollupContentPath ? rollupContentPath : window.location.pathname.replace(/\/$/, ''); previousStepSkipped = dataLayer.previousStepSkipped; pageInfo = { "pageName": pageName }; eventInfo = { "previousStepSkipped": previousStepSkipped }; newsletterInfo = ""; subInfo = ""; buildEventSend("podcastLink", eventInfo, subInfo, newsletterInfo, pageInfo); break; case 'articleLinks': //console.log("articlestep Reached"); //s.pageName = rollupContentPath ? rollupContentPath : window.location.pathname.replace(/\/$/, ''); //console.log("pageName is currently: "+s.pageName); //s.eVar2 = s.pageName; //s.eVar223 = dataLayer.previousStepSkipped; //s.events = "event258"; //s.linkTrackEvents = "event258"; var rollupContentPath = _satellite.getVar('TMG DL rollupContentPath'); pageName = rollupContentPath ? rollupContentPath : window.location.pathname.replace(/\/$/, ''); previousStepSkipped = dataLayer.previousStepSkipped; pageInfo = { "pageName": pageName }; eventInfo = { "previousStepSkipped": previousStepSkipped }; newsletterInfo = ""; subInfo = ""; buildEventSend("articleLinks", eventInfo, subInfo, newsletterInfo, pageInfo); break; case 'return': //s.eVar223 = dataLayer.previousStepSkipped; //s.events = "event259"; //s.linkTrackEvents = "event259"; previousStepSkipped = dataLayer.previousStepSkipped; eventInfo = { "previousStepSkipped": previousStepSkipped }; buildEventSend("return", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'secondToSpare': //s.eVar223 = dataLayer.previousStepSkipped; //s.events = "event260"; //s.linkTrackEvents = "event260"; previousStepSkipped = dataLayer.previousStepSkipped; eventInfo = { "previousStepSkipped": previousStepSkipped }; buildEventSend("secondToSpare", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'onboardingGooglePlayApp': //s.eVar223 = dataLayer.previousStepSkipped; //s.eVar225 = "google play"; //s.events = "event261"; //s.linkTrackEvents = "event261"; previousStepSkipped = dataLayer.previousStepSkipped; eventInfo = { "previousStepSkipped": previousStepSkipped, "editionAppLinkName":"google play" }; buildEventSend("onboardingAppClick", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'onboardingAppleStoreApp': //s.eVar223 = dataLayer.previousStepSkipped; //s.eVar225 = "apple store"; //s.events = "event261"; //s.linkTrackEvents = "event261"; previousStepSkipped = dataLayer.previousStepSkipped; eventInfo = { "previousStepSkipped": previousStepSkipped, "editionAppLinkName":"apple store" }; buildEventSend("onboardingAppClick", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'onboardingPodcastSelection': //s.eVar223 = dataLayer.previousStepSkipped; //s.eVar224 = dataLayer.podcastName; //s.events = "event262"; //s.linkTrackEvents = "event262"; previousStepSkipped = dataLayer.previousStepSkipped; podcastName = dataLayer.podcastName; eventInfo = { "previousStepSkipped": previousStepSkipped, "podcastName":podcastName }; buildEventSend("onboardingPodcastSelection", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'onboardingArticlesClicked': //s.events = "event264"; //s.linkTrackEvents = "event264"; buildEventSend("onboardingArticlesClicked", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'onboardingWhatsAppLaunched': //s.events = "event265"; //s.linkTrackEvents = "event265"; buildEventSend("onboardingWhatsAppLaunched", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'subscriptionPaymentplanupsell': //s.events = 'event267'; //s.linkTrackEvents = "event267"; //console.log("check for dL stuff: "+dataLayer.subscription.productID+", "+dataLayer.subscription.paymentPlan); //s.eVar61 = dataLayer.subscription.productID; //s.eVar62 = dataLayer.subscription.paymentPlan; //s.linkTrackVars += 'events,' + _satellite.getVar('TMG linkTrackVars'); productID = _satellite.getVar("TMG Sub Product ID"); subPaymentPlan = dataLayer.subscription.paymentPlan; eventInfo = { "productID": productID, "subPaymentPlan":subPaymentPlan }; buildEventSend("subscriptionPaymentplanupsell", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'subscriptionPaymentplanchoice': //s.events = 'event267'; //s.linkTrackEvents = "event267"; //console.log("check for dL stuff: "+dataLayer.subscription.productID+", "+dataLayer.subscription.paymentPlan); //s.eVar61 = dataLayer.subscription.productID; //s.eVar62 = dataLayer.subscription.paymentPlan; //s.linkTrackVars += 'events,' + _satellite.getVar('TMG linkTrackVars'); productID = _satellite.getVar("TMG Sub Product ID"); subPaymentPlan = dataLayer.subscription.paymentPlan; eventInfo = { "productID": productID, "subPaymentPlan":subPaymentPlan }; buildEventSend("subscriptionPaymentplanupsell", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'cancellationReason': //s.events = "event216"; //s.linkTrackEvents = "event216"; buildEventSend("cancellationStepWhy", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'cancellationWhyStay': //s.events = "event217"; //s.linkTrackEvents = "event217"; //s.eVar19 = dataLayer.cancellationReason; //s.linkTrackVars += 'events,' + _satellite.getVar('TMG linkTrackVars'); cancellationReason = dataLayer.cancellationReason; eventInfo = { "cancelReason":cancellationReason } buildEventSend("cancellationStepOffer", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'cancellationNewOffer': //if(typeof s.events != "undefined" || s.events != "") //{ //s.events = s.events + ", event218"; //}else{ //s.events = "event218"; //} //s.eVar209 = dataLayer.discount; //s.prop30 = dataLayer.offerID; //s.linkTrackEvents = s.events; discount = dataLayer.discount; offerID = dataLayer.offerID; eventInfo = { "discount":discount, "offerID":offerID } buildEventSend("cancellationStepStay", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'cancellationSecondOffer': //if(typeof s.events != "undefined" || s.events != "") //{ // s.events = s.events + ", event287"; //}else{ //s.events = "event287"; //} //s.eVar209 = dataLayer.discount; //s.prop30 = dataLayer.offerID; //s.linkTrackEvents = s.events; discount = dataLayer.discount; offerID = dataLayer.offerID; eventInfo = { "discount":discount, "offerID":offerID } buildEventSend("cancellationSecondOffer", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'offerCardChange': eventCheck = s.events; //if(!(new RegExp(/event52/).test(eventCheck))){ //if(typeof s.events != "undefined" || s.events != "") //{ //s.events = s.events + ", event52"; //console.log("added here: "+s.events); // }else{ // s.events = "event52"; //} //} //s.eVar141 = dataLayer.offerICID; //s.eVar75 = dataLayer.offerVariation; //s.linkTrackEvents = s.events; icid = dataLayer.offerICID; offerVariation = dataLayer.offerVariation; eventInfo = { "icid":icid, "targetCustom":offerVariation } buildEventSend("offerCardChange", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'cancellationConfirmation': eventCheck = ""; if(dataLayer.cancelling == "yes"){ //s.events = "event241"; eventCheck = "cancellationLeaveConfirm"; }else if(dataLayer.cancelling == "no"){ //s.events = "event243"; eventCheck = "cancellationStayConfirm"; } //s.linkTrackEvents = s.events; buildEventSend(eventCheck, eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'subscriptionThankYouPage': eventCheck = ""; if(dataLayer.cancelling == "yes"){ //s.events = "event242"; eventCheck = "cancellationLeaveThankYou"; }else if(dataLayer.cancelling == "no"){ //s.events = "event244"; eventCheck = "cancellationStayThankYou"; } //s.linkTrackEvents = s.events; buildEventSend(eventCheck, eventInfo, subInfo, newsLetterInfo, pageInfo); break; //case 'expressCheckout': //s.events = "event272"; //s.linkTrackEvents = "event272"; //s.events = typeof s.events == 'undefined' ? 'event272' : s.events + ',' + 'event272'; //s.linkTrackEvents = typeof s.linkTrackEvents == 'undefined' ? 'event272' : s.linkTrackEvents + ',' + 'event272'; //break; case 'expressCheckoutStep1Complete': //s.events = typeof s.events == 'undefined' ? 'event273' : s.events + ',' + 'event273'; //s.linkTrackEvents = typeof s.linkTrackEvents == 'undefined' ? 'event273' : s.linkTrackEvents + ',' + 'event273'; //console.log("user status check: "+dataLayer.userStatus); //s.eVar235 = dataLayer.userStatus; backupVisitorStatus = dataLayer.userStatus; //s.events = "event273"; //s.linkTrackEvents = "event273"; eventInfo = { "backupVisitorStatus":backupVisitorStatus } buildEventSend("expressCheckoutStep1Complete", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'smsSent': //s.events = "event293"; //s.linkTrackEvents = s.events; buildEventSend("smsSent", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'expressCheckoutComplete': //s.events = typeof s.events == 'undefined' ? 'event274' : s.events + ',' + 'event274'; //s.linkTrackEvents = typeof s.linkTrackEvents == 'undefined' ? 'event274' : s.linkTrackEvents + ',' + 'event274'; buildEventSend("expressCheckoutComplete", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'bonusSubSplash': //s.events = typeof s.events == 'undefined' ? 'event274' : s.events + ',' + 'event274'; //s.linkTrackEvents = typeof s.linkTrackEvents == 'undefined' ? 'event274' : s.linkTrackEvents + ',' + 'event274'; //s.events = 'event276'; //s.linkTrackEvents = 'event276'; buildEventSend("bonusSubsSplashScreen", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'bonusSubEmail': //s.events = 'event277'; //s.linkTrackEvents = 'event277'; buildEventSend("bonusSubEmail", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'bonusSubLogin': //s.events = 'event278'; //s.linkTrackEvents = 'event278'; buildEventSend("bonusSubLogin", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'bonusSubRegister': //s.events = 'event279'; //s.linkTrackEvents = 'event279'; buildEventSend("bonusSubRegister", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'bonusSubExistingSub': //s.events = 'event280'; //s.linkTrackEvents = 'event280'; //s.eVar210 = dataLayer.exsitingSubType; eventInfo = { "backupVisitorStatus":backupVisitorStatus } buildEventSend("bonusSubExistingSub", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'bonusSubConfirmation': //s.events = 'event281, event46'; //s.linkTrackEvents = 'event281, event46'; buildEventSend("bonusSubConfirmation", eventInfo, subInfo, newsLetterInfo, pageInfo); if(!(tmgFunctions.getCookie("dtm_subComplete"))){ //s.eVar61 = dataLayer.subscription.productID ? dataLayer.subscription.productID : dataLayer.subscription.productId; //s.eVar62 = dataLayer.subscription.paymentPlan; //s.eVar63 = dataLayer.subscription.paymentType; productID = dataLayer.subscription.productID ? dataLayer.subscription.productID : dataLayer.subscription.productId; subPaymentPlan = dataLayer.subscription.paymentPlan; paymentType = dataLayer.subscription.paymentType; //if(tmgFunctions.getCookie('DtmSubIcid')) //{ //s.eVar202 = tmgFunctions.getCookie('DtmSubIcid'); //tmgFunctions.deleteCookie('DtmSubIcid'); //} tags = ""; if(tmgFunctions.getCookie("artTags")) { tags = tmgFunctions.getCookie("artTags"); tags = tags.replace(/,/g, ";"); //s.list2 = tags; } console.log("s.events here is: "+s.events); //s.events = typeof s.events == 'undefined'||s.events == "" ? 'event46' : s.events + ',' + 'event46'; //s.linkTrackEvents = s.events; console.log("s.events sub: "+s.events); console.log("s.linktrack sub: "+s.linkTrackEvents); // adobe.target.trackEvent({ // 'mbox': 'target-global-mbox', // 'params': { // 'productId': dataLayer.subscription.productID, // 'paymentPlan': dataLayer.subscription.paymentPlan, // 'paymentType': dataLayer.subscription.paymentType // } // }); _satellite.logger.info('Rule: TMG Page Events -> Action: WEB SDK - Custom Code: about to fire alloy(sendEvent) with "decisionScopes": ["__view__"]'); /**window.tmgAdobeLaunchRules.mboxTracking({ 'mbox': 'target-global-mbox', 'params': { 'productId': dataLayer.subscription.productID, 'paymentPlan': dataLayer.subscription.paymentPlan, 'paymentType': dataLayer.subscription.paymentType } });**/ console.log("after first target event"); // adobe.target.trackEvent({ // 'mbox': 'tmg.subscriptionComplete', // 'params': { // 'productId': dataLayer.subscription.productID, // 'paymentPlan': dataLayer.subscription.paymentPlan, // 'paymentType': dataLayer.subscription.paymentType // } // }); _satellite.logger.info('Rule: TMG Page Events -> Action: WEB SDK - Custom Code: about to fire alloy(sendEvent) with "decisionScopes": ["tmg.subscriptionComplete"]'); /**window.tmgAdobeLaunchRules.mboxTracking({ 'mbox': 'tmg.subscriptionComplete', 'params': { 'productId': dataLayer.subscription.productID, 'paymentPlan': dataLayer.subscription.paymentPlan, 'paymentType': dataLayer.subscription.paymentType } });**/ console.log("after second target event"); subType = _satellite.getVar('TMG Subscription Type'); expDate = new Date(); var year = expDate.getFullYear(); var month = expDate.getMonth(); var day = expDate.getDate(); var c = new Date(year + 2, month, day); eventInfo = { "productID": productID, "subPaymentPlan":subPaymentPlan, "paymentType": paymentType, "articleTags": tags }; buildEventSend("subscriptionConfirmation", eventInfo, subInfo, newsLetterInfo, pageInfo); //document.cookie = "tmgSubscriberType="+subType+";domain=.telegraph.co.uk;path=/;expires="+c+";"; //document.cookie = "dtm_subComplete=1;expire=; path=/; domain=telegraph.co.uk"; }else{ console.log("nosub"); } //buildEventSend("subscriptionConfirmation", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'offerRedemptionStart': //s.events = 'event295'; //s.linkTrackEvents = s.events; buildEventSend("offerRedemptionStart", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'offerRedemptionEmailForm': //s.events = 'event296'; //s.linkTrackEvents = s.events; buildEventSend("offerRedemptionEmailForm", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'offerRedemptionEmailRecognised': //s.events = 'event297'; //s.linkTrackEvents = s.events; buildEventSend("offerRedemptionEmailRecognised", eventInfo, subInfo, newsLetterInfo, pageInfo); break case 'offerRedemptionSwitch': //s.events = 'event298'; //s.linkTrackEvents = s.events; buildEventSend("offerRedemptionSwitch", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'offerRedemptionUpgrade': //s.events = 'event305'; //s.linkTrackEvents = s.events; buildEventSend("offerRedemptionUpgrade", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'offerRedemptionSubscription': //s.events = 'event299'; //s.linkTrackEvents = s.events; buildEventSend("offerRedemptionSubscription", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'offerRedemptionSubscriptionComplete': //s.events = ""; //if(!(tmgFunctions.getCookie("dtm_subComplete"))){ //s.eVar61 = dataLayer.subscription.productID ? dataLayer.subscription.productID : dataLayer.subscription.productId; //s.eVar62 = dataLayer.subscription.paymentPlan; //s.eVar63 = dataLayer.subscription.paymentType; productID = dataLayer.subscription.productID ? dataLayer.subscription.productID : dataLayer.subscription.productId; subPaymentPlan = dataLayer.subscription.paymentPlan; paymentType = dataLayer.subscription.paymentType; //if(tmgFunctions.getCookie('DtmSubIcid')) //{ //s.eVar202 = tmgFunctions.getCookie('DtmSubIcid'); //tmgFunctions.deleteCookie('DtmSubIcid'); //} tags = ""; if(tmgFunctions.getCookie("artTags")) { tags = tmgFunctions.getCookie("artTags"); tags = tags.replace(/,/g, ";"); //s.list2 = tags; } console.log("s.events here is: "+s.events); //s.events = typeof s.events == 'undefined'||s.events == "" ? 'event46' : s.events + ',' + 'event46'; //s.linkTrackEvents = s.events; console.log("s.events sub: "+s.events); console.log("s.linktrack sub: "+s.linkTrackEvents); // adobe.target.trackEvent({ // 'mbox': 'target-global-mbox', // 'params': { // 'productId': dataLayer.subscription.productID, // 'paymentPlan': dataLayer.subscription.paymentPlan, // 'paymentType': dataLayer.subscription.paymentType // } // }); _satellite.logger.info('Rule: 3rd Party|Adobe: TMG Event onchange -> Action: WEB SDK - Custom Code: about to fire alloy(sendEvent) with "decisionScopes": ["__view__"]'); /**window.tmgAdobeLaunchRules.mboxTracking({ 'mbox': 'target-global-mbox', 'params': { 'productId': dataLayer.subscription.productID, 'paymentPlan': dataLayer.subscription.paymentPlan, 'paymentType': dataLayer.subscription.paymentType } });**/ console.log("after first target event"); // adobe.target.trackEvent({ // 'mbox': 'tmg.subscriptionComplete', // 'params': { // 'productId': dataLayer.subscription.productID, // 'paymentPlan': dataLayer.subscription.paymentPlan, // 'paymentType': dataLayer.subscription.paymentType // } // }); _satellite.logger.info('Rule: 3rd Party|Adobe: TMG Event onchange -> Action: WEB SDK - Custom Code: about to fire alloy(sendEvent) with "decisionScopes": ["tmg.subscriptionComplete"]'); /**window.tmgAdobeLaunchRules.mboxTracking({ 'mbox': 'tmg.subscriptionComplete', 'params': { 'productId': dataLayer.subscription.productID, 'paymentPlan': dataLayer.subscription.paymentPlan, 'paymentType': dataLayer.subscription.paymentType } });**/ console.log("after second target event"); subType = _satellite.getVar('TMG Subscription Type'); expDate = new Date(); var year = expDate.getFullYear(); var month = expDate.getMonth(); var day = expDate.getDate(); var c = new Date(year + 2, month, day); eventInfo = { "productID": productID, "subPaymentPlan":subPaymentPlan, "paymentType": paymentType, "articleTags": tags }; buildEventSend("subscriptionConfirmation", eventInfo, subInfo, newsLetterInfo, pageInfo); //document.cookie = "tmgSubscriberType="+subType+";domain=.telegraph.co.uk;path=/;expires="+c+";"; //document.cookie = "dtm_subComplete=1;expire=; path=/; domain=telegraph.co.uk"; //}else{ console.log("nosub"); } buildEventSend("offerRedemptionSubscriptionComplete", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'offerRedemptionExistingPrint': //s.events = 'event301'; //s.linkTrackEvents = s.events; buildEventSend("offerRedemptionExistingPrint", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'offerRedemptionCantRedeem': //s.events = 'event302'; //s.linkTrackEvents = s.events; buildEventSend("offerRedemptionCantRedeem", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'offerRedemptionCodeRedeemed': //s.events = 'event303'; //s.linkTrackEvents = s.events; buildEventSend("offerRedemptionCodeRedeemed", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'offerRedemptionGenericError': //s.events = 'event304'; //s.linkTrackEvents = s.events; buildEventSend("offerRedemptionGenericError", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'ExpressGetStarted': //s.events = 'event302'; //s.linkTrackEvents = s.events; buildEventSend("ExpressGetStarted", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'expressSubscriptionPayment': console.log("WEB SDK CHECK HERE start checkout fire"); tmgFunctions.setCookie('DtmSubIcid', _satellite.getVar('TMG icid'), (60 * 60 * 24 * 1000)); //s.events = 'event45'; //linkTrackEvents = "event45"; //s.events = typeof s.events == 'undefined' ? 'event45' : s.events + ',' + 'event45'; //s.linkTrackEvents = typeof s.linkTrackEvents == 'undefined' ? 'event45' : s.linkTrackEvents + ',' + 'event45'; //s.eVar61 = dataLayer.subscription.productID; productID = dataLayer.subscription.productID; if( new RegExp(/monthly/).test(_satellite.getVar("TMG Subscription Offer ID"))){ //s.eVar62 = "Monthly"; subDuration = "Monthly"; }else{ //s.eVar62 = "Annually"; subDuration = "Annually"; } //s.linkTrackVars += 'events,' + _satellite.getVar('TMG linkTrackVars'); //console.log("end checkout fire"); eventInfo = { "productID": productID, "subInfoSubDuration":subDuration }; buildEventSend("subscriptionCheckout", eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'cancellationConfirmation': if(dataLayer.cancelling == "yes"){ //s.events = "event241"; eventCheck = "cancellationLeaveConfirm"; }else if(dataLayer.cancelling == "no"){ //s.events = "event243"; eventCheck = "cancellationStayConfirm"; } //s.linkTrackEvents = s.events; buildEventSend(eventCheck, eventInfo, subInfo, newsLetterInfo, pageInfo); break; case 'subscriptionThankYouPage': if(dataLayer.cancelling == "yes"){ //s.events = "event242"; eventCheck = "cancellationLeaveThankYou"; }else if(dataLayer.cancelling == "no"){ //s.events = "event244"; eventCheck = "cancellationStayThankYou"; } buildEventSend(eventCheck, eventInfo, subInfo, newsLetterInfo, pageInfo); break; } } }