Often when tracking pages in a mobile app or when a webpage URL contains arbitrary information, it becomes necessary to set the URL that Matomo tracks in order to ensure the reports generated are accurate and usable.

This can be done using the Matomo JavaScript tracking with the following code:

_paq.push(['setCustomUrl', 'https://yourdomain.com/your-new-page-url']);

As you can see from the example above, we need to specify the full URL of the page.
Simply setting the custom URL to something such as /your-new-page-url will not work.

Important note: The Custom URL must be set before a Pageview tracking request is sent using trackPageView