Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve with-segment-analytics for client rendered paths #4587

Closed
dsbrianwebster opened this issue Jun 11, 2018 · 1 comment
Closed

Improve with-segment-analytics for client rendered paths #4587

dsbrianwebster opened this issue Jun 11, 2018 · 1 comment

Comments

@dsbrianwebster
Copy link

dsbrianwebster commented Jun 11, 2018

It be great to flesh out this example so analytics.page() will capture ALL page views -- client and SSR rendered. Not sure if that means moving some of the code from _document.js (which is only rendered on the server) to the new (Next6) _app.js file.

Or, instead, is a matter having to manually call analytics.page inside of onRouteChangeComplete or possibly in the lifecycle hooks of page components and leaving the setup code where is. Thoughts?

@timneutkens
Copy link
Member

I assume someone created a PR for this, if not feel free to create a PR, you'll want to add the tracking to _app.js with a typeof window !== 'undefined' otherwise it'll track server side + client side leading to skewed results.

@mulholo mulholo mentioned this issue Jan 15, 2019
timneutkens pushed a commit that referenced this issue Jan 18, 2019
RE: #4587, this pull request improves the with-segment example.

Previously, only SSR page loads were tracked. This pull request adds manual page view logging via `Router.events.on('routeChangeComplete')` in `Page.js`.

There is also a minor bug fix on the textarea to remove a console error.
@lock lock bot locked as resolved and limited conversation to collaborators Jan 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants