How can I override the default Page URL without causing duplicate pageviews in PP TM?

I’ll file a feature request for this as it would be best to include it directly in the tracking code. This is possible right now but you would have to ditch using the Piwik PRO tag template and use a custom HTML tag instead - not ideal for sure.

Can’t really comment about the overall safety as it would probably depend on the case. I have used this method of overwriting the default URL a couple of times and it worked fine. You are right that in some cases it could lead to race conditions as it’s indeed still asynchronous.

If you’d still want to use it, it would probably look something like this:

<script>
  var _paq = _paq || [];
  _paq.push(["setCustomUrl", {{ My custom URL}} ]);
</script>

The _paq command queue (var _paq = _paq || [];) is defined here because we are using it before the tracker is added to the website.

There’s actually a couple of ping types. The documentation you will probably find most useful would be:

The first one is about the event/request recognition pipeline and the second describes the whole HTTP tracking API request structure.

1 Like