Hello,
We are using a custom JavaScript inside AEM DTM to track the timings of the page loads.
The custom script uses the performance.timing
objects and looks like this:
return performance.timing.loadEventEnd - performance.timing.navigationStart;
The value is stored in a evar and prop (we tried both).
This works fine when we test it in the console (satellite debug enabled), but when we inspect the value delivered by the DTM custom script, we end up we a negative number, because the loadEventEnd is 0.
We tried different approaches with onLoad
, domReady
, ... page rules
, all with the same result.
Any help is much appreciated!
Thanks.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Jor,
Instead of using performance.timing.loadEventEnd, you will have to calculate the timing at when you invoke your function.
If you are calculating from performance.timing.navigationStart, you can use performance.now() to return the page load time at the point you invoke your function.
Note, in s_getLoadTime plugin, the start time is performance.timing.requestStart. If you decide to use this as your start time instead, you will have to calculate in this manner:
performance.timing.navigationStart + performance.now() - performance.timing.requestStart
Note: going through the following chart will aid in understanding when the respective performanceTiming markers are set with their respective values. The chart can be found in the W3C Navigation Timing recommendation document:
Views
Replies
Total Likes
Hi jor,
I have check this for you and here is the result.
1. When testing it in the Console (I assume you did not put in a Breakpoint to test it) the loadEventEnd Value is already set. Because everything has finished loading.
2. When using any other approach within DTM than 'onLoad' the loadEvent has not been triggered yet and that´s why the value is 0.
The problem with onLoad is the moment onLoad is being triggered the loadEventEnd does not contain the value yet.
I have tested this in Google Chrome by adding an evenListener to the Window Object:
window.onload = function(){
console.log(JSON.stringify(performance.timing)); <- This way you get the actual object and not the Object pointed towards. check ths value for loadEventEnd, for me it always has been 0.
console.log(performance.timing.loadEventEnd); <- This value is 0
setTimeout(function(){
console.log(performance.timing.loadEventEnd); <- This value is set
}, 0);
}
Long story short with the default functionality of DTM you will not be able to capture performance.timing.loadEventEnd.
If you really need to have those values been properly tracked you can send a second call to Adobe using a EventBasedRule but this way you destroy your default Bounce Rate and double your Server Call costs to Adobe (at least for Page Views).
Views
Replies
Total Likes
Hi Jor,
Broadly speaking, the approach to this is to store the calculated value and pick it up on the next page load; the value is then analysed against "Previous Page Name" (or a dedicated "Performance Timing Page Name" variable).
That's the approach taken in Adobe's performanceTiming plugin with an additional bit of functionality that picks up the measurements on Exit Link-tracking calls as well.
Views
Replies
Total Likes
Hi Jor,
Instead of using performance.timing.loadEventEnd, you will have to calculate the timing at when you invoke your function.
If you are calculating from performance.timing.navigationStart, you can use performance.now() to return the page load time at the point you invoke your function.
Note, in s_getLoadTime plugin, the start time is performance.timing.requestStart. If you decide to use this as your start time instead, you will have to calculate in this manner:
performance.timing.navigationStart + performance.now() - performance.timing.requestStart
Note: going through the following chart will aid in understanding when the respective performanceTiming markers are set with their respective values. The chart can be found in the W3C Navigation Timing recommendation document:
Views
Replies
Total Likes
Hi Barry,
How can performanceTiming be used with Adobe Launch? Would you be able to provide the steps for this.
Thanks.
Views
Replies
Total Likes
Hi adilk,
I wouldn't recommend any longer the use of Adobe's performanceTiming plugin: in my view, the "lost" measurements (you will miss almost every single "exit page", i.e. the last page of the visit) are too important to ignore.
A better approach, in my opinion, is to write your own Data Element that calculates the measurements you want from the performanceTiming object (with reference to "navigationStart") and assigns these values to Events. This sounds more complicated that using the provided plug-in; however, I think that including an Adobe plug-in in Launch is not that easy.
The primary benefits:
The downsides:
Views
Replies
Total Likes
Hi Barry,
The website I'm looking at has been built in Angular and so, the first page load has the correct performance metrics in performance.timing variables. On second page load onward, loadEnd event timestamps stay the same as page 1 as the browser does not make a full round trip to load the content of the second page.
Views
Replies
Total Likes
In that case, @adlik, I think there are two parts to what you could consider doing:
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies