Embed a SurveyMonkey Survey in a WordPress Page

surveymonkey surveySurveyMonkey is a great service (with a free option) that allows you to create sophisticated surveys. I just created a survey for a client and wanted to add it to their WordPress site … but found how painful it can be to embed javascript within a WordPress page or post. After much trial and error, I came across a solution that doesn’t require a plugin or editing the PHP in your page templates. This approach will let you embed any external javascript widget within a WordPress page or post – event invitations, calendars, social media feeds, etc.

Once you’ve created your survey in SurveyMonkey, go to the “Collect Responses” tab and create a “Website Collector”. Choose the “Embed” option.

embed surveymonkey survey in wordpress

Copy the HTML code that SurveyMonkey generates for you.

surveymonkey javascript embed code

Create a new page or post in WordPress and switch to the HTML option for the WYSIWIG editor. Paste the SurveyMonkey code in the editor.

Strip all the extra <div>’s out until you’re left with something that looks like this. DO NOT switch back to the visual option for the editor – it will mangle the HTML and you’ll be unhappy. Wrapping the <script> tags in <div> tags keeps WordPress from inserting <p> tags, which make your widget “disappear”.

embed javascript in a wordpress page

Publish your page or post and you’re done! No plugins necessary, no template changes, no PHP. If you save your page as a draft and try to view it in preview mode, the survey likely won’t show up. I don’t know why … but if you publish it, the survey will be there.

What sorts of widgets are you going to embed in your site???

  • Pingback: Survey Skipper

  • Kieran Hyder

    Hi Jen. I’ve tried what you suggested to embed a survey monkey survey in wordpress.com. However, I don’t think that wordpress permits any java, so when I paste the link, edit as you suggest and then save the page all the part in between the script statement disappears. Got any suggestions? Kieran

    • http://www.rightbrainlogic.com/ Jen Mozen

      Hi Kieran.  I’m sorry – I’ve never run a site on wordpress.com so I’m not familiar with their restrictions, though what you say makes sense.  I doubt any of the more technical work-arounds involving modifying PHP files are an option for you either.  You may have to resort to launching the survey as a pop-up?  Best of luck!

    • http://www.gamesfromeverywhere.com.au/ David Trounce

      Kieran, I got it to work by saving straight after stripping.

  • Kieran Hyder

    Thanks Jen – thought as much but worth asking. Kieran

  • kevin

    i don’t get the part where it says strip all the ‘s out

    • http://www.rightbrainlogic.com/ Jen Mozen

      Hi Kevin -

      SurveyMonkey auto-generates a block of code for you, but you need to edit it. Here’s the code it generated for my specific survey – all of the extra bits that needed to be stripped out are highlighted in red.

      Does that help?

      Jen

      • http://www.wonderfulwanderings.com/ Sofie

        Hm… The code generated for me doesn’t include any ”, but ”:/

        • http://www.rightbrainlogic.com/ Jen Mozen

          Hm, not sure. Did you set up a “website collector”?

          • http://www.wonderfulwanderings.com/ Sofie

            Yups:/

  • Jacob Wall

    Thank you for this info! It is the easiest & most straight forward instruction I have found for adding a survey to my WordPress blog post. I’m pretty new to this stuff so simple is what I need. I haven’t posted the survey yet, but I’m about to give it a whirl!

    • http://www.rightbrainlogic.com/ Jen Mozen

      Hi Jacob -

      I’m so glad you found this writeup helpful! Best of luck with your WordPress adventure.

      Jen

  • http://dinobaskovic.com/ Dino Baskovic

    Ah, bless your heart for posting a plugin/config-free solution! Everything else I found on forums and such was utterly convoluted.

    • http://www.rightbrainlogic.com/ Jen Mozen

      Yes, I found much of the same when I was looking for a simple solution. Glad you found it useful!

  • Barry Hall

    Great stuff – thanks so much! Easy peasey, lemon squeezie.

  • Betsy Hadley

    Does this work for the free version of SurveyMonkey? I’m on a shoestring budget.

    • http://www.rightbrainlogic.com/ Jen Mozen

      Yes, I was using the free version of SurveyMonkey too!

  • http://www.facebook.com/jess.venner Jessica Venner

    I don’t know if I’m being a bit dim but I just can’t get it to show up, even with your good instructions! Can anyone help me please? This is my code without me messing around with it (so it may not be applying to the above instructions as seen here):

    id=”surveyMonkeyInfo”>

    Thanks!

    • http://www.rightbrainlogic.com/ Jen Mozen

      Hi Jessica -

      Try this:

      Jen

  • http://twitter.com/simonforgacs Simon Forgacs

    Hi Jen! Do you have any advice on how can I use the Invitation Popup on the first page of my WordPress website? Many thanks in advance!

  • http://twitter.com/simonforgacs Simon Forgacs

    Hi Jen! I managed to solve the Invitation Popup issue, and in the mean time I implemented the embed option as well where I could only make work with this version:

    I just wrote down to help anyone with the same issue as I had..

    • http://www.rightbrainlogic.com/ Jen Mozen

      Great, thanks for sharing! Sorry I couldn’t help with the invitation popup – I haven’t used that one yet.

  • Information Managment

    Thank you, friendly friend!

  • Kelly Dietrich

    Thanks for the tip on this! It was exactly what I was looking for and don’t know why Survey Monkey wouldn’t have this info in their FAQs. Thanks again!

  • מיה ליברמן

    Hi Jen,
    Thank you so much for your advise. Becasue of you I managed to put my survey about classical music and music education in may blog: http://www.mymusicaltalent.com
    I will be happy to help you in anything concern to music.