How do I get the measurements to work correctly when GravityForm is embedded in an iframe on another site?

I am creating a contact form in GravityForm for a client.

There are two hidden fields in the contact form, EmbedURL and RefURL, and I have set the following merge tags for the default values.

Correspondence between field names and merge tags
EmbedURL → {embed_url}
RefURL → {referer}

I create the form on my site and display it on a page.

The customer embeds that page into their site using an iframe.
The form is displayed in an iframe embedded in multiple pages.

For example, if the form was submitted from page1, the value that would go into the merge tag would be as follows
{embed_url} → https://mysite/clientA
{referer} → https://ClientAsite

Similarly, when a form is submitted from page2, the value in the merge tag is as follows.
{embed_url} → https://mysite/clientA
{referer} → https://ClientAsite

If the form is submitted from page1, then
{referer} → https://ClientAsite/page1

If the form is submitted from page2
{referer} → https://ClientAsite/page2

How can I make it so?

Gravity Forms doesn’t support embedding the form outside of the site where the plugin is running. Therefore the use case described is not supported out of the box.

The merge tags that you’re using are designed to get the information from the server PHP’s $_SERVER global variable, so values would be according to what the server where your plugin is running is passing to Gravity Forms.

There’s an old third-party add-on for iframe embedding, I can’t tell if it’s going to help for the above use case or if it’s still working with recent versions of Gravity Forms, but you could give it a try.

If that doesn’t help, I would recommend you to hire someone to work with you in a custom solution. Gravity Forms are official partners with Codeable , who are the #1 WordPress outsourcing service. They can provide quality development from hand-picked Gravity Forms specialists for any project size and budget. Additionally, they can also provide you with a no obligation estimate of what the project may cost up front.

You can also post to our Community Forum Job Board, We do not vet any of the individual developers there, it is an open forum for all, but our community is certainly full of talented folks!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.