my site uses a link rel="canonical" tag to support various crawlers/social share/etc. I do this with react-helmet.
calling analytics.page() on onRouteUpdated doesn't work in this case, because this fires before the react component that renders the meta tag is re-rendered.
so at the time when analytics.js tries to figure out what hte current page path is, it looks at the canonical tag and sees <link data-react-helmet="true" rel="canonical" href="https://todayilearned.io/">.
so page() path is set to /.


the fix could be to use the location.pathname passed to the onRouteUpdate hook, as it's the correct route at that point:

segment.js does allow passing in the path manually: https://segment.com/docs/sources/website/analytics.js/#default-properties
my site uses a
link rel="canonical"tag to support various crawlers/social share/etc. I do this withreact-helmet.calling
analytics.page()ononRouteUpdateddoesn't work in this case, because this fires before the react component that renders the meta tag is re-rendered.so at the time when analytics.js tries to figure out what hte current page path is, it looks at the
canonicaltag and sees<link data-react-helmet="true" rel="canonical" href="https://todayilearned.io/">.so
page()path is set to/.the fix could be to use the
location.pathnamepassed to theonRouteUpdatehook, as it's the correct route at that point:segment.js does allow passing in the path manually: https://segment.com/docs/sources/website/analytics.js/#default-properties