Updating page url in datalayer


is there any way while pushing dataLayer i can enter the page url as well for page view event like below.

‘url’: /my/custom/url,
‘event’: ‘stg.pageView’
i want to change page URL to custom, so that while watching goal user flow i can have flow according to URL i am sending


I guess you need just a virtual page view tag :slight_smile:

In this tag, you will be able to use variable from the dataLayer.

Just make sure that:

  • the new variable is actually pushed
  • you have variable created in the Tag Manager ui that will simply read that value
  • I’d also consider using dedicated event name to not change the default behaviour of stg.pageView event.

Yes but i want to have this url thing with default page view, i want it to consider it as a page view for virtual URL., Thanks i will try and update if it works

Hi @kuba ,

What will be the value i should used for below

What will be the value of virtual page and Document title.


OK, so maybe one step back. How are you building the URL? Maybe it’ll be simply enough to override the URL before each page view using this method:

_paq.push(["setCustomUrl", "https://example.com/virtual-page"]);

You just add a new custom html tag on each page view and it should affect all the tracked URLs.

Hi ,
in google analytics i am using it like below

‘page’: /my/custom/url ,
‘event’: ‘gaPageView’

in Piwik you are suggesting like below ?

‘setCustomUrl’: /my/custom/url ,
‘event’: ‘stg.pageView’

Let me brief you with the scenario i am working on, we have registration form popup which has like 12 fields , so for each field i am triggering a pageview event and i want to send custom url as well like for firstname it should be /registeration/desktop/firstname and so on for all other fields after successful completion of for i will send url as /registeration/desktop/success and this same url i will use inside Goals when i will create goal i will add page url contains /registeration/desktop/success this way i will have user flow for all fields and i can find out how much numbers are getting drooped from which fields .

I hope i explained it well.


Let’s try so then:

‘Page Url’: `/my/custom/url` ,
‘event’: ‘stg.pageView’

Hi @kuba ,

Tried this one but no luck. it still picks browser URL


Ok, so let’s go with a nice and clean example.

‘CustomUrl’: `/my/custom/url` ,
‘event’: ‘customPageView’

After sending this event, make sure that you intercept it correctly in the tag manager by:

  • adding a variable that will read the CustomUrl
  • adding a new virtual page view tag with trigger set to the data layer event called customPageView

Of course, please make sure you use the newly created variable as the page url for your new virtual page view :slight_smile: For the title of the page, you can use another JavaScript variable that will be set to document.title.

1 Like

This how it looks now

I guess for the document.title you have to create a new Document variable because otherwise it will simply display it as text.

Does it work? You can always check it using the Tag Manager debugger and the Tracker debugger functionalities.

Not sure if everything ok, as now nothing getting tracked

Please have a look on screenshot i shared


In the trigger, the event name constraint should be set to CustomPageView. I noticed that the consent type is set to Analytics. Are you using the consent manager? Does the tag fire in the debug mode?

Thanks it worked now :slight_smile:

I’m trying to set a custom URL through a custom code tag that loads before the Piwik Pro basic tracking code.

  _paq.push(['setCustomUrl', {{ PageURL clean }}]);

But I get this error in my console:

Uncaught ReferenceError: _paq is not defined

I don’t understand why. Isn’t _paq initialised when the tag manager loads? Or is the initialisation only done when the main Piwik Pro basic tracking code is fired? And if this is the case, how can I override the page URL using the command queue?

Hi @rmeekers
All of our tags in Piwik PRO Tag Manager start with the following part:

var _paq = _paq || [];

This way you know for sure the array (or queue) is available to have commends like yours pushed through.

By default this is created when setting up the actual tracker.


1 Like

Wonderful. I didn’t know that it could work like this.

The thing is that all the code is used asynchronously, once the ppms.js library is loaded. So, you can even configure parts of the Analytics tracking code before loading the Piwik PRO tag. :slight_smile:

1 Like