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?
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.
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.
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?
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.