gatsby-plugin-segment-js
gatsby-plugin-segment-js copied to clipboard
delayLoad and delayLoadTime did not work
Hi! At version 4.0.3, the delay load didn't work.
delayLoad: true,
delayLoadTime: 1000
Segment load without page scroll event or Link click.
I'll have a look. I guess nobody really has been using that or watching closely?
Are you a new user of this library, or that option? Wondering how long it's been broken.
Hi @eDubrovsky I think you just need to set the trackPage: true
option...the delayLoad
functionality is working for me.
@newhouse Hi!
I have used this plugin for about 10 months, and version 3.7.1 works perfectly. :)
I found the problem scenario. My current setting:
trackPage: true,
trackPageDelay: 50,
delayLoad: true,
delayLoadTime: 1000
In this case, the delay time = trackPageDelay = 50. And script loaded without a page scroll event. But delayLoadTime and loading script by scroll event no applied in this case.
If I set delayLoad to false, the script loading without delay and works correctly.
Hi @eDubrovsky maybe I'm misunderstanding. Are you saying that:
- With the settings listed above
- you expected the
pageview
to not occur until the User scrolls?
I think perhaps:
- what I'm seeing happen is what I am expecting
- you are seeing the same thing that I am seeing, but it is NOT what you are expecting.
Can you try to clarify a bit for me - I think I'm not following. Thank you!
I am trying to improve my website's TTI for PageSpeed Insights by Google.
When I set delayLoad: true
I am expecting this scenario:
- User opens my site, and Segment is NOT loading (it helps with a better result in PageSpeed Insights)
- After the user scrolls the page, the Segment loading with
delayLoadTime: 1000
- After that
analytics.page()
trigger withtrackPageDelay: 50
OK, I think I understand.
You expect to not see the loading occur until either (a) the user scrolls or (b) a page routing change.
I think what I've done in 4.x is more like breaking-change and expected behavior from this issue: https://github.com/benjaminhoffman/gatsby-plugin-segment-js/issues/37
At this point, what I think I should do is leave things how they are with the options you've chosen, but add an additional option like delayLoadUntilScrollOrRouteChange
that if true
will do what you're expecting....which was the old actual behavior but not the new current behavior.
How does that sound?
Code back at 3.7.1:
https://github.com/benjaminhoffman/gatsby-plugin-segment-js/tree/897db9ba7f2b0bab91aab3c87bac1682fcf36396 https://github.com/benjaminhoffman/gatsby-plugin-segment-js/blob/897db9ba7f2b0bab91aab3c87bac1682fcf36396/src/gatsby-browser.js https://github.com/benjaminhoffman/gatsby-plugin-segment-js/blob/897db9ba7f2b0bab91aab3c87bac1682fcf36396/src/gatsby-ssr.js
@newhouse delayLoadUntilScrollOrRouteChange
option sounds cool, yep! 🤟
@eDubrovsky can you please install 5.0.0-beta.0
and play around with it a bit to see if it's working correctly?
You can see the new options here: https://github.com/benjaminhoffman/gatsby-plugin-segment-js/pull/59/files
Actually 5.0.0-beta.1
, please.
Yes, it works! Like it! 🤟
p.s.: how can I turn off plugin console.logs?
