Lead Capture Tools

FadyAzmy
Participant

Passing UTM parameters to a visitor's cookie and writing them to hidden form fields

SOLVE

Hello everyone,

 

I'm trying to make our UTM values persist across multiple pages up until the point of conversion on a form, etc. As you know without persistent UTMs, we lose them if they don't convert on the first page they are directed to from tagged UTM URL.

 

I've come across some community articles, but find them a bit over my head. We use HubSpot CMS for our website and we don't use GTM. Maybe worth noting that we'd like to have tge UTM cookies valid for up to 90 days without overwriting the current UTM values stored in the UTM cookie.

 

Any pointers to useful sources on the most efficient way to develop the JS and how to apply the JS to all website forms (120+ forms). It'd be cool if we could update all existing forms with hidden UTM fields to avoid throwing any errors when the code is deployed. Any idea on how to achieve that via Forms API or else?

 

Has anyone deployed this globally through their CMS and could share their knowledge? Is it as a simple as adding a JS file under the website's theme? any gotchas to watch out for?

 

Thanks so much for the help in advance 🙂

1 Accepted solution
josh_todd
Solution
Contributor

Passing UTM parameters to a visitor's cookie and writing them to hidden form fields

SOLVE

You could pass the query string from the URL into a local cookie on the users browser (assuming they have cookies enabled) then detect when the form is on the page and push the local cookie into the hidden form field. That way no matter how many pages they go to you can still attribute that query string to their contact record when they fill out the form.

 

 

hubspot-community-signature.png
Joshua Todd |  CEO of Pixl Labs
www.pixllabs.io

View solution in original post

4 Replies 4
josh_todd
Solution
Contributor

Passing UTM parameters to a visitor's cookie and writing them to hidden form fields

SOLVE

You could pass the query string from the URL into a local cookie on the users browser (assuming they have cookies enabled) then detect when the form is on the page and push the local cookie into the hidden form field. That way no matter how many pages they go to you can still attribute that query string to their contact record when they fill out the form.

 

 

hubspot-community-signature.png
Joshua Todd |  CEO of Pixl Labs
www.pixllabs.io

FadyAzmy
Participant

Passing UTM parameters to a visitor's cookie and writing them to hidden form fields

SOLVE

Thanks so much Josh! do you have any helpful links that could tackle how to achieve this in HubSpot via Form APIs? Also, any idea how to push this on all existing forms rather than updating every single form manually with hidden fields? We're using HubSpot CMS for our website btw, could it be achieved by adding a JS file to the HubSpot theme in use for example? Any other gotchas to look for?

 

Thanks!

0 Upvotes
josh_todd
Contributor

Passing UTM parameters to a visitor's cookie and writing them to hidden form fields

SOLVE

I would check out how to push the data after a form is submitted. HubSpot has documentation on how to go about this via their API. You will have more control if you embed the forms rather than use their form module but if you don't want to re-add all the forms you can use JS to detect the forms and submit the data.

 

Embedding forms - https://legacydocs.hubspot.com/docs/methods/forms/advanced_form_options
Detecting hs forms and using global events - https://legacydocs.hubspot.com/global-form-events 
Submitting via form - https://legacydocs.hubspot.com/docs/methods/forms/submit_form

Hopefully this helps!

 

hubspot-community-signature.png
Joshua Todd |  CEO of Pixl Labs
www.pixllabs.io

PamCotton
Community Manager
Community Manager

Passing UTM parameters to a visitor's cookie and writing them to hidden form fields

SOLVE

Hello, @FadyAzmy I will add some top experts so they can share their thoughts, @josh_todd @DanielSanchez any recommendations about @FadyAzmy matter?

 

Thank you, Pam

Você sabia que a Comunidade está disponível em outros idiomas?
Participe de conversas regionais, alterando suas configurações de idioma !


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !