Closed chriswhong closed 4 years ago
@chriswhong this is an interesting observation. this could potentially be an issue. personally i haven't experienced this but i also have never used the delayLoad
. will ask around.
Are you doing anything custom with your routing or in your gatsby-browser.js?
I don't think so. Here's my site's source code if anyone wants to clone and try to reproduce. We ended up using gatsby-plugin-segment-analytics
I’ve seen the same issue on my site. Segment's debug tool always shows the previous page’s info when using onRouteUpdate
in gatsby-browser.js
to call window.analytics.page()
on pages visited after the initial page load.
The location
object available via onRouteUpdate
does have the correct page info, but there must be a race condition where Segment's tracking is handled before the page/DOM are actually updated. In my tests, delaying the analytics call by 1 second when the route updates works around the issue. I haven't seen a Gatsby API that would be a better fit than onRouteUpdate
.
Did you find a more reliable solution?
super excited to announce, this issue is fixed! hat tip to @TomPridham. solved via https://github.com/benjaminhoffman/gatsby-plugin-segment-js/pull/30
issue is now closed. please upgrade your version of this plugin to v3.3.0
and definitely let us know if you are still experiencing any issues!
cc @bwlng @chriswhong @Kilian
Thanks for a great plugin!
I got it working but noticed in my segment dashboard that the
title
property always reflects the previous page instead of the one being reported in the pageview.For example, navigating to
/contact
from/download
shows up as:I'm wondering if anyone has encountered this before or has an idea what could be going wrong.
I have
delayLoad
set to true anddelayLoadTime
set to1000