# 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](https://docs.pulseinsights.com/configuring-pulse-insights-console/account-level-settings/data-and-integrations-callbacks).&#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.                                                                                                                                                                                                                                                                                                                |
