Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Single page app - form each field time spent

m_1985
Level 4
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
ParitMittal
Correct answer by
Level 10
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
ParitMittal
Correct answer by
Level 10
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