I want to pass url parameters (hidden fields) to iframe/embedded forms on our Hubspot landing pages.
The url parameters I want to pass to the Typeform are utm_sour
This is possible using Typeform Embed API
See a working example on Glitch
You can edit here.
Steps to reproduce:
Extract parameters from URL
let params = new URLSearchParams(location.search);
Reconstruct your form URL
var url = "https://YOUR_SUBDOMAIN.typeform.com/to/YOUR_TYPEFORM_ID"
url += "?utm_source=" + params.get('utm_source');
Display form in a target div
const embedElement = document.querySelector('.target-dom-node')
window.typeformEmbed.makeWidget(
embedElement,
url,
{
hideHeaders: true,
hideFooter: true,
}
)
Hope it helps :)