How can I set a custom URL for Pageviews?

In some cases, e.g. due to values in the URL path that should not be tracked anywhere because they contain personal data, we need to set a custom URL when we track pageviews.
So we need to clean the URL before we send it to Piwik.
This is no problem with Adobe or Google Analytics. But in Piwik’s case, the only accepted parameter is “customPageTitle”, so I can customize the Page Title, but not the tracked URL:

This needs to be added to PiwikPRO.
Or am I missing something?

Hi @loldenburg ,

you can add _paq.push([“setCustomUrl”, “”]);
before calling trackPageView
As documented here:
API — Piwik PRO Analytics Suite 16.33 documentation

1 Like

Thanks! Maybe Piwik can add that hint to the trackPageview method in your documentation, I don’t think this is obvious. I spent half the day searching.

It is usually done by setting up the Virtual Pageview tracking tag in Tag Manager, where you can add the (custom) Page URL and Page Title.

But since you were pointing to the javascript tracking client API, I thought let’s guide you there.

Thanks for asking in the community, after all that’s what it is for.

1 Like

Thanks. I don’t use the Piwik Tag Manager, we have a lot of stuff in GTM already, and I want to hook onto the existing logic there. The Piwik GTM Tag Template does not seem to offer much besides basic pageview tracking and some auto-events, so we need to do it via the JS API. Correct me if that is wrong, I have only spent 3 days with the tool so far.

When you intend to use all features of Piwik PRO, Tag Manager, consent Manager and Analytics, I would definitively use the integration as it is written by the Install manually (Install a container (with a tracking code) | Piwik PRO help center) , because all modules know about each other (especially the consent manager and tag manager in case of GDPR and the like)

Tag Manager and Analytics work well together when using for instance custom dimensions.

Thx. I definitely don’t want a second Tag Manager on the same site.
And I want to limit Custom HTML in GTM as much as possible.
Consent Manager already exists on that site, so I only need Analytics.