I have a question that maybe you all can help with.
I have a hidden field on my form to capture UTM paramters. I typically do this through the creation of a Cookie on my website to capture and store the data - and then input it into the hidden form fields using the input id.
However, HubSpot doesn't seem to have an input id on hidden form fields - meaning that the Cookie I've created can't put the information into the hidden field - as you can see below.
I've done this same setup for lots of forms, and HubSpot is the first one I've run into that doesn't have an input id for the hidden form fields.
How can I capture the data in the hidden field without an input id?
The name property of each input on a HubSpot form is the same as the internal name of the corresponding HubSpot property. Updating the value using jQuery is pretty straightforward:
Thanks for the response. I tried adding that code to Google Tag Manager, but it still didn't pull in the cookie value (I adjusted the names - but nothing happened.)
I'm not super familiar with the ins-and-outs of Google Tag Manager, but a common issue here is form-related code executing before the HubSpot form has been fully loaded on the page.
To rectify this, you can either customize the form embed code, or listen for a global form event. Check out the docs linked here:
I've used this code on multiple websites and it works to capture the UTM parameters.
I then typically use this code to add the cookie value to the hidden fields on my form:
<script>
(function () {
var selector = "#input_1_14"; //Enter your CSS Selector for the hidden field here
if(document.querySelector(selector)){
document.querySelector(selector).value = {{cookie - fbclid}};
};
var selector = "#hs-messages-hide-welcome-message"; //Enter your CSS Selector for the hidden field here
if(document.querySelector(selector)){
document.querySelector(selector).value = {{cookie - gacid}};
};
var selector = "#lastname-655a4135-b40e-4492-ac12-1d3d0d4d1f52_5785"; //Enter your CSS Selector for the hidden field here
if(document.querySelector(selector)){
document.querySelector(selector).value = {{cookie - gclid}};
};
var selector = "#input_1_8"; //Enter your CSS Selector for the hidden field here
if(document.querySelector(selector)){
document.querySelector(selector).value = {{cookie - msclkid}};
};
var selector = "#input_1_8"; //Enter your CSS Selector for the hidden field here
if(document.querySelector(selector)){
document.querySelector(selector).value = {{cookie - utm_campaign}};
};
var selector = "#hs-input"; //Enter your CSS Selector for the hidden field here
if(document.querySelector(selector)){
document.querySelector(selector).value = {{cookie - utm_content}};
};
var selector = "#input_1_8"; //Enter your CSS Selector for the hidden field here
if(document.querySelector(selector)){
document.querySelector(selector).value = {{cookie - utm_device}};
};
var selector = "#input_1_12"; //Enter your CSS Selector for the hidden field here
if(document.querySelector(selector)){
document.querySelector(selector).value = {{cookie - utm_program}};
};
var selector = "#utm_source-655a4135-b40e-4492-ac12-1d3d0d4d1f52_1235"; //Enter your CSS Selector for the hidden field here
if(document.querySelector(selector)){
document.querySelector(selector).value = {{cookie - utm_source}};
};
var selector = "#input_1_10"; //Enter your CSS Selector for the hidden field here
if(document.querySelector(selector)){
document.querySelector(selector).value = {{cookie - utm_keyword}};
};
})();
</script>
The "#input_1_10" is usually how I direct the cookies into the correct hidden form fields. This is typically the input id.
With HubSpot hidden forms, the input id does not exist.
So now, I cannot pass the cookie information into the HubSpot form field and I need to be able to do that.
Is there an easy way to ensure that all utm parameters will be sent to Hubspot via cookie to hidden form fields with corrisponding 5 utm fields in Hubspot? For example, if I have a fully dynamic utm tagged Google ads final destination url, and I have all these utms configured in Hubspot, will I be able to drill down Hubspot reports without using the default utm_campaign that the Hubspot system uses? Can I just see the utms in Hubspot that were stored in the final destination url in my Google ad?