//JS Para trackeo de aplicaciones. var trackObject={id:"no"}; var testabConfigEvent = {'test_ab':false,event_name: "test_ab", event_option: '1', testId:''}; var filetypes = /\.(pdf|xlsx?|docx?|txt|rtf|csv|exe|key|pp(s|t|tx)|7z|pkg|rar|gz|zip|avi|mov|mp4|mpe?g|wmv|midi?|mp3|wav|wma)$/i; window.dataLayer = window.dataLayer || []; function gtag(){window.dataLayer.push(arguments);} // Init, necesita un objeto con propiedades ent (entorno) establecida function bde_initGtm(oParam){ //Parámetros obligatorios try{ trackObject.ent = (typeof(oParam.ent)!= 'undefined')?oParam.ent.toUpperCase():function(){throw "Error. No se ha definido el entorno"}(); }catch(e){console.error(e);return false;} //Parámetros opcionales trackObject.evento = (typeof(oParam.ev) != 'undefined')?oParam.ev:false; trackObject.autoEvntPersonal = (typeof(oParam.AutoEv) != 'undefined')?true:false; if(trackObject.evento!=false){ trackObject.dLayer=oParam.dLayer; } var sGtmId = (trackObject.ent=="P")?trackObject.app:"DEV"; doTrackGTM(); } function bde_trackGTM(oDataLayer) { gtag('event','ga4_event',oDataLayer); } function doTrackGTM(){ if (typeof trackObject != 'undefined') { (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-KZV85WF'); } //añadimos evento testab si no está vacio y si estamos en las rutas correctas if(typeof testabConfig !== 'undefined') { //testabConfigEvent = {'test_ab':testabConfig['testabEnabled'],event_name: "test_ab", 'event_option':testabConfig.audienceValue}; testabConfigEvent.test_ab = testabConfig.testabEnabled; testabConfigEvent.event_name = 'test_ab'; testabConfigEvent.event_option = typeof testabConfig.audienceValue !== 'undefined' ? testabConfig.audienceValue: 'Sin audiencia'; testabConfigEvent.testId = testabConfig.testId; if(testabConfigEvent.test_ab && testabConfigEvent.event_option !== 'Sin audiencia') { if (testabConfig.debugEnabled) console.log('Enviando: ' + JSON.stringify(testabConfigEvent)); bde_trackGTM(testabConfigEvent); } } //evento añadido en el init además del pageview if(trackObject.evento!=false){ bde_trackGTM(trackObject.evento); } jQuery(document).ready(function(jQuery) { var baseHref = ''; if (jQuery('base').attr('href') != undefined){ baseHref = jQuery('base').attr('href'); } jQuery('a').each(function() { var href = jQuery(this).attr('href'); if(href){ if ((href.startsWith("/") || (href.match(document.domain)))) { jQuery(this).click(function() { bdeClick('navigation_click', this); }); } if (href.match(/^mailto\:/i)) { jQuery(this).click(function() { var mailLink = href.replace(/^mailto\:/i, ''); bdeClick('action_click_mailto',this); }); } if (href.match(/^tel\:/i)) { jQuery(this).click(function() { var mailLink = href.replace(/^tel\:/i, ''); bdeClick('action_click_tel',this); }); } // descargas de archivos if (href.match(filetypes)) { jQuery(this).attr('data-click','fileDownload'); jQuery(this).click(function() { bdeClick('download_file',this); }); } // eventos personalizados var dataEvent = dataEvent2 = jQuery(this).attr("data-event"); if(dataEvent){ if(dataEvent.includes('share')){dataEvent='share'}; switch(dataEvent){ case 'download-audio': jQuery(this).click(function() { bdeClick('click_descarga_audio',this); }); break; case 'block-highlighted': jQuery(this).attr('data-option','destacado'); jQuery(this).click(function() { bdeClick('click_destacado',this); }); break; case 'block-card-news': jQuery(this).attr('data-option','actualidad'); jQuery(this).click(function() { bdeClick('click_destacado',this); }); break; case 'carrusel': jQuery(this).click(function() { bdeClick('click_carrusel',this); }); break; case 'share': jQuery(this).attr('data-description',dataEvent2); jQuery(this).click(function() { bdeClick('click_share',this); }); break; } } if(href.includes('https://app.bde.es/pmk/CIR_Visual_')){ jQuery(this).click(function() { bdeClick('click_cir_powerBI',this); }); } if(href.includes('https://app.powerbi.com/')){ jQuery(this).click(function() { bdeClick('click_powerBI',this); }); } } }); var oAudio = document.getElementsByTagName("audio"); for(i=0;i0){ var oUrlParams = new URLSearchParams(window.location.search); if(oUrlParams.get("T1") != null){ sTextoBuscado=oUrlParams.get("T1"); }else{ if(oUrlParams.get("A1") != null){ sTextoBuscado=oUrlParams.get("A1"); }else{ sTextoBuscado=oUrlParams.get("search"); } } for(var i=0;i0){ var oUrlParams = new URLSearchParams(window.location.search); var sTextoBuscado = (oUrlParams.get("T1") != null)?oUrlParams.get("T1"):oUrlParams.get("A1"); for(var i=0;i0){ var oUrlParams = new URLSearchParams(window.location.search); if(oUrlParams.get("T1") != null){ sTextoBuscado=oUrlParams.get("T1"); }else{ if(oUrlParams.get("A1") != null){ sTextoBuscado=oUrlParams.get("A1"); }else{ sTextoBuscado=oUrlParams.get("search"); } } for(var i=0;i0){ var oUrlParams = new URLSearchParams(window.location.search); var sTextoBuscado = (oUrlParams.get("T1") != null)?oUrlParams.get("T1"):oUrlParams.get("A1"); for(var i=0;i