Include Referrer in form within IFRAME

Last Update: February 28, 2016

UPDATE: Capturing the referrer is now pretty easy.Simply add this widget to your form Get Referrer. If you want to capture the URL where the form is embedded, use this widget Get Form Page URL. These widgets work on iframe embedded forms.

Browser Security prevents us from getting the referrer of the IFRAME's parent from within the IFRAME so we must pass it into the frame.  Here is how: 

1: Add a text field and then hide it (unless you want your user to see their referrer).

2: Populate this field in the form by adding a variable to the IFRAME url containing the php global variable, $_SERVER['HTTP_REFERER']. 

If your field is called 'referrer' this is what would need to be added to the url:


e.g., append a query variable to the iFrame tag:<?php echo $_SERVER['HTTP_REFERER'];?> 


MichelleFait (August 25, 2015 at 04:26 PM)

I integrated this form with Mailchimp and I am trying to see how I can add tracking on my Mailchimp side to show that the subscriber came from Jotform. I set up the integration and tested but when I go to see the subscriber It says it came from API Generic. I tested the above Todo and it didn't function properly.

This is my IFRAME CODE: Where do I add this code? $_SERVER['HTTP_REFERER'] or maybe I am missing a step?

window.handleIFrameMessage = function(e) {var args =":");var iframe = document.getElementById("JotFormIFrame");if (!iframe)return;switch (args[0]) {case "scrollIntoView":iframe.scrollIntoView();break;case "setHeight" = args[1] + "px";break;case "collapseErrorPage":if (iframe.clientHeight > window.innerHeight) { = window.innerHeight + "px";}break;case "reloadPage":window.location.reload();break;}};if (window.addEventListener) {window.addEventListener("message", handleIFrameMessage, false);} else if (window.attachEvent) {window.attachEvent("onmessage", handleIFrameMessage);}

View Answer

FeedbackForMe (February 23, 2016 at 02:14 PM)

Can questions have dynamic text? I don't want fields to be pre-populated, but rather want "referrer" above to customized. If this can be done, how do I do it?

View Answer

Send Comment