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 URL updates on a single page? #178

Closed
weavermedia opened this issue Nov 2, 2018 · 4 comments
Closed

Tracking URL updates on a single page? #178

weavermedia opened this issue Nov 2, 2018 · 4 comments

Comments

@weavermedia
Copy link

weavermedia commented Nov 2, 2018

My site runs on Carrd, a site builder and hosting platform. It emulates multiple page websites by hiding and showing sections on demand.

When a nav link is clicked, the required section shows and the URL is updated to, for example, /#contact. Somewhat different to a regular SPA because no remote data requests are made for new sections. All the section content is loaded at once and simply hidden/shown on demand.

I added fathom('trackPageview'); to each nav button to track views of each section but the URL hash fragments aren't being tracked.

How do I track with the hash fragment?

Example: https://meatbeats.com

@weavermedia weavermedia changed the title Tracking 'page views' on a single page? Tracking URL updates on a single page? Nov 2, 2018
@dannyvankooten
Copy link
Contributor

dannyvankooten commented Nov 2, 2018

Hey,

Is there a setting in Carrd that lets you update the actual URL of the page instead of using the hash fragments, so for example clicking the contact link would change the page URL to /contact (still without reloading) instead of /#contact?

That would allow Fathom to pick-up on the URL with success and pretty much all browsers nowadays support updating the URL on the fly like that (without having to use hash fragments). Fathom won't pick up on hash fragments right now because a lot of times, this is used for data that you don't want in your analytics tools.

Alternatively, I'm thinking of mimicking Google Analytics by allowing an additional variable to override the page URL in the call to fathom('trackPageview').

Example:

fathom('trackPageview', {
    path: '/path-of-page-you-want-to-increment-tracking-stats-for' 
})

Would the latter approach work for you (if the former isn't an option)?

@weavermedia
Copy link
Author

I'll check in with the Carrd dev about using non-hash URLs. There is an option for redirects. If a add a redirect like /contact=#contact I wonder if that would be picked up by Fathom? 🤔

Otherwise, yes the override method would work very well indeed. I actually tried fathom('trackPageview', '/contact'); in case there was some undocumented functionality but, alas, no. 😀

@weavermedia
Copy link
Author

@dannyvankooten Just saw the commit. Wow, that was fast! Will this be in the next release?

@dannyvankooten
Copy link
Contributor

Yes, definitely @weavermedia!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants