Closed slidenerd closed 5 years ago
UPDATE I tried something but this has a drawback
TimeMe.initialize({
currentPageName: "my-home-page", // current page
// idleTimeoutInSeconds: 5, // stop recording time due to inactivity
websocketOptions: { // optional
websocketHost: "ws://your_host:your_port",
appId: "insert-your-made-up-app-id"
}
});
I commented out idleTimeoutInSeconds but this has a drawback If I try to type something on the address bar, the timer stops running but unless I click on the page again it does not start running
Sorry my bad, modified your code slightly and does the trick
var start = Date.now();
window.onload = function () {
TimeMe.trackTimeOnElement('area-of-interest-1');
TimeMe.trackTimeOnElement('area-of-interest-2');
setInterval(function () {
var timeSpentOnPage = TimeMe.getTimeOnCurrentPageInSeconds();
document.getElementById('timeInSeconds').textContent = timeSpentOnPage.toFixed(2);
var timeSpentOnElement = TimeMe.getTimeOnElementInSeconds('area-of-interest-1');
document.getElementById('area-of-interest-time-1').textContent = timeSpentOnElement.toFixed(2);
var timeSpentOnElement = TimeMe.getTimeOnElementInSeconds('area-of-interest-2');
document.getElementById('area-of-interest-time-2').textContent = timeSpentOnElement.toFixed(2);
var totalTime = (Date.now() - start) / 1000;
document.getElementById("totalTime").textContent = totalTime.toFixed(2)
}, 25);
First of all, fantastic work on the library. I am looking to measure 2 things
Suggestions are super appreciated