goatcounter icon indicating copy to clipboard operation
goatcounter copied to clipboard

How to track movement within a page

Open rouilj opened this issue 2 years ago • 1 comments

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?

rouilj avatar May 09 '22 02:05 rouilj

I'm interested in this as well. Being able to differentiate between page changes and SPA events is really nice.

jwendel avatar Jan 08 '23 17:01 jwendel