Following this advice I added if (!window.location.pathname.match(/(\/modal)/))to the manual tracking code to exclude all pages with url ‘/modal’. I got a console error, ‘Uncaught SyntaxError: invalid regular expression flag o’. Checking, I see that when I save the manual tracking code, the backslash is stripped out, leaving if (!window.location.pathname.match(/(/modal)/)). How do I ensure the tracking code is saved with the backslash? Thanks
The answer seems to be that this regex gets ‘sanitised’ when adding it in the matomo wp plugin. The solution is to disable the tracking code in the plugin. Instead add the tracking code with regex directly to the page.
Hello @workel. Glad to hear that you’re able to find solution to the problem. This will be a great help to Matomo community.
I’m glad and it’s nice to get a thank you. One comment - the drawback is having to add the tracking code manually to all pages and not just once through the plugin. It should be possible to use a recognised regex in the plugin without it conflicting with the sanitise routine. If that’s not possible, at least make this clear in the advice page.