In a site I manage, there is a privacy banner displayed for each new visitor. The choice made by the visitor (accept/decline) causes a page refresh, because I need to update the Content-Security-Policy meta tag and I can’t do it via Javascript.
The trouble is: such page refresh causes an extra page view and also affects the bounce rate.
I need to update it because of some youtube videos in the site. Depending on the user choice, the “frame-src” part of the CSP (that always contains www.youtube-nocookie.com) may contain also www.youyube.com and youtu.be.
Anyway, as I can’t make decisions on this part, the CSP update must be considered mandatory for me.
The current flow is:
the (new) user loads the page [–> one page view in matomo].
the user select accept/decline
the JS code updates a cookie (but can’t update the CSP; I’ve already tried that) and forces a page refresh
the new page contains the right CSP [but matomo changes the page view count and the bounce rate]
Then you can, for the new page, load all Matomo but not hit the PageView…
Do you track by MTM? just JavaScript (via _paq variable)? or by another manner?
Yes just ignore the _paq.push(['trackPageView']);, be sure the document title and page URL haven’t changed (except for parameters that are ignored by Matomo in Administration > Measurables > Manage > {Your site} > Excluded Parameters), and this should work well!
Then this should work, but I think that just putting some parameter in the URL or manage the writting of _paq.push(['trackPageView']); server-side would be a little bit easier…