Updating page url in datalayer

Hi,

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

window.dataLayer.push({
‘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

Thanks

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.

Thanks

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

window.dataLayer.push({
‘page’: /my/custom/url ,
‘event’: ‘gaPageView’
})

in Piwik you are suggesting like below ?

window.dataLayer.push({
‘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.

Thanks

Let’s try so then:

window.dataLayer.push({
‘Page Url’: `/my/custom/url` ,
‘event’: ‘stg.pageView’
})

Hi @kuba ,

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

Thanks

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

window.dataLayer.push({
‘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

Thanks

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: