Track UTMs in HubSpot Form Module (Page Builder)
Add the form module into your page.
After that insert our UTMSimple script as explained here: Where is the tracking code?
And add the following snippets anywhere in your page:
<script>
window.addEventListener('message', event => {
if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormReady') {
let form_id = event.data.id
let f = handlj("[data-form-id='"+form_id+"']")
f.serializeArray().map(x=>{
let cookie_val = Cookies.get(x.name)
if (cookie_val && cookie_val != ''){
f.find('input[name="'+x.name+'"]').val(cookie_val).change();
}
})
}
});
</script>