Skip to main content
suned41710892
New Participant
Aug 27, 2019 12:16 PM UTC
Solved

Adding page name to script

Hi,

I am applying this script to all pages, and need to insert the current page url:

Is that possible, and if yes how?

Thanks in advance.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Alexis_Cazes_
Alexis_Cazes_Accepted solution
Level 10
Sep 5, 2019 8:14 AM UTC

Capture the URL in a variable and use it in your code using concatenation.

var url = document.location.href;

gtag('event', 'conversion',{

'allow_custom_scripts': true,

'u1': url,

'send_to':'something'

});

For the noscript tag it will not work as DTM require javascript to work so if there is noscript it means there is no javascript allowed so it will never run.

1 reply

Alexis_Cazes_
Alexis_Cazes_Accepted solution
Level 10
Sep 5, 2019 8:14 AM UTC

Capture the URL in a variable and use it in your code using concatenation.

var url = document.location.href;

gtag('event', 'conversion',{

'allow_custom_scripts': true,

'u1': url,

'send_to':'something'

});

For the noscript tag it will not work as DTM require javascript to work so if there is noscript it means there is no javascript allowed so it will never run.

Translate