The Javascript API

Using the Javascript API to specify user IDs and custom properties
Using Informizely's Javascript API you, or your developer, can associate any number of custom properties ("name-value" pairs) with a response. Each custom property that is set on a page where a survey is shown is displayed in the responses view for the survey. These custom properties can also be used to target your surveys against.

Example

You want to show a survey only to visitors that made a purchase in the last 7 days. Informizely can't know whether this is the case, but your website knows this. In this case your website could, using the Javascript API, set the custom property made-purchase to the value yes. In the survey's targeting settings you would then add the custom property "made-purchase=yes". Note that you can set any number of custom properties and that the texts used in the name-value pair are completely up to you. Informizely does not interpret these texts in any way, other than to match them with the currently set custom properties.

User identification

If your website has registered users, and you want to target your survey to some or all registered users, or to unidentified users, you could use custom properties, like in the example above. But especially for this case Informizely's Javascript API has a special setting. Your website can set the current user's ID to any identifying property, e.g. the user's email address or customer ID. You can then target your survey to some or all identified users, or to unidentified users, using the survey's target setting "Target (un)identified users". The user ID will be shown in the response view for all responses where it was set.

Using the Javascript API

It's very simple to pass data to the Informizely widget using the Javascript API: first you retrieve a handle to the "api" object, and then you call the appropriate functions on it.

Note: the term "insitez" used below refers to the previous name of Informizely.

To retrieve the "api" object, add the following code directly before the normal Informizely code snippet:

To set the user ID, call api.set('userId', '<<<USER-ID>>>'), where <<<USER-ID>>> is replaced with the current user's identifying property, e.g. his email address.
To set one or more custom properties, call api.set('custom', { <<<name-value-pairs>>> }), where <<<name-value-pairs>>> is replaced by one or more 'name':'value' pairs, separated by commas.

These API functions can be called any number of times. At every call the Informizely widget will check if there are surveys to be displayed.

Complete example