chrisblakley / Nebula

Nebula is a WordPress theme framework that focuses on enhancing development. The core features of Nebula make it a powerful tool for designing, developing, and analyzing WordPress websites consistently, yet its deliberately uncomplicated code syntax also serves as a learning resource for programmers themselves.
https://nebula.gearside.com
GNU General Public License v3.0
144 stars 36 forks source link

Sometimes initial load is missing GA4 pageview properties...? #2277

Closed chrisblakley closed 8 months ago

chrisblakley commented 8 months ago

I noticed that a website sends the GA4 page_view on initial load, but didn't have any of the page view properties that Nebula usually sets... Then on reload, they were all there.

Initial Load: Screen Shot 2024-03-06 at 8 28 14 AM

Subsequent Load (simply refreshing the same page a moment later): Screen Shot 2024-03-06 at 8 28 59 AM

chrisblakley commented 8 months ago

For this issue it was that a second GA tag was added by a third-party to GTM which conflicted with the Nebula GA4 tag. This appears to be a non-Nebula issue, but I want to review this to see if we can detect/avoid these kinds of conflicts in the future.

Not sure if this console error is related: Screen Shot 2024-03-06 at 10 08 13 AM

I don't think it is because the error is present in both the initial page load and subsequent page load, but still worth looking into.

chrisblakley commented 8 months ago

The current solution is if both GA4 and GTM Nebula Options exist, then we'll delay loading GTM by 1 second.

chrisblakley commented 8 months ago

Confirming this works given the situation on this website. Could dial in the setTimeout to lower it from 1 second eventually.