Share your poll

Embed a poll on your website

Add a poll, survey or form directly to your own site, inline, as a popup or full page, with step-by-step instructions for every website builder.

Last updated

Show your poll where your visitors already are, instead of sending them to another site to answer. Everything you make with StrawPoll embeds the same way: quick polls, multi-page surveys, quizzes, meeting polls, sign-up sheets and forms with file uploads.

To put a poll into an email instead of a web page, see Put a poll in an email or newsletter.

Free on every plan

Embeds are free. A free account can embed as many polls as you like, on as many sites as you like, and collect unlimited responses. No paid plan is required.

  • No ads. Embedded polls never show ads, on any plan.
  • A small badge on Free and Basic. Embedded polls show a “Made with StrawPoll” link at the bottom. Pro and up remove it, so the poll looks like part of your own site. Compare plans on the pricing page.
  • Your look. The embed uses the poll’s theme. To match your site, set its colors and font, or on Pro add your logo and custom CSS, see Change the design with themes.

Before you embed

Decide on the following first, since visitors start answering as soon as the page is live:

  1. Publish the poll. A draft cannot be embedded. See Drafts and publishing.
  2. Choose how to limit responses. On someone else’s website you can’t see who is voting, so this matters more than on a shared link. See Embeds and duplicate votes below.
  3. Choose who sees the results. Right after voting, once the poll closes, or only you. See Choose who sees the results.
  4. Consider one-click voting. For a single question under an article or post, visitors vote with one click and see the results in the frame, without a Submit button. See Let people vote with one click.

Get the embed code

  1. Open the poll and go to the Share tab, then Embed on a website.
  2. Choose an embed mode: Standard, Popup or Full page. Each is explained below.
  3. Check the Preview on Desktop and Mobile. The preview is view-only, so nothing you click there counts as a vote.
  4. Click Copy code.
The embed settings with the embed mode, the embed code and a preview of the poll on a website

Pick an embed mode

Standard: inside your page

The poll sits in your page content, between your own text and images, like a block of the page. This is the right choice for most blogs, articles and landing pages.

The frame adjusts to the poll’s height automatically, so visitors never scroll inside a box. It grows when someone moves to a longer page of the survey and shrinks again on the results.

Turn on Use a fixed height only if the frame has to keep an exact size, for example in a sidebar or a card of a set height. It then stays at the height you choose, between 300 and 2,000 pixels, and longer polls scroll inside the frame.

Your page shows a button, and the poll opens on top of the page when it is clicked. Use it when the poll is supplementary, such as “Rate this article” or “Take our 1-minute survey”, and should not push your content down.

Set the Button text and the Button color next to it. The popup is up to 640 pixels wide, fits the poll’s height and scrolls once the poll is taller than the window. Visitors close it with the × or by clicking outside it.

Full page: fills the window

The poll fills the whole browser window, as if it were the page itself. Use it for a page of its own on your domain, such as yoursite.com/vote, where nothing else should appear. Comments, if you allow them, appear only in full page embeds.

Add the code to your site

Paste the code into your site’s HTML where the poll should appear. Most website builders have a block for this, called “HTML”, “Code”, “Custom code” or “Embed”.

WordPress

  1. Open the page or post in the block editor.
  2. Click +, search for Custom HTML and add the block.
  3. Paste the embed code into it.
  4. Click Preview to check it, then Update or Publish.

On WordPress.com, scripts only run on plans that allow plugins. Without the script the poll still shows, at the height in the code, see If the script can’t run.

Wix

  1. In the Wix Editor, click Add Elements (+).
  2. Choose Embed Code, then Embed HTML.
  3. Click Enter Code, paste the embed code and click Update.
  4. Drag the element into place and publish.

Wix shows embeds in a box of a fixed size, so drag the element tall enough for the whole poll.

Squarespace

  1. Edit the page and click Add Block where the poll should go.
  2. Choose Code.
  3. Paste the embed code, keep the mode on HTML and leave Display Source off.
  4. Save the page.

Squarespace only runs scripts in code blocks on plans that include custom code.

Webflow

  1. In the Designer, open the Add panel (+).
  2. Drag a Code Embed element onto the page.
  3. Paste the embed code and click Save & Close.
  4. Publish the site.

Scripts do not run in the Designer, so check the poll on the published site.

Shopify

  1. In your admin, go to Online Store → Themes and click Customize.
  2. Open the page where the poll should go and click Add section.
  3. Choose Custom Liquid and paste the embed code into the Liquid code field.
  4. Click Save.

Ghost

  1. In the editor, click + on an empty line, or type /html.
  2. Choose HTML and paste the embed code.
  3. Publish or update the post.

Framer

  1. Click Insert and search for Embed.
  2. Drag the Embed component onto the page.
  3. Set Type to HTML, paste the embed code and size the component.
  4. Publish.

Notion

Notion cannot run embed code, so use the poll’s link instead.

  1. Copy the poll’s link from its Share tab.
  2. In your Notion page, type /embed and press Enter.
  3. Paste the link and click Embed link.
  4. Drag the bottom edge of the embed until the whole poll shows.

Your own HTML

Paste the code into your template where the poll should appear. A standard embed looks like this, with your poll’s link in place of abc123:

html
<iframe
	src="https://strawpoll.com/r/abc123?embed=1"
	title="Your poll"
	width="100%"
	height="640"
	style="border:0;max-width:100%;border-radius:8px"
	loading="lazy"
	allow="clipboard-write"
></iframe>
<script src="https://strawpoll.com/embed.js" async></script>
  • Several polls on one page are supported. Paste each poll’s <iframe>; the script is only needed once per page, though a second copy does no harm.
  • Single-page apps such as React, Vue or Svelte can render the <iframe> in a component and load embed.js once in the page’s <head>. The script picks up frames added later.
  • A Content Security Policy on your site has to allow StrawPoll: add https://strawpoll.com to frame-src and script-src. If your poll runs on your own domain, allow that domain instead.
  • Prefill answers by adding parameters to the src link, such as the visitor’s email or the page they came from. See Prefill answers from the link.

What the script does

The small <script> at the end of the code, embed.js, is about 2 KB and loads after your page, so your own content comes first. The frame itself loads lazily, only when visitors scroll near it. The script does two things:

  1. It fits the frame to the poll. The poll tells your page how tall it is, and the script resizes the frame as people answer.
  2. It recognizes returning visitors. Many browsers block StrawPoll’s cookie inside frames on other sites. The script keeps a random visitor id in your site’s own browser storage instead and hands it to the poll, so a visitor who comes back is still known. The id says nothing about who the visitor is and is only used to limit votes.

StrawPoll’s own analytics do not run inside embedded polls.

If the script can’t run

Some builders and plans strip scripts. The poll still shows and works, with two differences:

  • The height stays fixed at the height in the code. Turn on Use a fixed height before you copy the code and choose a height that fits the whole poll, or make the builder’s embed box tall enough.
  • The browser check is less reliable. Without the visitor id, a browser that blocks StrawPoll’s cookie in frames, such as Safari or Firefox, looks like a new visitor each time. Use one of the other checks below.

Embeds and duplicate votes

An embedded poll uses the same settings as its link, including the Duplicate check in the Settings tab. Which one fits depends on your page:

Your pageDuplicate check
A blog post, news article or fan pageBrowser session to stop casual repeat votes, or IP address when it matters more
A contest or vote people care about winningIP address, plus blocking VPNs and bots
An intranet or members’ areaUnique code, with each member’s code in the embed, see Allow one vote per member on your website
A survey for a known groupEmail address, with verified emails if the result counts

Please note that everyone in one office or school shares an IP address, see “You have already voted”, but I haven’t. Compare all options in Choose how to limit responses.

After it’s live

  • Edits apply immediately. Change the questions, theme or settings and publish, and the embed shows the new version. You never need to replace the code.
  • Results stay in the frame. When visitors see results after voting, they open inside the embed too, sized like the poll.
  • Responses are collected as usual. Read them on the poll’s Results tab, get notified about new ones or send them to Google Sheets, Slack and more.
  • Close it when voting is over. Closing the poll shows visitors that voting has ended, while the embed stays on your page.

If something looks wrong

  • The poll is cut off or has a scrollbar. Check that you copied the whole code, including the <script> at the end, and that your builder runs scripts. If it doesn’t, use a fixed height that fits the poll, see If the script can’t run.
  • There is empty space under the poll. Your builder sets its own box height. Make the box shorter, or let it size to its content.
  • Nothing shows at all. The poll may still be a draft, or a Content Security Policy on your site blocks the frame. Open your browser’s console to see which.
  • Your edits are not visible. Make sure you published them, then reload the page. See My changes don’t show up for voters.
  • Visitors are told they already voted. They most likely share a network with someone who voted, see “You have already voted”, but I haven’t.

Related articles