aboutisya
4/26/2016 - 5:39 PM

pathlogger.js

$(function() {
    var clickedClasses = [];
    $(document).on('click', function (event) {
        var t = event.target || event.srcElement;
        var c = t.className;
        clickedClasses[clickedClasses.length] = c;
    });
 
  window.onunload = function () {
        date = new Date();
        day = date.getDate();
        hours = date.getHours();
        minutes = date.getMinutes();
        pathLogger_cookie = !$.cookie('pathLogger_cookie') ? location.pathname:

            $.cookie('pathLogger_cookie') + '=>' + location.pathname + ' : ' + clickedClasses.join(' ,') + 
            '(' + day + ')' + '(' + hours + ':' + minutes + ')';

        $.cookie('pathLogger_cookie', pathLogger_cookie, { expires: 30 , path: '/' });

        ga('send', 'event', 'PathLogger', pathLogger_cookie, { 'dimension1': pathLogger_cookie});
   };
});