-
Notifications
You must be signed in to change notification settings - Fork 27
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
Usage in redirect routes #88
Comments
Hey! After that it should work like that: import { track } from "@vercel/analytics/server"
// pages/some-route.js
export async function getServerSideProps(ctx) {
if (await shouldRedirect()) {
await track("Redirecting", {
destination: "",
}, {
headers: ctx.req.headers
})
return {
destination: 'https://my.destination',
permanent: false
}
}
return {
props: {}
}
} Be sure to pass the headers to track, this will link the custom event to the pageviews from the users before. Let me know if that works! |
@tobiaslins Thanks for your reply! The track feature looks good, but let me be more clear about my question. I'm not trying to track a "Redirecting" event, but to track the visit to this "/some-route" path, so that it's counted in the Web Analytics visitors/pageviews chart. How am I supposed to do that? |
Oh sorry, I misunderstood this. The visit to the |
No, I'm not seeing it on the dashboard.
Let me make this clear...IIUC the tracking is done by using |
Sorry for not being clear. |
I placed |
Oh, so instead of await track("Redirecting", {
destination: "",
}, {
headers: ctx.req.headers
}) you would want to do something like We don't support this yet, but could also be added most probably! |
That's right. I want to track users' visits to this
Alright I'll keep an eye on this. |
Would also be interested in this functionality. Assume it's still not available? |
Hi, thanks for providing this convenient SDK and I enjoy using it in my Next.js projects. I'm just wondering how am I supposed to use it in routes that redirects (so that the
<Analytics />
component won't render)? FYI in my case I'm doing redirects ingetServerSideProps
, and I want to track visitors and views to this /some-route path.The text was updated successfully, but these errors were encountered: