1jQuery(document).ready(function() { 2 // Si venimos de un submit anterior, guardamos y repetimos el CTA en la página de "gracias" 3 // para que al inspeccionar el dataLayer también se vea ahÃ. 4 try { 5 var href = (window.location && window.location.href) ? window.location.href : ''; 6 var persisted = sessionStorage.getItem('mx_last_ga_cta_label'); 7 if (persisted && href.indexOf('gracias') > -1) { 8 envia_ga_event('conversion', 'cta', persisted, '-'); 9 sessionStorage.removeItem('mx_last_ga_cta_label'); 10 } 11 } catch (e) { 12 // Nada: solo es para debugging/visibilidad del evento. 13 } 14 15 jQuery('.selector_ordenacion_vo').on('change', function() { 16 var formulario = jQuery('#admin_ajax_listado_vo'); 17 var data = formulario.serializeArray(); 18 jQuery('.mascara_cargando').addClass("visible"); 19 jQuery.ajax({ 20 type: 'POST', 21 url: ajax_data.ajax_url, 22 data: { 23 datos: data, 24 action: formulario.attr('action') 25 }, 26 success: function(response) { 27 jQuery('.contenido_listado_ocasion').html(response); 28 jQuery('.mascara_cargando').removeClass("visible"); 29 } 30 }); 31 }); 32 33 /** EVENTOS GA **/ 34 35 /** GA Event cuando el usuario hace scroll (25%, 50%, 75%, 100%) **/ 36 var distinto_porcentaje = 0; 37 window.addEventListener('scroll', function() { 38 var portentaje = amountscrolled(); 39 if ((portentaje === 25 || portentaje === 50 || portentaje === 75 || portentaje === 100) && portentaje !== distinto_porcentaje) { 40 console.log(portentaje); 41 distinto_porcentaje = portentaje; 42 envia_ga_event('interaccion', 'scroll', 'scroll_' + portentaje, portentaje); 43 } 44 }); 45 46 /** GA Event cuando el usuario hace click en Cómo llegar **/ 47 jQuery('.contacto--sede--gmaps-link').on('click', function () { 48 envia_ga_event('interaccion', 'clic_como_llegar', encodeURIComponent(jQuery(this).data('nombre_sede')), '-'); 49 }); 50 51 /** GA Event cuando el usuario hace click en un banner del carrusel **/ 52 jQuery('.home-banner--swipe .swiper-slide').on('click', function() { 53 envia_ga_event('interaccion', 'clic_carrusel', encodeURIComponent(jQuery(this).attr("title")), '-'); 54 }); 55 56 /** GA Event cuando el usuario hace click en un elemento del carrusel de gama **/ 57 jQuery('.home .gama--swipe .swiper-slide').on('click', function() { 58 envia_ga_event('interaccion', 'clic_carrusel', encodeURIComponent(jQuery(this).find('.gama--swipe--nombre').text()), '-'); 59 }); 60 61 /** GA Event cuando el usuario hace click en el pop-up de oferta **/ 62 jQuery('.evento_cta_promos_popup').on('click', function() { 63 envia_ga_event('interaccion', 'clic_ver_ofertas', 'pop-up', '-'); 64 }); 65 66 /** GA Event cuando el usuario hace click en contactar del banner de inactividad **/ 67 jQuery('.container-inactividad-promo a.boton').on('click', function() { 68 envia_ga_event('interaccion', 'contactar_base', document.location.href, '-'); 69 }); 70 71 /** GA Event cuando el usuario hace click en el area de una promoción **/ 72 jQuery('.promos--list--item').on('click', function() { 73 envia_ga_event('interaccion', 'clic_promo', encodeURIComponent(jQuery(this).find('.promos--list--item--titulo').html()), '-'); 74 }); 75 76 /** GA Event cuando el usuario hace click en el botón saber más de una promoción, de coche vo o noticia **/ 77 jQuery('.promos--list--item--cta, .vos--list--item--cta, .noticias--list--item--cta').on('click', function() { 78 envia_ga_event('interaccion', 'clic_saber_mas', jQuery(this).closest('a').attr("href"), '-'); 79 }); 80 81 /** GA Event cuando el usuario hace click en el botón ver promociones desde un modelo de gama **/ 82 jQuery('.ver_promociones_gama_mazda_event').on('click', function() { 83 envia_ga_event('interaccion', 'clic_ver_promociones', document.location.href, '-'); 84 });
85 86 /** GA Event cuando el usuario hace click en el botón descubrir toda la gama **/ 87 jQuery('.descubrir_gama_event').on('click', function() { 88 envia_ga_event('interaccion', 'clic_descubrir_gamas', document.location.href, '-'); 89 }); 90 91 /** GA Event cuando el usuario hace hover tanto con la ubicación como en el teléfono (ambos en la cabecera) **/ 92 jQuery('.cabecera--ubicacion, .cabecera--telefono').on('mouseenter', function() { 93 envia_ga_event('interaccion', 'hover', jQuery(this).data('event'), '-'); 94 }); 95 96 /** GA Event cuando el usuario hace click en un teléfono de la cabecera **/ 97 jQuery('.llamanos_event').on('click', function() { 98 envia_ga_event('conversion', 'llamanos', jQuery(this).data('event'), '-'); 99 }); 100 101 /** GA Event cuando el usuario hace click en el botón ver modelos **/ 102 jQuery('.ver_modelos_event').on('click', function() { 103 envia_ga_event('interaccion', 'clic_ver_modelos', document.location.href, '-'); 104 }); 105 106 /** GA Event cuando el usuario hace click en el botón lo quiero, dentro de la ficha vo **/ 107 jQuery('.lo_quiero_event').on('click', function() { 108 envia_ga_event('conversion', 'clic_lo_quiero', document.location.href, '-'); 109 }); 110 111 /** GA Event cuando el usuario hace click en el botón lo quiero, dentro de la ficha vo **/ 112 jQuery('.cabecera--branding--logo').on('click', function() { 113 envia_ga_event('interaccion', 'clic_logo', document.location.href, '-'); 114 }); 115 116 /** GA Event cuando el usuario hace click en términos y condiciones (footer) **/ 117 jQuery('.terminos_condiciones_event').on('click', function() { 118 envia_ga_event('interaccion', 'footer', 'terminos y condiciones', '-'); 119 }); 120 121 /** GA Event cuando el usuario hace click en privacidad (footer) **/ 122 jQuery('.privacidad_event').on('click', function() { 123 envia_ga_event('interaccion', 'footer', 'privacidad', '-'); 124 }); 125 126 /** GA Event cuando el usuario hace click en cookies (footer) **/ 127 jQuery('.cookies_event').on('click', function() { 128 envia_ga_event('interaccion', 'footer', 'cookies', '-'); 129 }); 130 131 /** GA Event cuando el usuario hace click en contacta con nosotros (menú lateral) **/ 132 jQuery('.menuitem--contacto').on('click', function() { 133 envia_ga_event('interaccion', 'botonera', 'contacta', '-'); 134 }); 135 136 /** GA Event cuando el usuario hace click en cita previa taller (menú lateral) **/ 137 jQuery('.menuitem--cita').on('click', function() { 138 envia_ga_event('interaccion', 'botonera', 'cita_previa', '-'); 139 }); 140 141 /** GA Event cuando el usuario hace click en cita previa taller (menú lateral) **/ 142 jQuery('.menuitem--ofertas').on('click', function() { 143 envia_ga_event('interaccion', 'botonera', 'solicita_oferta', '-'); 144 }); 145 146 /** GA Event cuando el usuario hace click en prueba de conducción (menú lateral) **/ 147jQuery('.menuitem--testdrive').on('click', function() { 148 envia_ga_event('interaccion', 'botonera', 'test_drive', '-'); 149 }); 150 151 /* 152 * LEGACY (precaución / rollback): 153 * Eventos GA especÃficos por módulo Forminator. 154 * Actualmente están desactivados porque el handler global calcula y envÃa el `conversion/cta` 155 * usando el módulo que disparó el submit. 156 * 157 * Si hay que volver atrás, descomentar este bloque. 158 */ 159 /* 160 jQuery('#forminator-module-631').on('forminator:form:submit:success', function( event, formData ) { 161 var select_3 = "{}"; 162 if (formData && typeof formData.forEach === 'function') { 163 formData.forEach( function(valor, indice, array) { 164 if( indice === "select-3"){ select_3 = valor; } 165 }); 166 } else { 167 console.warn('formData (module-631) no es array:', formData); 168 } 169 envia_ga_event('conversion', 'cta', 'conversion:TestDriveRequest:'+select_3, '-'); 170 console.log("TEST DRIVE -> event: ga-event, categoria: conversion, accion: cta, label: conversion:TestDriveRequest:"+select_3); 171 });
172 173 jQuery('#forminator-module-578').on('forminator:form:submit:success', function( event, formData ) { 174 var select_3 = "{}"; 175 if (formData && typeof formData.forEach === 'function') { 176 formData.forEach( function(valor, indice, array) { 177 if( indice === "select-3"){ select_3 = valor; } 178 }); 179 } else { 180 console.warn('formData (module-578) no es array:', formData); 181 } 182 envia_ga_event('conversion', 'cta', 'conversion:RequestAQuote:'+select_3, '-'); 183 console.log("OFERTA PERSONALIZADA -> event: ga-event, categoria: conversion, accion: cta, label: conversion:RequestAQuote:"+select_3); 184 }); 185 186 jQuery('#forminator-module-576').on('forminator:form:submit:success', function( event, formData ) { 187 var select_3 = "{}"; 188 if (formData && typeof formData.forEach === 'function') { 189 formData.forEach( function(valor, indice, array) { 190 if( indice === "select-3"){ select_3 = valor; } 191 }); 192 } else { 193 console.warn('formData (module-576) no es array:', formData); 194 } 195 envia_ga_event('conversion', 'cta', 'conversion:RequestAQuote:'+select_3, '-'); 196 console.log("INACTIVIDAD -> event: ga-event, categoria: conversion, accion: cta, label: conversion:RequestAQuote:"+select_3); 197 }); 198 199 jQuery('#forminator-module-630').on('forminator:form:submit:success', function( event, formData ) { 200 if( jQuery("#id_modelo_maestro").text() == "" ){ 201 var id_maestro_gama = "{}"; 202 }else{ 203 var id_maestro_gama = "{"+jQuery("#id_modelo_maestro").text()+"}"; 204 } 205 envia_ga_event('conversion', 'cta', 'conversion:RequestAQuote:'+id_maestro_gama, '-'); 206 console.log("OFERTA GAMA -> event: ga-event, categoria: conversion, accion: cta, label: conversion:RequestAQuote:'+id_maestro_gama); 207 }); 208 */ 209 210 /** GA Event cuando se rellena correctamente un formulario de forminator **/ 211 jQuery(document).on('forminator:form:submit:success', function(event, formData) { 212 // Evento genérico (ya existÃa) para saber que el submit fue OK. 213 envia_ga_event('conversion', 'formulario_OK', document.location.href, '-'); 214 215 // Evento especÃfico del formulario (evitamos depender de forminator-module-XXX fijo). 216 try { 217 var $moduleRoot = (event && event.target) ? jQuery(event.target).closest('[id^="forminator-module-"]') : jQuery(); 218 219 var hasMaestro = $moduleRoot.find('#id_modelo_maestro').length > 0; 220 var hasSelect3Dom = $moduleRoot.find('[name="select-3"], #select-3, [id="select-3"]').length > 0; 221 222 var select_3 = "{}"; 223 var foundSelect3 = false; 224 if (formData && typeof formData.forEach === 'function') { 225 formData.forEach(function(valor, indice) { 226 if (indice === "select-3") { select_3 = valor; foundSelect3 = true; } 227 }); 228 } else if (hasSelect3Dom) { 229 // Fallback: intentar leer el valor desde el DOM si formData no viene como array. 230 var $select3 = $moduleRoot.find('[name="select-3"], #select-3, [id="select-3"]').first(); 231 if ($select3 && $select3.length) { 232 select_3 = $select3.val() || "{}"; 233 foundSelect3 = true; 234 } 235 } 236 237 var url = (window.location && window.location.href) ? window.location.href : ""; 238 var label = null; 239 240 var isTestDrive = (url.indexOf("prueba-de-conduccion") > -1); 241 var isGama = (url.indexOf("gama-mazda") > -1) || hasMaestro; 242 var isOfertaPersonalizada = (url.indexOf("solicita-una-oferta-personalizada") > -1); 243 var moduleId = $moduleRoot && $moduleRoot.length ? ($moduleRoot.attr('id') || '') : ''; 244 245 // Gama: usamos #id_modelo_maestro si existe. 246 if (hasMaestro || moduleId.indexOf('630') > -1 || isGama) { 247 var maestroTxt = jQuery("#id_modelo_maestro").text(); 248 var id_maestro_gama = (maestroTxt && maestroTxt.trim() !== "") ? ("{"+maestroTxt+"}") : "{}"; 249 label = 'conversion:RequestAQuote:' + id_maestro_gama; 250 } else if (moduleId.indexOf('631') > -1 || isTestDrive) { 251 label = 'conversion:TestDriveRequest:' + select_3; 252 } else { 253 // Oferta personalizada / inactividad comparten lógica: RequestAQuote. 254 if (moduleId.indexOf('578') > -1 || moduleId.indexOf('576') > -1 || isOfertaPersonalizada || foundSelect3 || hasSelect3Dom) { 255 label = 'conversion:RequestAQuote:' + select_3; 256 } else { 257 return; // No parece uno de los formularios que queremos medir. 258 } 259 } 260 261 if (label) { 262 envia_ga_event('conversion', 'cta', label, '-'); 263 try { 264 sessionStorage.setItem('mx_last_ga_cta_label', label); 265 } catch (e) {} 266 } 267 } catch (e) { 268 console.warn('GA cta (submit success) error:', e); 269 } 270 });
271 272 /** GA Event que detecta el error en la validación de formulario y envÃa el evento **/ 273 jQuery('.forminator-button-submit').on('click', function() { 274 setTimeout(function() { 275 if (jQuery('.forminator-error-message').size() > 0) { 276 envia_ga_event('conversion', 'formulario_KO', 'Validación de campos incorrecta', '-'); 277 } 278 }, 2000); 279 }); 280 281 /** GA Event cuando el usuario hace click en los CTAs de más información de la home **/ 282 jQuery('.home--ctas2--botonera .boton').on('click', function() { 283 envia_ga_event('interaccion', 'clic_mas_info', jQuery(this).attr('href'), '-'); 284 }); 285 286 /** GA Event cuando el usuario hace click el CTA solicita una oferta de la home **/ 287 jQuery('.solicitar_oferta_event').on('click', function() { 288 envia_ga_event('interaccion', 'clic_solicitar_oferta', document.location.href, '-'); 289 }); 290 291 /** GA Event cuando el usuario hace click en el botón pruébalo **/ 292 jQuery('.cta_test_drive').on('click', function() { 293 envia_ga_event('interaccion', 'clic_pruebalo', document.location.href, '-'); 294 }); 295 296 /** GA Event cuando el usuario hace click en el botón pedir cita **/ 297 jQuery('.cta_pedir_cita').on('click', function() { 298 envia_ga_event('interaccion', 'cita_previa', document.location.href, '-'); 299 }); 300 301 /** FIN EVENTOS GA **/ 302 303 /** Rellenar sessionStorage con el modelo si la página es de oferta DEV **/ 304 jQuery('.forminator-ui').on('submit', function() { 305 if (window.location.href.indexOf("gama-mazda") > -1) { 306 if (document.getElementsByTagName("h1") != null) { 307 sessionStorage.setItem('modelo_oferta', document.getElementsByTagName("h1")[0].innerHTML); 308 } 309 } else if (window.location.href.indexOf("solicita-una-oferta-personalizada") > -1) { 310 if (document.querySelector(".campo-productId1 .forminator-select--field") != null) { 311 sessionStorage.setItem('modelo_oferta', document.querySelector(".campo-productId1 .forminator-select--field").value); 312 } 313 } 314 if (sessionStorage.getItem('modelo_oferta') != null) { 315 console.log(sessionStorage.getItem('modelo_oferta')); 316 } 317 }); 318});
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.