Yecats
Yecats

Reputation: 1815

Detect change in iframe for survey monkey

I am embedding a survey monkey survey onto my page and I want to detect when the user submits the survey and is routed to the "thank you" page. (At this point I want to redirect to another page, lets just say www.google.com for simplicity sake). How do I detect a change within the div to the survey monkey confirmation url? (Which seems to be: http://www.surveymonkey.com/Home_Landing.aspx?sm=HO4sAuxWGVqYlHQe3fZmKuIQKB2Chu5Pcw9UfeB2rP5FLvW8Xg8B7nyhEj9ZH1Fe)

Here is the survey monkey embedded info they have me add:

    <div id="surveyMonkeyInfo">
<div><script src="http://www.surveymonkey.com/jsEmbed.aspx?sm=vWWHOiYv9Mb1LAjgBfpOEw_3d_3d"> </script>
</div></div>

Upvotes: 2

Views: 4082

Answers (2)

dougwig
dougwig

Reputation: 616

Currently with embedded SurveyMonkey forms (which are delivered in an iframe) you can monitor the iframe messages to detect load and success.

If you listen for the messages from https://surveymonkey.com you'll see: "survey messages"

Upvotes: 0

user885100
user885100

Reputation:

SurveyMonkey has the ability to basically provide a callback site.

http://help.surveymonkey.com/articles/en_US/kb/Can-I-redirect-respondents-to-a-different-website-upon-completion

Another option using jquery to check the iframe for contents that indicated a completed survey. This will not work by directly linking to the survey through the iframe because you would then being attempting to access data across different domains.

$().ready(function(){
if($('#surveyFrameId').contents().find("div .embed_title").val() == 'Thank you for taking the survey!'){
    // do something
}

setTimeout(arguments.callee, 10000);})

You could something as indicated in the post below to get around the cross-domain issues.

Unsafe JavaScript attempt to access frame with URL

Upvotes: 1

Related Questions