# 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](/javascript-api.md) documentation.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zigpoll.com/tutorials/custom-trigger.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
