Welcome to Instabug's Documentation! Here you'll find
a comprehensive technical guide to help you start
working with the Instabug SDK as quickly as possible.

Get Started

Targeting Surveys

Detailed here is how you can target specific users for your In-App Surveys as well as related APIs.

You can define criteria that your users have to meet in order for your surveys to appear in their app. This can be done through both automatic and manual targeting.

Auto Targeting Surveys

After choosing the survey type you want to create, you can target specific audiences using custom conditions.

When you select Auto Targeting, you can define criteria for who should receive the survey. Your users matching the conditions you set will automatically see the survey. In addition to default attributes like app version, you can set conditions for custom user attributes or user events that you have created.

This is the audience targeting step of the survey creation flow in your dashboard, with **Auto Targeting** selected.

This is the audience targeting step of the survey creation flow in your dashboard, with Auto Targeting selected.

Controlling Auto Targeting Surveys

You can have auto targeting surveys shown automatically at the start of a user's session or show it manually.

Showing Automatically

By default, a survey will automatically be presented to users who meet your conditions in their first session after you publish the survey within 10 seconds of opening your app. If you have multiple surveys running and a user meets the conditions for more than one survey, they will be shown each survey one by one.

Showing Manually

You can also customize when you want to show your auto targeting surveys. To do this, first disable automatic showing using the following API.

cordova.plugins.surveys.setAutoShowingEnabled(
            true,
            function () {
                console.log('Invoke method called!');
            },
            function (error) {
                console.log('Invocation event could not be set - ' + error);
            }
        );

Then, present the surveys using the below APIs.

cordova.plugins.surveys.showSurveyIfAvailable(
  					function () {
                console.log('Invoke method called!');
            },
            function (error) {
                console.log('Invocation event could not be set - ' + error);
            }
				);

Auto targeting surveys can only be shown a maximum of two times. Learn how to set the conditions for re-showing dismissed surveys here.

Manual Targeting Surveys

You can also use Manual Targeting to show your surveys to specific audiences, and these surveys can be re-shown any number of times.

Each created survey has a unique token that you can refer to in your code, as explained in the following section.

This is the audience targeting step of the survey creation flow in your dashboard, with **Manual Targeting** selected.

This is the audience targeting step of the survey creation flow in your dashboard, with Manual Targeting selected.

Controlling Manual Targeting Surveys

When you want to target your surveys to specific users, like only users who opt-in, manually targeted surveys might be the best method. You can use the following API to show a survey with a specific token.

cordova.plugins.surveys.showSurveyWithToken(
    'SURVEY_TOKEN',
    function () {
      console.log('Survey with token shown.');
    },
    function (error) {
      console.log('Survey with token could not get shown - ' + error);
    }
  };

You can also check if a specific user has responded to a survey or not through the following API.

cordova.plugins.surveys.hasRespondedToSurveyWithToken(
  'SURVEY_TOKEN',
  function (hasResponded) {
    console.log('Has Responded: '+hasResponded);
  },
  function (error) {
    console.log('Could not get the value - ' + error);
  }
);

The above API is particularly useful since you can manually show a survey multiple times to the same user. More information can be found here regarding re-showing surveys.


What's Next

Now that you've learned how to target your users, check out how to customize behavioral elements of your surveys.

Customizing Survey Behavior