1let countInterval = 0; 2const baseUrlParams = new URLSearchParams(window.location.search); 3const patterns = ['/credit-cards/','capitalone']; 4const excludePattern = [ 5 '/credit-cards/member-benefits/', 6 'discovercard.com/', 7 '/credit-cards/contact-us/', 8 '/credit-cards/contactless/', 9 '/credit-cards/cardmember-agreement/', 10 '/credit-cards/exclusives/sharediscover/', 11 '/credit-cards/language-services/', 12 '/credit-cards/browser-support/', 13 '/credit-cards/add-authorized-user/', 14 '/credit-cards/balance-transfer-offers/', 15 '/credit-cards/protection-solutions/identity-theft-protection/product-details.html', 16 '/credit-cards/cash-back/cashback-calendar.html' 17 ]; 18 19function getEcid(){ 20 countInterval++; 21 if (typeof alloy === 'function' && countInterval <= 20) { 22 console.log('Adobe Experience Platform Web SDK (Alloy) is initialized.'); 23 alloy("getIdentity") 24 .then(function(result) { 25 console.log("ecid received:",result.identity); 26 updateCheckCta(result.identity.ECID); 27 }) 28 .catch(function(error) { 29 console.error("Error retrieving ECID:", error); 30 noEcid(); 31 }); 32 } else { 33 console.log('Adobe Experience Platform Web SDK (Alloy) is NOT initialized.'); 34 if (countInterval > 20) { 35 noEcid(); 36 } else { 37 setTimeout(function() { getEcid(); },50); 38 } 39 } 40} 41 42function noEcid() { 43 const randomNumberValue = crypto.randomUUID().replaceAll('-','').substring(0,16); 44 const defaultEcidValue = String("DFSNOECID"+Date.now()+ randomNumberValue); 45 updateCheckCta(defaultEcidValue); 46 dataLayerClickEventPush({ customecid: defaultEcidValue}); 47 console.log('Default Ecid value for No ECID Scenario',defaultEcidValue); 48} 49 50function updateCheckCta(ecid) { 51 52 const validParam = [ 53 "pageFileId", 54 "sc", 55 "srccode", 56 "iq_id", 57 "campaignid", 58 "cmpgnid", 59 "scmpgnid", 60 "irgwc", 61 "gclid", 62 "sid", 63 "pid", 64 "aid", 65 "ef_id", 66 "plasticTypeCode", 67 "SCMPGN", 68 "cardArtType", 69 "sku", 70 "source", 71 "extole_shareable_code", 72 "channel", 73 "flavor", 74 "fbclid", 75 "msclkid", 76 "gclsrc", 77 "gad_source", 78 "gad_campaignid" 79 ]; 80 let externalIdVal = ""; 81 validParam.forEach(function(name) { 82 if (baseUrlParams.has(name)) { 83 let qValue = baseUrlParams.get(name); 84 externalIdVal = externalIdVal + name + "=" + qValue + "&"; 85 } 86 }); 87 externalIdVal = externalIdVal + "dfs_ecid=" + ecid; 88 externalIdVal = encodeURIComponent(externalIdVal); 89 console.log("final url: ",externalIdVal); 90 91 $('a[href]').not('[href=""], [href="#"], [href="undefined"], [href^="javascript:"]').each(function(){ 92 const hrefValue = $(this).attr('href'); 93 const isMatch = patterns.some(p => hrefValue.toLowerCase().includes(p.toLowerCase())); 94 const isExclude = excludePattern.some(p => hrefValue.toLowerCase().includes(p.toLowerCase())); 95 96 if(!isMatch || isExclude) return; 97 98 console.log("Before Change: ", hrefValue); 99 100 const redurl = new URL(hrefValue, location.origin); 101 redurl.searchParams.set("external_id",externalIdVal); 102 $(this).attr('href', redurl.toString()); 103 104 console.log("Updated URL: ", redurl.toString()); 105 }); 106} 107 108 109$(document).ready(function() { 110 getEcid(); 111}); 112 113
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.