Reporting & Analytics

ilporyynanen
Member

Populating datalayer variables with page data

SOLVE

Hi everyone,

 

I am trying to populate datalayer variables in thank you page template with page data. I have already managed to do so with contact properties like this:

 

<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event' : 'formSubmissionSuccess',
'contactId' : {{contact.id}}
});
</script>

 

But I have not managed to include data from the page itself. I would wish it to be something like this:

<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event' : 'formSubmissionSuccess',
'pageTitle' : {{page title here}},

'pageUrl': {{page url here}}

});
</script>

Also any other page related data would be great.

 

Also I would be interested in passing data to the datalayer with the form values when a form has been submitted and assuing the next page would be thank you page where we could use and send data to various platforms.

 

Are there ready-made variables in Hubspot which I could use or does this require custom coding?

Thank you for your time,

Ilpo Ryynänen

0 Upvotes
1 Accepted solution
Kevin-C
Solution
Recognized Expert | Partner
Recognized Expert | Partner

Populating datalayer variables with page data

SOLVE

Thanks @sharonlicari 

 

Hey @ilporyynanen 

 

This documentation has the hubl variables for your all accessible current page data.

 

For page URL use "request.full_url" and for the title use "page_meta.html_title"

 

Hope this gets you moving

Kevin Cornett - Sr. Solutions Architect @ BridgeRev

View solution in original post

2 Replies 2
sharonlicari
Community Manager
Community Manager

Populating datalayer variables with page data

SOLVE

Hey @ilporyynanen 

 

Thank you for sharing this information. I'll tag a few experts that can share their experiences with you.

 

Hey @Kevin-C @Aakar @Joe-Kelp any tip or advice you can share with @ilporyynanen?

 

Thank you

Sharon


Join us on March 27th at 12 PM for the Digital Essentials Lab, an interactive session designed to redefine your digital strategy!
Engage with expert Jourdan Guyton to gain actionable insights, participate in live Q&A, and learn strategies to boost your business success.
Don't miss this opportunity to connect and grow—reserve your spot today!

0 Upvotes
Kevin-C
Solution
Recognized Expert | Partner
Recognized Expert | Partner

Populating datalayer variables with page data

SOLVE

Thanks @sharonlicari 

 

Hey @ilporyynanen 

 

This documentation has the hubl variables for your all accessible current page data.

 

For page URL use "request.full_url" and for the title use "page_meta.html_title"

 

Hope this gets you moving

Kevin Cornett - Sr. Solutions Architect @ BridgeRev