goatcounter
goatcounter copied to clipboard
How to track movement within a page
I have a number of pages with multiple sections and a table of contents. I would like to track how somebody moves through the page. Taking a page from SPA support, I am using:
window.addEventListener('hashchange', function(e) {
newURL = new URL(e.newURL)
window.goatcounter.count({ path: location.host +
location.pathname +
location.search +
location.hash,
referrer: e.oldURL,
title: document.title + " " +
newURL.hash })
})
this seems to work, but it deaggregates multiple hits on the page. Is there some way to view both the path somebody takes through a page and also view the aggregate for a given page?
Would treating the changes within a page as events (set event: true in the argument object) be a better way to store this data?
Any thoughts?
I'm interested in this as well. Being able to differentiate between page changes and SPA events is really nice.