Tracking SPA: skip redirects

In our company I’ve found at least two SPAs that use a sort of redirect when you open a page; they fire two History Change events after another.

For example, I click a link to a “news” page, the URL changes to “/news/” with a History Change, and immediately changes again to “/news/2023/” with another History Change. One of these SPAs doesn’t even change the URL the second time, just fires two History Change events.

I’ve tried using the “Fire delay” setting on the pageview tag, and that works in a way as the in-between page is not firing a pageview anymore. But now the final page fires TWO pageviews, including the delayed one from the in-between page, but both register a pageview for the final page. So now I’m counting all pageviews on the final page twice.

Is there a way to delay firing a pageview, and cancel it if another pageview happens before the delay expires? I would have expected that to be the default; it’s more logical to ignore a very short pageview than to register a pageview twice if it happens after a redirect.

To make it more precise: the first history change is a pushState() call, which is followed after ca 100 ms by a replaceState() call. Both of these trigger the History Change trigger in Matomo Tag Manager.

Hi @pbb72
I think using delay to bypass false behavior in JavaScript is never the best solution…
I suggest 2 different solutions…

  1. If the temporary “no-page” have specific url template, you can use the following configuration to not trigger in these cases:
  2. Couldn’ t you add, in your SPA, some datalayer variable. If you are in a “no-page” case, the datalayer variable would be set to false, and in other cases set to true. After, the same as solution 1: configure a trigger condition on this datalayer variable…