> For the complete documentation index, see [llms.txt](https://docs.pulseinsights.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pulseinsights.com/implementing-pulse-insights-dev/implementing-on-web-and-mobile-web/callbacks.md).

# Callbacks

Callbacks enable custom functionality such as:

* Integrating with custom vendors that use tag-based integrations on your website
* Ingesting data from the dataLayer
* Creating custom logic or functionality

## Two Ways To Implement Callbacks

### JavaScript

```javascript
pi('oncomplete', function(survey) {
     ... your callback code here ...
  });
```

### In Console

You can manage callback code in Console, described in more detail [here](/configuring-pulse-insights-console/account-level-settings/data-and-integrations-callbacks.md).&#x20;

## **Callback Types**

| Type                                                                 | Executes When                                              | Details                                                                                                                                                                                                                                                                                                                                                                                                                   |
| -------------------------------------------------------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><strong>On Impression</strong><br><code>onimpression</code></p>   | Platform delivers a survey to the page                     |                                                                                                                                                                                                                                                                                                                                                                                                                           |
| <p><strong>On Viewed Impression</strong><br><code>onview</code> </p> | Survey appears in the viewport                             | <p>When a survey is configured to display as soon as the page loads, the Viewed Impression callback will execute right after the Impression callback</p><p></p><p>Conversely, when a survey is dependent on user behavior (time on page, scroll percentage, etc.) or is attached to a page section that is not visible on page load, the Viewed Impression callback will only execute when the survey becomes visible</p> |
| <p><strong>On Answer</strong><br><code>onanswer</code></p>           | User submits an answer                                     | Can fire multiple times for a multiple question survey                                                                                                                                                                                                                                                                                                                                                                    |
| <p><strong>On Complete</strong><br><code>oncomplete</code></p>       | All questions in a survey path are answered                | When a survey contains a single question, the Oncomplete callback will execute right after the Onanswer callback                                                                                                                                                                                                                                                                                                          |
| <p><strong>On Close</strong><br><code>onclose</code></p>             | The survey is closed                                       |                                                                                                                                                                                                                                                                                                                                                                                                                           |
| <p><strong>On Click</strong><br><code>onclick</code></p>             | An anchor tag within a custom content question is clicked. | This callback is only available to use when the account setting "Custom Content Link Tracking" is enabled.                                                                                                                                                                                                                                                                                                                |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.pulseinsights.com/implementing-pulse-insights-dev/implementing-on-web-and-mobile-web/callbacks.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.
