Integrations - Linking surveys in an iFrame

Introduction

Currently, certain browsers do not allow a web page from a remote domain hosted in an iFrame to set cookies unless there is an existing session cookie from the remote domain. This causes Research Studio questionnaires not to work as expected when presented in an iFrame.

Solution

As a workaround to this, an HTML page is available on the Research Studio Data Collection cluster that will set a session cookie allowing a questionnaire to work in an iFrame.  If you want to run a questionnaire in an iFrame you will need to use a page load function to check if a Data Collection cookie has been set, and if not, set one. 

The process should be as follows:

  • On Page Load check if a Research Studio Data Collection cookie has been set.
    • If Yes  
      • Do nothing - iFrame will work
    • Otherwise  
      • Set a cookie value showing Research Studio Data Collection cookie has been set.
      • Redirect to http://dc.miprocloud.net/dcwebengine/SetDcCookie.htm
      • This will in turn redirect back to a chosen page (through ‘caller’ parameter), or to the calling page (effectively this will not affect the user at all)

SetDcCookie.htm

This is the page that sets the Research Studio Data Collection cookie.  It accepts a parameter ‘caller’ which is the location of the page that it will redirect to.  If the caller parameter is not set the page will try to redirect to the previous page in the browser history.

Example

window.location = 'http://dc.miprocloud.net/dcwebengine/SetDcCookie.htm?caller=http://mipro.net'; 

Example Code to include on page that will load data collection in an iFrame

The code below uses the jQuery Document Ready function to check for a set a data collection cookie.

$(document).ready(function() {  try {   if (parseInt(document.cookie.indexOf('RS_ready')) < 0) {   //Set Cookie    document.cookie='RS_ready=true';    if (document.cookie.indexOf('RS_ready') < 0) {     //Setting Cookies failed - Cookies disabled     alert('Cookies are disabled in your browser, you will need to enable cookies to continue. (Code pu 101)');                }    else {     //Redirect to DC page to set cookie     window.location = 'http://dc.miprocloud.net/dcwebengine/SetDcCookie.htm?caller=http://91.106.193.220/dev/Popup';    }   }  }  catch(err) {   //Setting Cookies failed - Cookies disabled   alert('Cookies are disabled in your browser, you will need to enable cookies to continue. (Code pu 102)');   } });

Still need help? Contact Us Contact Us