Expand my Community achievements bar.

SOLVED

Single page app - form each field time spent

Avatar

Level 4

Hi,

Is there a way to get amount of time spent on form each fields.?  any recommendations. 

update: the below code seems to be working by getting the name of the field and field timing on the browser console. But, it doesnt seem to be working when i include this code in DTM. I could understand sine the page is not reloading and that's the reason it is not working. Any help would be greatly appreciated

$(document).ready(function() {         
     var d=0;
     var t=0;
     $(':input').focus(function () {
     d=new Date();
     t =d.getTime();
                });
    $(':input').blur(function() {
    var e=new Date();
    var x = e.getTime();
    var exit = Math.round((x - t)/1000);
        var formPage = document.title;
                if($(this).val().length > 0){ 
                console.log($(this).attr('name'));
                console.log(exit);
    } 
        
    });
});

Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi ,

We tried a similar thing at our end and included the time on field code which you provided in a  "Global Page Load Rule "  as a "Sequential Javascript" under  tab " Javascript / Third Party tag " and it was working and the time spent on a field was getting printed on the console.

Please find attached  snapshots for your reference and we would recommend to try out the same thing at your end and le tus know whether the same thing works for you or not

Thanks & Regards

Parit Mittal

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Hi ,

We tried a similar thing at our end and included the time on field code which you provided in a  "Global Page Load Rule "  as a "Sequential Javascript" under  tab " Javascript / Third Party tag " and it was working and the time spent on a field was getting printed on the console.

Please find attached  snapshots for your reference and we would recommend to try out the same thing at your end and le tus know whether the same thing works for you or not

Thanks & Regards

Parit Mittal