# Custom Survey Trigger

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:

```javascript
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:

```javascript
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.

{% hint style="info" %}
For more advanced JavaScript API usage, see the [Javascript API](https://docs.zigpoll.com/javascript-api) documentation.
{% endhint %}
