# Data & Integrations (Callbacks)

## Integrating with Other Services

Pulse Insights was built to easily integrate into other services. For example:

* You might want to push survey responses into Google Analytics or Adobe Analytics so you can add the missing context to traditional web analytics data
* If the survey is targeted to your customers, you might want to push results into your CRM system
* You may want to place the current user into a DMP segment or A/B Test segment based on what they answer
* Similarly, you might want to push preferences into your Personalization profile

{% hint style="info" %}
Because CRM setups tend to vary from client to client, CRM integrations are configured and managed by Pulse Insights Tech Ops. Get in touch with your Customer Success Manager (CSM) if you need to add or make changes to your CRM integration.
{% endhint %}

Pulse Insights supports the following integration methods:

* Real-time API call upon question submissions
* Hourly/daily feed placed on client’s or Pulse Insights’ sftp server
* JavaScript callouts on question submissions

## Callbacks

Under the "Setup" dropdown menu, you’ll find the **Data & Integrations** page with the following callback code hooks:&#x20;

### **Impression Callback**&#x20;

Impression callbacks are executed when the survey has an impression.

You can use the `pi('set_context_data', object);` to save context data along with the survey results.\
The object can be a javascript object, arrays, string or integers size limit is 1000 characters once serialized into JSON.\
\
Examples:\
`pi('set_context_data', {gender: 'male', age: 32, locale: 'en-US'});`\
`pi('set_context_data', 'christmas_promotion');`

### **Viewed impression Callback**

&#x20;(Only available if "Viewed Impression" feature is enabled for your account). This callback is executed as soon as the survey is viewed by the user.

### **Onanswer Callback**

This code snippet will be executed after each answer submission (after submitting but right before the /answer HTTP call).

\
The `survey` object gives you access to all the data related to the survey and the `question` object the answered question.\
Also, an `answer` object gives you access to the last answer submitted and will be formated as the following:\
\
Single choice question: `{ id: the_possible_answer_id, content: 'asdf', next_question_id: 1234 }`\
Multiple choice question: `{ id: the_possible_answer_id, content: 'asdf', next_question_id: 1234 }`\
Free text question: `{ id: null, content: 'asdf', next_question_id: 1234 }`

### **Onclose Callback**

This code snippet will be executed when the survey is closed before all of its questions have been answered.

\
The `survey` object gives you access to all the data related to the survey.

### **Oncomplete callback**

This code snippet is executed after the survey submission and the `survey` object gives you access to all the data related to the survey and the submitted answers.

\
`survey.questions` returns all the details about the survey questions and `survey.answers` returns the submitted answers by the user.

\
In case of Onanswer Callback, `answer` and `question` objects representing the current answer and question will be also present.\
\
Example:\
`var firstQuestionContent = survey.questions[0].content;`\
`var firstAnswerContent = survey.answers[0].content;`\
`ga('send','hitType': 'event',`\
&#x20; `'eventCategory': 'survey',`\
&#x20; `'eventAction': 'response',`\
&#x20; `'eventLabel': firstQuestionContent,`\
&#x20; `'eventValue': firstAnswerContent`\
`});`

### Onclick callback

This code snippet is executed after an anchor tag within a [custom content ](https://docs.pulseinsights.com/configuring-pulse-insights-console/editor/question-types/custom-content-next-best-action)question gets clicked.

This callback is only available to use when the account setting "[Custom Content Link Tracking](https://docs.pulseinsights.com/configuring-pulse-insights-console/account-level-settings/configured-by-pulse-insights)" is enabled.&#x20;
