I have tried multiple different scripts ranging from simply "hello world" prints to more complex ones in GA4/GTM Custom Javascript Events.
I had a jscript developer look at it as is stumped so was wondering if theres any hints or tips or ideas?
Current example is to try and build a script that grabs the pageloadtime for example
function() {
if (window.performance && window.performance.getEntriesByType) {
var entries = window.performance.getEntriesByType("navigation");
if (entries.length > 0) {
var navTiming = entries[0];
var pageLoadTime = navTiming.loadEventEnd - navTiming.startTime;
return Math.round(((pageLoadTime / 1000) + Number.EPSILON) * 100) / 100;
}
}
}
however when I test in preview... the response is always the sane "undefined".
As the devs also stumped is there something in ga4 config or something in GA that perhaps I need to do?
ps... the tag is linked to the trigger and i've even opened up the trigger to fire on all pages all the time...no joy.
really appreciate any advice...
ps.. ive also used about 5 different scripts so i'm sure its not the script but something either blocked or not switched on but console works fine with "window.performance.timing.loadEventEnd - window.performance.timing.navigationStart"
multiple different scripts ranging from "hello world" prints to the pageload one included above...
Ive looked at console and tested (it works).....
looked at GTM preview ("undefined" response")....
Network collect looks fine....
no obvious 404 or failures in network console notices
no obvious blocking of jscript but it feels like this is the issue as no script works.