2

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>
SgtPooki
  • 11,012
  • 5
  • 37
  • 46
Yecats
  • 1,715
  • 5
  • 26
  • 40

1 Answers1

1

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

Community
  • 1
  • 1
  • You'll want to follow this advice. There is no way for your parent page to know what is happening in the iframe (child), as it is a seperate webpage, UNLESS that child is willing to pass information back via js...i.e. an API. I use this with video embedding, though have not used survey monkey. – Josh Dean Mar 04 '13 at 02:38
  • I can't go this route - this is for paid users only. – Yecats Mar 04 '13 at 02:42
  • You will have a very difficult time ever knowing that the survey was submitted. You could maybe try to detect the contents of the iframe? –  Mar 04 '13 at 02:48
  • I was thinking about detecting when the iframe redirects to a new page. Is there anyway to hook onto the iframe's onload event? – Yecats Mar 04 '13 at 02:57
  • 1
    I don't think so. It would be a security risk to know what is happening inside of an iframe. – Michael Theriot Mar 04 '13 at 02:58
  • You could try launching the survey in a new child window and detect when it has been closed. This would be a questionable solution but you may have more luck. –  Mar 04 '13 at 03:06
  • The "proper" solution would be a "callback url" at the end of the survey (which is on your domain and can communicate with the parent page). I doubt SurveyMonkey supports this - am I wrong? Is there such a setting? –  Oct 30 '14 at 13:16