How to implement prefill using URL parameter to airtable form embed in webflow

I’ve embedded an airtable form in a page built with webflow.
I wanted to prefill airtable form using the URL parameter, but I don’t know how to do it.

First, I embedded the airtable form in a page built with webflow, referring to the following site

Then I realized that I can write prefill directly in the embed code.

However, what I want to do now is to prefill the embedded airtable form using the URL parameter, but I don’t know how to do it.
I have a feeling that I can do it by applying the code in the URL below, but the code is too complicated for me to understand.

I’m using deepl, so I apologize if the wording is confusing.

Hi @ihas0318,

In case you’re still looking for the answer…

  1. Add this script to the inside head tag of your webflow page:
<script src="https://static.airtable.com/js/embed/embed_snippet_v1.js"></script>
  1. Add this iFrame into your embed code. (Note there is no src attribute here. We’ve added an id attribute:
<iframe id="myIframe" class="airtable-embed" frameborder="0" onmousewheel="" width="100%" height="533" style="background: transparent; border: 1px solid #ccc;"></iframe>
  1. Edit the below script according to your needs and install it into the ‘before body tag’ of your webflow page:
<script>
            let myIframe = document.getElementById("myIframe");
            let endpoint = "https://airtable.com/embed/xxxxxxxxxxxxxx";
            let url_string = window.location.href;
            let url = new URL(url_string);
            console.log(url_string);
            let name = url.searchParams.get("name");
            console.log(name);
            let email = url.searchParams.get("email");
            console.log(email);
            let fullURL = endpoint+"?prefill_Name="+name+"&prefill_Email="+email;
            console.log(fullURL);
            myIframe.src = fullURL;
        </script>

Since the URL parameters I’ve used in this script are “name” and “email”, the URL I give to my users should therefore be constructed like so:
https://website.com/yourpage?name=John+Doe&email=john@gmail.com

I hope this solution works for you too!

For more information, see the post by the author of the script:

Hey @Dean_Arnold, thanks for posting this.

Every time I add an “id” tag to the iframe, I get an “airtable.com refused to connect” error:
image

Remove the ID tag and the form displays just fine (or I get a blank screen if there’s no src tag).

Any thoughts on this?

Re-did everything from scratch in case I missed something. Same problem. Some info:

Inside HEAD tag:
<script src="https://static.airtable.com/js/embed/embed_snippet_v1.js"></script>

Before BODY tag:

<script>
            let myIframe = document.getElementById("AirtableEmbed");
            let endpoint = "https://airtable.com/shr...5WB";
            let url_string = window.location.href;
            let url = new URL(url_string);
            console.log(url_string);
            let email = url.searchParams.get("email");
            console.log(email);
            let fullURL = endpoint+"?prefill_Email+Address="+email;
            console.log(fullURL);
            myIframe.src = fullURL;
</script>

In EMBED element:
<iframe id="AirtableEmbed" class="airtable-embed airtable-dynamic-height" frameborder="0" onmousewheel="" width="100%" height="1991" style="background: transparent; border: 1px solid #ccc;"></iframe>

URL:
https://.../survey?email=a@b.com

Appreciate any thoughts.
AL

Hey AL,

Remove the ? from the let fullURL line.

Also, check that your Airtable form field names match up to the script.

My page is working with:

Inside tag

<script src="https://static.airtable.com/js/embed/embed_snippet_v1.js"></script>

Before tag

<script>
            let myIframe = document.getElementById("myIframe");
            let endpoint = "https://airtable.com/embed/shr...jTU";
            let url_string = window.location.href;
            let url = new URL(url_string);
            console.log(url_string);
            let name = url.searchParams.get("name");
            console.log(name);
            let email = url.searchParams.get("email");
            console.log(email);
            let fullURL = endpoint+"prefill_Name="+name+"&prefill_Email="+email+"&prefill_Receive+Email+With+Results=true";
            console.log(fullURL);
            myIframe.src = fullURL;
        </script>

Html Embed code

<iframe id="myIframe" class="airtable-embed" frameborder="0" onmousewheel="" width="100%" height="100%"  style="background: transparent; border: 0px solid #ccc;"></iframe>

Thanks for the reply @Dean_Arnold! Appreciate you taking some time with me.

I’ve checked and re-checked. Tried removing the “?”, renamed my ID from “AirtableEmbed” to the same as yours. Copy and pasted stuff in again. Not getting any love here.

I’m looking at the console, and I do see the following:
image

  1. Looks like I need the “?” since it’s missing from the URL.
  2. After plugging that in, the console log looks great. The link to Airtable is perfectly formed, and when I click on it from the console it loads up just like it should.

The problem is this “Refused to display” line from Airtable and the X-Frame-Options setting. X-Frame-Options appears to be a setting that restricts embedding. Which seems strange for Airtable to reject, considering this is embed code.

It fails the minute I add the ID tag to the iFrame. I’ve tried moving code to the header, body, inline, etc. Nothing seems to get past this.

Will try Airtable support. This shouldn’t be this hard, and I have no idea why it works for you and not me! Oy.

Wow. Ok. Figured this out after quickly chatting w/ Airtable support.

It’s a sad one, and it’s 100% on me.

Don’t forget the “/embed/” in your URL!

sigh

I managed to remove mine somewhere along the way, thus the issue.