Expand my Community achievements bar.

SOLVED

Page load time plugin not working

Avatar

Level 3

Hi Team, 

 

PLT plugin mentioned in the below link is not calling the getPageLoadTime() function. This plugin is not setting window._pltPreviousPage, window._pltLoadTime variables & s_plt variable too. 

https://experienceleague.adobe.com/docs/analytics/implementation/vars/plugins/getpageloadtime.html?l...

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello,

Based on the link you provided, I see that you are using the getPageLoadTime plugin in Adobe Analytics. This plugin is designed to capture the page load time for each of your site's pages.

The getPageLoadTime function needs to be called on each page load, and it uses the two variables you mentioned (window._pltPreviousPage, window._pltLoadTime) to calculate the load time.

If the function is not being called or the variables are not being set.

View solution in original post

6 Replies

Avatar

Correct answer by
Community Advisor

Hello,

Based on the link you provided, I see that you are using the getPageLoadTime plugin in Adobe Analytics. This plugin is designed to capture the page load time for each of your site's pages.

The getPageLoadTime function needs to be called on each page load, and it uses the two variables you mentioned (window._pltPreviousPage, window._pltLoadTime) to calculate the load time.

If the function is not being called or the variables are not being set.

Avatar

Level 3

https://experienceleague.adobe.com/docs/analytics/implementation/vars/plugins/getpageloadtime.html?l...

 

As mentioned in the above link, I am using the same to call the getPageLoadTime() method. 

 

if(s.pageName) getPageLoadTime();
if(window._pltPreviousPage)
{
  s.prop10 = window._pltLoadTime;
  s.eVar10 = window._pltPreviousPage
  s.events = "event100=" + window._pltLoadTime;
}

getPageLoadTime() - method is throwing error. I think there must be some other way to call the same. I tried s.getPageLoadTime() or this.getPageLoadTime() .. still error is throwing ..  Undefined is the error.

 

Avatar

Community Advisor

The error message "Undefined" usually means that the JavaScript interpreter is unable to locate the function or variable you're referring to, in this case getPageLoadTime(). In Adobe Analytics, getPageLoadTime() is not a built-in method but is instead a custom function defined by the user, typically within a custom JavaScript plugin.

Based on the context you've provided, it seems that you're referring to the getPageLoadTime() function as defined in the Adobe Experience League documentation here https://experienceleague.adobe.com/docs/analytics/implementation/vars/plugins/getpageloadtime.html?lang=en.

In this case, you need to ensure that you've defined this function somewhere in your Adobe Analytics JavaScript implementation before you attempt to call it. The function looks something like this:

 

function getPageLoadTime() {
    // This function calculates the page load time
    // and sets the relevant variables.
    //...
}

 

However, if you've already defined this function and are still seeing the "Undefined" error, it's possible that there's a scope issue. You may need to define the function in a scope that's accessible to the code where you're trying to call it.

Finally, you could also try console logging to check if your function is defined correctly:

console.log(getPageLoadTime);

If the function is defined properly, this should log the function definition to the console. If it logs "undefined", then the function hasn't been defined properly or is out of scope.

Avatar

Level 3

@Hemang35  

I am added the code like first plugin code followed by calling the getPageLoadTime() as per documentation. Now I am not getting the getPageLoadTime() undefined error. However,   window._pltPreviousPage is undefinedwindow._pltLoadTime is always set to one value ( not changing as we move different pages)

Avatar

Community Advisor

 

The code snippet you've used should, in theory, be working as expected. However, it seems like something is not properly set with window._pltPreviousPage and window._pltLoadTime variables.

Here are a few troubleshooting steps you can try:

  1. Check if the getPageLoadTime() method is called after the page fully loads. This is important because you want to make sure the page load time is measured after all the elements have fully loaded. You can do this by placing the method inside a window.onload function like this:
window.onload = function() { getPageLoadTime(); }