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

Tracking page views in a Single Page App #83

Open
ninjaPixel opened this issue Jul 8, 2024 · 1 comment
Open

Tracking page views in a Single Page App #83

ninjaPixel opened this issue Jul 8, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ninjaPixel
Copy link
Contributor

ninjaPixel commented Jul 8, 2024

I'm using counterscale with Next.js and on page load it sends a trackPageview event to Cloudflare. However, on subsequent page views (where Next.js is effectively a SPA) nothing is sent to Cloudflare. I have tried:

  1. Calling window.counterscale("trackPageview") on navigation
  2. Setting the data-spa="auto" property on the counterscale script tag. (This property is available on the Fathom script so I thought I'd give it a go here!)

How can I make sure that my SPA page views are tracked? Thanks!

@benvinegar
Copy link
Owner

@ninjaPixel First, thanks for submitting this. 🙏

How can I make sure that my SPA page views are tracked?

I think we need to augment tracker.js to be aware of (and track) navigation changes using PopStateEvent (mdn).

But before that, we need to add tests to the tracker using Playwright or something similar. I've been reticent to add functionality to the tracker because it's not covered at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants