I have an iFrame-embedded Qualtrics survey installed on a client site. I need to be able to capture the parent page's URL and UTM (key value pair) into Qualtrics. I am able to capture the parent URL by using an embedded variable as described here, but not the key value pair. I have added an additional embedded data variable for the key value ("Mode"), but I don't know how to adjust the JS to include it. Any advice would be a HUGE help!
Here is the JS I'm currently using for the parent URL:
var parentUrl = (parent != window) ? document.referrer : "";
Qualtrics.SurveyEngine.setEmbeddedData("parentUrl", parentUrl);
Solved
How to pass key value pair from iFrame parent into Qaultrics?
Best answer by jaemaz
Thanks for the response @bgooldfed . I couldn't quite figure it out with your suggestions, but I did get help from a colleague and now it is working as intended.
I've outlined the solution below for the sake of anyone searching for this solution in the future. Let me know if I missed something or if you have an idea for making this little explainer more clear.
- Go to Survey Flow within your survey and create a new Embedded Data element at the beginning of your survey.
- In the Field dropdown that appears in the Embedded Data element type in this value: parentUrl (This value is custom -- it is not found in the list).
- Click Add a New Field, and enter Mode (This value is custom -- it is not found in the list).
- Click Apply, publish your survey and copy your survey link.
- Navigate to the back-end of the website where you want to place the survey.
- Enter the following script on the page where you want the survey to appear (add or remove whatever iframe parameters your want in the process, and replace "YourQualtricsSurveyLink1234567" with the URL for your survey.
8. Save the page. You should now be able to provide your audiences with custom URLs on the parent domain using various single key-value pairs (using "Mode" as the key). For example, if your survey was placed on this parent page: https://my-interesting-research-project.com/survey/, you could send out this URL https://my-interesting-research-project.com/survey/?Mode=AdChannelOne , and the parent url and "AdChannelOne" would pass through into Qualtrics.
9. Lastly— in order to see the key-value pairs you capture this way, navigate to the Data and Analysis tab, click on Column Chooser, then hover over Embedded Data— you will see all the available Embedded Data elements in your survey. Select parentUrl and Mode to make sure those captured values appear within your column view.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
