ccc

Datalayer: tracking la web

En el index de la web:
(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 =
                    '//www.googletagmanager.com/gtm.js?id=' + i + dl;
                f.parentNode.insertBefore(j, f);
            })(window, document, 'script', 'dataLayer', 'GTM-XXXXXX');


Ejemplo 1:
dataLayer.push({
    'event': 'virtual-pageview',
    'ga_pagepath': '/contactar'
});


Ejemplo 2:
$(".loquesea").hover(function(e) {
        var el = $(this);
        if (!timeoutId) {
            timeoutId = window.setTimeout(function() {
                timeoutId = null;
dataLayer.push({
'event': 'gaEvent',
'gaEventCategory': 'aaaa',
'gaEventAction': 'bbbb',
'gaEventLabel': 'cccc',
'gaEventValue': 1,
'gaEventNonInt': 0
});
console.log("tracking comprobVisita");
            }, 750);
        }
    }, function() {
        if (timeoutId) {
            window.clearTimeout(timeoutId);
            timeoutId = null;
        }
    });

No hay comentarios:

Publicar un comentario