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

Previous FAQ: How do I setup Matomo to track multiple websites without revealing the Matomo server URL footprint which appears in the Javascript code in all websites?