function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
pinnamanenipinnamaneni 

Calculate average time take for submission of an order in Lightning community

Hi Folks,

In Lightning community we have order creation  module, In this module after clicking on "Create New order" button user has to enter the details in 3 screens for submitting the order.
We have a requirement to calculate the average time taken for creation (time taken between clicking  "Create" button and "submit" button) of an order and show it in google Analytics.

Thanks
 
Ramesh DRamesh D
@pinnamaneni,
Give this a try call "Start" on "Create New Order" button and "end" on "Submit" button
start:function(component) {
      
       var startTime = new Date();
        component.set('v.starttime',startTime);
    },    
    end:function(component) {
        var startTime =component.get('v.starttime');
        var  endTime = new Date();
        var timeDiff = endTime - startTime; //in ms
        // strip the ms
        timeDiff /= 1000;
        
        // get seconds 
        var seconds = Math.round(timeDiff);
        alert(seconds);
        console.log(seconds + " seconds");
    }

 I hope you find the above solution helpful. If it does mark as best answer to help others too.
Thanks,
Ramesh D