developer-documentation icon indicating copy to clipboard operation
developer-documentation copied to clipboard

Update the single-page-tracking tutorial

Open gka opened this issue 7 years ago • 2 comments

This page is talking about how to use Matomo in SPAs, but it's referring only to hashchange style navigation.

These days, SPAs are almost exclusively using pushState navigation, so it would make sense to update the documentation. The main points are:

  1. Whenever your app is calling pushState or replaceState, you might want to call the trackPageView method
  2. Then you probably want to listen to window.popstate events and send a trackPageView message as well

Most of the page can stay as it is, I would just replace the bits about hashchange with pushState.

gka avatar Oct 16 '18 20:10 gka

Thank you for the suggestion @gka

Maybe it even makes sense for the page to explain both methods (not sure?)

mattab avatar Nov 13 '18 04:11 mattab

I guess it's ok to keep an hashchange example as reference for older apps.

gka avatar Nov 22 '18 11:11 gka