1console.log('PASSOU MARFEEL'); 2 3function trackMarfeel(trackingName, additionalData = {}) { 4 if(typeof window.marfeel === "undefined"){ 5 console.log("Marfeel não esta ativo"); 6 return; 7 } 8 window.marfeel.cmd.push(['compass', function(compass) { 9 if(typeof additionalData.meta !== 'undefined'){ 10 compass.trackConversion(trackingName, additionalData.meta); 11 }else{ 12 compass.trackConversion(trackingName); 13 } 14 }]); 15 console.log("Marfeel tracking: " + trackingName); 16 if(typeof additionalData.meta !== 'undefined'){ 17 console.log("Com dados adicionais: ", additionalData.meta); 18 } 19} 20 21let hasTrackedOfertaView = false; 22 23document.addEventListener('DOMContentLoaded', () => { 24 const marfeelConvertionObj = { 25 ".assinetop": "Site - Botão Assine - Header", 26 ".assine-btn a": "Site - Botão Assine - Hambunger", 27 ".mobile-assine": "Site - Botão Assine - Mobile", 28 ".botaoAssineWidgetCarousel": "Site - Botão Assine - Revista Rodapé", 29 ".linkCapa": "Site - Botão Assine - Revista Rodapé", 30 ".botao-assine-onboarding": "Site - Botão Assine - Onboarding", 31 32 ".card-paywall-button": "Paywall - Botão Assine Paywall", 33 ".card-paywall-footer .btn-offer-google": "Paywall - Botão Assine Google", 34 35 "#popup_oferta .botao": "Ofertas - Botão Assine - Popup Oferta", 36 "#popup_oferta .close": "Ofertas - Botão Close - Popup Oferta", 37 "#popup_oferta .naoquero": "Ofertas - Botão Não Quero - Popup Oferta", 38 39 "#popup_oferta2 .botao": "Ofertas - Botão Assine - Popup Oferta Digital", 40 "#popup_oferta2 .close2": "Ofertas - Botão Close - Popup Oferta Digital", 41 "#popup_oferta2 .naoquero2": "Ofertas - Botão Não Quero - Popup Oferta Digital", 42 43 "#popup_oferta3 .botao":"Ofertas - Botão Assine - Popup Captação de Lead", 44 "#popup_oferta3 .close3": "Ofertas - Botão Close - Popup Captação de Lead", 45 46 ".botoes .botao": "Ofertas - Botão Assine", 47 ".botoes .btn-offer-google": "Ofertas - Botão Assine - Oferta com Google", 48 ".oferta-receber .url": "Ofertas - Botão Assine - Bloco Quero Receber Oferta", 49 50 ".resumo-abril .dropdown-resumo": "Resumo - Click Matéria", 51 ".resumo-abril .section-header": "Resumo - Click Matéria em Tópicos", 52 53 ".block.edicao-semana .edition .link": "Bloco edição da Semana - Botão Assine", 54 ".block.cinquenta-anos a .bt-assine": "Bloco 50 anos - Botão Assine", 55 56 ".oferta-signature .btn": "Ofertas - Botão Signature", 57 58 ".google-preferred-source-btn": "Acessibilidade - Botão Google Fonte Preferida", 59 }; 60 61 // Dispara a visualização de ofertas uma vez por carregamento de página 62 if (!hasTrackedOfertaView && window.location.href.includes('.abril.com.br/ofertas/')) { 63 hasTrackedOfertaView = true; 64 trackMarfeel("Ofertas - View"); 65 } 66 67 // Criamos uma string única com todos os seletores: ".assinetop, .assine-btn a, ..." 68 const allSelectors = Object.keys(marfeelConvertionObj).join(','); 69 70 document.addEventListener('click', (event) => { 71 72 console.log('PASSOU MARFEEL - CLIQUE MARCA'); 73 // O closest() verifica se o clique foi no elemento ou em algo dentro dele 74 const targetElement = event.target.closest(allSelectors); 75 76 if (targetElement) { 77 // Agora precisamos descobrir qual chave do objeto deu o "match" 78 for (const selector in marfeelConvertionObj) { 79 if (targetElement.matches(selector)) { 80 const trackingValue = marfeelConvertionObj[selector]; 81 trackMarfeel(trackingValue); 82 break; // Paramos no primeiro encontro para ser mais rápido 83 } 84 } 85 } 86 }); 87 88 // Tracking de cliques nas marcas do header (swiper) 89 document.addEventListener('click', (event) => { 90 const brandLink = event.target.closest('.swiper-wrapper .swiper-slide a'); 91 if (brandLink) { 92 const img = brandLink.querySelector('img'); 93 const brandName = img ? img.alt : 'Desconhecida'; 94 trackMarfeel('Marcas Header - ' + brandName); 95 } 96 }); 97 98 // checa se o paywall existe e se ele foi aberto, se sim, 99 // dispara o evento de visualização do paywall 100 const paywall_marfeel = document.querySelector("#ip_abril"); 101 102 if(paywall_marfeel){ 103 let hasTracked = false;
104 // Cria o observador 105 const observer_paywall_marfeel = new MutationObserver(mutations => { 106 mutations.forEach(mutation => { 107 if (mutation.attributeName === "style") { 108 const displayAtual = window.getComputedStyle(paywall_marfeel).display; 109 110 if (displayAtual === "block" && !hasTracked) { 111 hasTracked = true; 112 if(typeof wp_paywall_vars !== "undefined"){ 113 if(typeof wp_paywall_vars['tipo_paywall'] !== "undefined"){ 114 /* 115 if(wp_paywall_vars['tipo_paywall'] === "closed"){ 116 trackMarfeel("Paywall - Matéria Fechada"); 117 } 118 if(wp_paywall_vars['tipo_paywall'] === "accounted"){ 119 trackMarfeel("Paywall - Matéria Contabilizada"); 120 } 121 */ 122 trackMarfeel("Paywall - Bloqueio de Leitura"); 123 observer_paywall_marfeel.disconnect(); 124 } 125 } 126 } 127 } 128 }); 129 }); 130 131 // Configura o observador para monitorar mudanças nos atributos 132 observer_paywall_marfeel.observe(paywall_marfeel, { attributes: true, attributeFilter: ["style"] }); 133 } 134 135 // Detecção de elementos multimÃdia/interativos na página 136 const mediaDetectors = [ 137 { 138 name: 'Audima', 139 selectors: ['script[src*="audima"]', '#audima-player', '.audima'] 140 }, 141 { 142 name: 'Riddle', 143 selectors: ['.riddle_target', 'script[src*="riddle.com"]', 'iframe[src*="riddle.com"]'] 144 }, 145 { 146 name: 'Dailymotion', 147 selectors: ['iframe[src*="dailymotion.com"]', 'script[src*="dmcdn.net"]'] 148 }, 149 { 150 name: 'Web Stories', 151 selectors: ['amp-story-player', 'a[href*="/web-stories/"]', '[data-webstories]'] 152 } 153 ]; 154 155 mediaDetectors.forEach(({ name, selectors }) => { 156 const found = selectors.some(sel => document.querySelector(sel)); 157 if (found) { 158 trackMarfeel('Conteúdo - ' + name); 159 } 160 }); 161}); 162 163// esse código foi criado para ficar observando se algum evento do google é executado 164// neste momento a gente faz a checagem e dispara o nosso evento se for um evento que queremos mapear 165// Garante que o dataLayer existe 166window.dataLayer = window.dataLayer || []; 167 168// Salva o push original 169const originalPush = dataLayer.push; 170 171// Sobrescreve o push com uma lógica de verificação 172dataLayer.push = function() { 173 // Executa o push original para não quebrar o Google Analytics 174 originalPush.apply(this, arguments); 175 176 // Analisa o que foi enviado 177 const eventData = arguments[0]; 178 179 if (eventData && eventData.event === 'begin_checkout' || eventData[1] === 'begin_checkout') { 180 trackMarfeel("Checkout - Inicia a compra"); 181 } 182 if (eventData && eventData.event === 'purchase' || eventData[1] === 'purchase') { 183 let tipoPagMarfeel = ""; 184 const tipoPagText = document.querySelector(".tipo_pedido"); 185 186 if(tipoPagText){ 187 if(tipoPagText.innerText !== ""){ 188 tipoPagMarfeel = " - " + tipoPagText.innerText; 189 } 190 } 191 trackMarfeel("Checkout - Purchase", { 192 meta: { 193 produto: eventData[2].items[0].item_name, 194 meio_pagamento: eventData[2].meio_pag_pedido || '', 195 valor: eventData[2].value, 196 voucher: eventData[2].coupon || '', 197 } 198 }); 199 } 200};
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.