- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Populating hidden form fields with information stored in cookies
Aug 18, 2020 3:41 PM - edited Aug 18, 2020 6:13 PM
Hello HubSpot Community,
I am trying to store the following values in a cookie (or various cookies) and later use the cookie to populate hidden fields on an embedded HubSpot form:
1.) UTM parameters
2.) GCLID (this could be included in UTM parameters, but wanted to call it out specifically as it’s a key value I’m seeking to collect)
3.) Google’s Client ID: _ga (I think this is set by Google already, but am having trouble extracting it)
I have read numerous articles on how to accomplish this and believe I understand the concept — the point of setting these cookies is to ensure we don’t lose the data when the user visits multiple pages of our website before converting on a form. I also understand that if a user enters the site with UTM parameters in the URL and, without leaving that page, submits a form we will get these values no problem... so that is a non-issue.
So far, I think I’ve been able to set and store the cookie(s), but I have not been able to populate the form fields with this information. I’ve tried editing the code directly, as well as using GTM to set, store and extract the cookie information without success. That said, I am an intermediate coder at best and my understanding of GTM is limited so it’s hard for me to troubleshoot efficiently.
I’ve currently removed any code and paused all GTM tags because nothing was working, but the form I am using to test this process lives here: https://headrushtech.com/jenna-test (ignore the styling). I plan to hide the fields, but for now have left them visible to make testing easier.
Some of the main methods I have tried include:
- Store GCLID in Cookie and Send to Hubspot
- How to capture UTM Parameters in a Cookie and transfer them to a (hidden) Form Field - YouTube
- Solved: HubSpot Community - Re: Send event from hubspot to google analytics also set form field when...
- HubSpot Community - Pass cookie information to the form - HubSpot Community
- HubSpot Community - Help: Javascript Snippet + Google Tag Manger to fill hidden field from cookie va...
I've created the necessary contact properties and know that the name needs to match exactly when I use it in the code:
- utm_campaign
- utm_medium
- utm_source
- utm_content
- utm_term
- gclid
- cid
I have also toggled on the "set as raw HTML form" setting for the form I am using.
Additionally, thought I’d mention that we use Magento for our CMS (this seems kind of non-stardard so not sure if it's causing any issues?) Also, our website is poorly coded in my opinion and I'm seeing a lot of errors in Console that might prevent this process from working, though I'm really not sure.
It would be really appreciated if you don’t point me to another community post, as I feel like I’ve read through so much and just need help with my specific situation / MarTech stack.
I'm hoping someone can tell me what specifically I need to create in GTM (tags, triggers, variables, etc.) and/or what specifically I need to add to the form embed code and where / in what order.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content