Expand my Community achievements bar.

SOLVED

What is a simple way to track Page Load Time with Launch?

Avatar

Level 1

Hi everyone,

I have worked with many tag management systems but I am new to Launch.

I am trying to capture the best approximation to page load time into an eVar and a numeric event. I have tried some traditional ways of solving it that have worked in other environments. However I am having a hard time to get it to work in Launch.

For example:

a) I am trying to capture a timestamp on "Library Loaded (Page Top)". I am using a Custom Code action step on the same rule that sends the page view beacon:

launchDataLayer.pageLoadStart = Date.now();

b) Then I am capturing another time stamp on "Window Loaded". Once again I am using a custom code on a separate rule firing on Window Loaded.

I am also storing the calculated value in the dataLayer objcet

launchDataLayer.pageLoadEnd = Date.now();

launchDataLayer.pageLoadTime = launchDataLayer.pageLoadEnd - launchDataLayer.pageLoadStart;

c) However when I try to read this value when setting the variables before sending the beacon, it doesn't have any value.

I am pretty sure I am missing something. What am I doing wrong? Is there a better and simple what to accomplish this with Launch?

Thank you in advance for your help!

Jose

1 Accepted Solution

Avatar

Correct answer by
Level 4

You may not be getting any data collected to your variables because of the timing that data elements are evaluated for SetVars.

Based on what you said here:

Adobe launch handles Data Elements in a very specific manner when they are referenced in the GUI (like a setVars action block or within the analytics extension 'Global Varables' section).  So let's imagine the following scenario:

MyPage Rule
- Trigger: PageTop

- Actions:
- - Custom Code Action Block (gets a timestamp value and puts it in the dataLayer)

- - Analytics SetVars Action Block (sets eVar1 = %DataElementGetTimeFromDataLayer%)

- - Analytics Send Beacon Action Block

Actual Execution Order:

  1. The trigger occurs (PageTop)
  2. MyPageRule evaluates conditions to determine if it should run
  3. Launch then evaluates all Data Elements that it knows about for 'MyPageRule' to ensure that the "MyPageRule" Rule will run properly (which means it evaluates %DataElementGetTimeFromDataLayer% before you wanted it to)
  4. Now Launch can tell you that "MyPageRule fired." and can start the actions...
  5. Custom Code Action Block now runs! (gets a timestamp value and puts it in the dataLayer)
  6. Analytics SetVars Action Block now runs, but the data elements have already been evaluated!  So it's just using those known values (remember: calculated prior to the value being put in the dataLayer)
  7. Analytics Send Beacon Action Block happens

If you want the data element to be evaluated after that action block, you may want to use the setVars custom code area to set this variable, which gets run at the timing you were expecting.

Or, alternatively, you could move your "Custom Code that gets the timestamp" up into the 'Conditions' area, which means it will be fully executed before those data elements are runnning. (just remember to end your condition with a return true;)

View solution in original post

3 Replies

Avatar

Level 9

Are you using a ContextHub Data Element to read out this property? AFAIK these only get initialized when the script loads.

When and how are you sending the beacon? One option would be to use a direct call rule and provide the values as a payload:
_satellite.track('load-time', {loadStart: launchDataLayer.pageLoadStart, loadEnd: launchDataLayer.pageLoadEnd, loadTime: launchDataLayer.pageLoadTime})
and then in the custom code Set Variables action of your rule you have this object available as event.detail

Avatar

Level 2

We use user-centric performance metrics, you can read here User-centric Performance Metrics  |  Web Fundamentals  |  Google Developers

This example code is for GA, it can be adapted to Adobe pretty easily.

Avatar

Correct answer by
Level 4

You may not be getting any data collected to your variables because of the timing that data elements are evaluated for SetVars.

Based on what you said here:

Adobe launch handles Data Elements in a very specific manner when they are referenced in the GUI (like a setVars action block or within the analytics extension 'Global Varables' section).  So let's imagine the following scenario:

MyPage Rule
- Trigger: PageTop

- Actions:
- - Custom Code Action Block (gets a timestamp value and puts it in the dataLayer)

- - Analytics SetVars Action Block (sets eVar1 = %DataElementGetTimeFromDataLayer%)

- - Analytics Send Beacon Action Block

Actual Execution Order:

  1. The trigger occurs (PageTop)
  2. MyPageRule evaluates conditions to determine if it should run
  3. Launch then evaluates all Data Elements that it knows about for 'MyPageRule' to ensure that the "MyPageRule" Rule will run properly (which means it evaluates %DataElementGetTimeFromDataLayer% before you wanted it to)
  4. Now Launch can tell you that "MyPageRule fired." and can start the actions...
  5. Custom Code Action Block now runs! (gets a timestamp value and puts it in the dataLayer)
  6. Analytics SetVars Action Block now runs, but the data elements have already been evaluated!  So it's just using those known values (remember: calculated prior to the value being put in the dataLayer)
  7. Analytics Send Beacon Action Block happens

If you want the data element to be evaluated after that action block, you may want to use the setVars custom code area to set this variable, which gets run at the timing you were expecting.

Or, alternatively, you could move your "Custom Code that gets the timestamp" up into the 'Conditions' area, which means it will be fully executed before those data elements are runnning. (just remember to end your condition with a return true;)