Pass url parameters to a embedded forms/iframes on landingpages

前端 未结 1 1933
离开以前
离开以前 2021-01-29 08:17

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

相关标签:
1条回答
  • 2021-01-29 08:44

    This is possible using Typeform Embed API

    See a working example on Glitch

    You can edit here.

    Steps to reproduce:

    1. Include Typeform Embed SDK in your HTML
    2. Extract parameters from URL

      let params = new URLSearchParams(location.search);

    3. Reconstruct your form URL

      var url = "https://YOUR_SUBDOMAIN.typeform.com/to/YOUR_TYPEFORM_ID" url += "?utm_source=" + params.get('utm_source');

    4. 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 :)

    0 讨论(0)
提交回复
热议问题