Custom Survey Trigger

Trigger a Zigpoll survey with custom JavaScript events

Use a custom JavaScript call to trigger your Zigpoll survey based on any event — a button click, form submission, scroll position, or any other user interaction.

Step #1: Get Your Poll ID

  1. Go to Surveys → Select your survey → Click the Manage tab.

  2. Copy the Poll ID.

Step #2: Add the Trigger Code

Use the following JavaScript to render and open your survey:

function renderZigpoll() {
  var pollId = YOUR_POLL_ID;
  window.Zigpoll.pollId = pollId;
  window.Zigpoll.onload = function () {
    window.Zigpoll.open();
  }
  window.Zigpoll.refresh();
}

Step #3: Call the Function on Your Event

Hook the function into whatever event you'd like. For example, a button click:

function renderZigpoll() {
  var pollId = YOUR_POLL_ID;
  window.Zigpoll.pollId = pollId;
  window.Zigpoll.onload = function () {
    window.Zigpoll.open();
  }
  window.Zigpoll.refresh();
}

document.getElementById('zigpoll-button').addEventListener('click', function () {
  renderZigpoll();
});

Replace YOUR_POLL_ID with the Poll ID from Step #1.

circle-info

For more advanced JavaScript API usage, see the Javascript API documentation.

Last updated