Skip to main content

Advanced Usage

Sample Scenarios​

This section describes several alternative scenarios you can try with the base app you created in the previous sections.

The following scenarios are discussed:

  • Using Intercept Logic to Solicit App Reviews: You can use an intercept's logic to determine whether the user should be asked to review the app. This lets you adjust the frequency of the requests at any time on the server rather than needing to add additional logic to the app, recompiling it, and resubmitting it to the app store.
  • View Targeting: If you use a property to save the name of the current activity/view controller, you can create logic on the server that displays different surveys depending on which screen the user is accessing. You could use this scenario to display different surveys for newly created UI such as a new settings screen or a new login screen.
  • Using Embedded Data: You can also use the properties collection to alter a survey's text. In this case, the user's first name is sent back to the server via a custom property, which is displayed to the user with piped text on the survey.
  • Controlling the Survey Presentation: If you would like to create your own means of presenting a survey rather than calling the display method, you can use this scenario to create custom survey invitations.
  • Bypassing the Give Feedback Prompt: You can use this scenario to go directly to the survey instead of asking first whether your users want to give feedback. This scenario is ideal for having a Give Feedback button in your app that you want to go straight to the survey.
  • Using Local Notifications: You can use local notifications within your app in order to show the feedback survey prompt to users when the app is not in the foreground. This is most helpful in scenarios such as app-exit when you want to measure app visitors' experience after they have interacted with your app.
  • Using Intercept Action Sets Within Your App: You can include logic to show different creatives within the same app as needed. This is typically the case if you are trying to capture end-user VOC across different app journeys.
  • Personalizing App Intercepts with Qualtrics XM Directory: The Qualtrics XM Directory can also be used to personalize your in-app listening and drive deeper customer segment and journey based insights. XM Directory can allow you to control cross-channel contact frequency as well as to target specific segments of users.

Using Intercept Logic to Solicit App Reviews​

Method one (preferred)​

This method uses the built-in functionality offered by the Mobile App Prompt Creative. This works by sending users to the review section of their device's app store automatically. You can find setup instructions here.

Method two​

Because the App Feedback solution allows you to control when interactions with users occur, you can use it for more besides presenting surveys. One example is you can control, from the server, when requests to review the app appear. The following example shows how to request a review.

In the code example below, modify the current evaluateProject handler inside onCreate and replace PLAY_STORE_REVIEW_URL to the URL to your app in the Play Store:

MainActivity.java
Qualtrics.instance().evaluateProject(new IQualtricsProjectEvaluationCallback() {
@Override
public void run(Map<String, TargetingResult> targetingResults) {
for (Map.Entry<String,TargetingResult> result: targetingResults.entrySet())
// Displays if passed and if the InterceptID matches the desired app review's InterceptID
if (result.getValue().passed() && result.getInterceptID().equals("APP_REVIEW_INTERCEPT_ID")
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(PLAY_STORE_REVIEW_URL)));
break;
}
}
}
}

When an intercept passes evaluation, the user will be presented with a request to review the app.

View Targeting​

By keeping the intercept logic on the server rather than in the app, you can change when intercepts appear easily and without rebuilding and redistributing your app. For this to work properly, though, the app must have all of the activities/view controllers properly instrumented, even those you do not care about.

In this example, the activity sends its name to the server to be used in the logic for displaying a survey. First, when the activity is loaded, it sends its name to the server. All activities would have a similar method, which could be moved to a base class. All classes could then be subclassed from this class.

MainActivity.java
Qualtrics.instance().properties.setString("activity", Activity.class.getSimpleName());
Qualtrics.instance().registerViewVisit(Activity.class.getSimpleName());

The first line registers the activity's name (in this case the name is MainActivity), and the second line increments the unique views (if this is the first time an activity named MainActivity has been registered) and total views.

Then you would evaluate the intercept logic where it makes the most sense for your app: in onCreate or after the user tapped a button, for instance:

MainActivity.java
Qualtrics.instance().evaluateProject(new MyCallback());

On the server, you would add an action that is only true if the desired activity is loaded. First, add a new action to your intercept by clicking on Add Intercept Display Logic. You will then see the action chooser:

Screen Shot 2018-01-13 at 1.00.23 PM.png

Add the logic shown above. The custom property is activity and in the case of the sample, its value is MainActivity.

You could create new action sets (click on Add Another Action Set) for different activities (SettingsActivity, LoginActivity, for instance) and present different surveys for each. You can also use the View Count Total Views and Unique Views values for additional conditional processing. The Total Views value is incremented every time your app calls registerViewVisitWithViewName. The Unique Views value is incremented every time your app calls registerViewVisitWithViewName with a unique name.

Using Embedded Data​

By using the properties collection, you can push data back to the server, which can pass it on to your survey as embedded data. For more information about using embedded data with the App Feedback solution, see Setting up the Intercept. For more information about embedded data and surveys, see Embedded Data.

In the example below, the app will send the user's first name back to the server to be used as piped text in the survey. If the app requires the user to create an account, the user's first name should be readily available.

In your App Feedback project UI, open the intercept and choose the embedded data from the Options dropdown on the action set.

Screen Shot 2018-01-09 at 2.31.35 PM.png

Now choose Custom Property from Value and use type firstName in both the fields as shown below:

Screen Shot 2018-01-09 at 1.54.11 PM.png

Now open the specific survey project to edit the survey to include the firstName value in the survey. Start by choosing a question.

You will modify the question text so it includes an embedded data field. Choose Piped Text... and then choose Embedded Data Field and type firstName in the text field as shown below:

Embedded fill-resaved-01.png

The question should look like this after you added the embedded text:

Embedded filled in-2-resaved-01.png

In the MainActivity.java source file, add the following code to the onCreate method after the call to initializeProject.

MainActivity.java
Qualtrics.instance().properties.setString("firstName", "John");

When you run the app and display the survey, you should see the firstName filled in as shown below:

d28f45f-Screenshot_1514928166.png

Controlling the Survey Presentation​

Rather than calling the Qualtrics display method, you can design and build your own survey invitation prompt and then call the getSurveyUrl method to present the survey in a WebView (in the handler for your "Take survey" action).

You would modify the run method as shown below:

MainActivity.java
Qualtrics.instance().evaluateIntercept("InterceptID", new IQualtricsCallback() {
@Override
public void run(final TargetingResult targetingResult) {
// Use the targeting result to see if the targeting logic passed
// You may choose to add additional conditions here before allowing the survey to display
if (targetingResult.passed()) {
// Record an impression
// This sends data back to Qualtrics, indicating that a survey invitation has been displayed to the user
targetingResult.recordImpression();

// Create an AlertDialog with options to take the survey or dismiss in
// The AlertDialog can be replaced with any custom dialog
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("Give Feedback");
builder.setMessage("Would you like to take a brief survey?");
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
// Record a click
// This sends data back to Qualtrics, indicating that the user opted to take the survey
targetingResult.recordClick();

// Load the survey URL into a WebView on the activity
// This can be replaced with a browser intent or any custom WebView implementation
mWebView.loadUrl(targetingResult.getSurveyUrl());
dialogInterface.dismiss();
}
});

builder.setNegativeButton("No thanks", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});

// Build and show the dialog
AlertDialog alert = builder.create();
alert.show();
}
}
});

The new code first presents the user with an alert asking whether it is okay to show a survey. If the user chooses to show the survey, the web view shows the survey at the URL from the targeting result's getSurveyUrl(). We can also use the displayTarget() method to show the survey in Qualtrics webview, avoiding the need to make a custom webview.

Tip​

If you want to use Preventing Repeated Display with this function, you need to call targetingResult.setLastDisplayedTime(). Otherwise, the Prevent Repeated Display will not be respected.

MainActivity.java
Qualtrics.instance().evaluateIntercept("InterceptID", new IQualtricsCallback() {
@Override
public void run(final TargetingResult targetingResult) {
// Use the targeting result to see if the targeting logic passed
// You may choose to add additional conditions here before allowing the survey to display
if (targetingResult.passed()) {
// Record an impression
// This sends data back to Qualtrics, indicating that a survey invitation has been displayed to the user
targetingResult.recordImpression();

// Create an AlertDialog with options to take the survey or dismiss in
// The AlertDialog can be replaced with any custom dialog
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("Give Feedback");
builder.setMessage("Would you like to take a brief survey?");
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
// Record a click
// This sends data back to Qualtrics, indicating that the user opted to take the survey
targetingResult.recordClick();

// Load the survey URL into a Qualtrics WebView on the activity
// This can be replaced with a browser intent or any custom WebView implementation
Qualtrics.instance().displayTarget(this, targetingResult.getSurveyUrl(), true);
dialogInterface.dismiss();
}
});

builder.setNegativeButton("No thanks", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});

// Build and show the dialog
AlertDialog alert = builder.create();
alert.show();
}
}
});

Bypassing the Give Feedback Prompt​

Typically, you would want to bypass the give feedback prompt when your users tap on a Give Feedback menu item or button. If you were to use the display() method, they would be asked whether they want to give feedback after they had already chosen to give feedback.

To avoid that, you can use the following code example instead for calling the displayTarget() method like we did in the previous example.

MainActivity.java
Qualtrics.instance().evaluateIntercept("InterceptID" new IQualtricsCallback() {
@Override
public void run(TargetingResult targetingResult) {
if (targetingResult.passed()) {
// Record an impression
targetingResult.recordImpression();

// Record a click
targetingResult.recordClick();
// Calls the Qualtrics webview with the survey URL as the target URL
Qualtrics.instance().displayTarget(this, targetingResult.getSurveyUrl());
}
}
});

Using Local Notifications to show app feedback prompts​

You can create and edit the Local Notification message using the Website / App Feedback authoring portal. Once the Notification creative has been added to your intercept and published, there are a few lines of Qualtrics SDK code that need to be added to your app.

For Android, Notifications do not automatically take the app's Icon as the Icon in the Notification. For this reason we need the app developer to let the Qualtrics SDK know which Image to use as the Notification Icon. It is recommended that the image being used is placed in the drawable folder of your application. After Initializing your intercept and before calling Display, simply add the following code.

MainActivity.java
Qualtrics.instance().properties.setNotificationIconAsset(R.drawable.my_notification_icon);

When targeting Android 13 or newer, It is Application developer's responsibility to request notification permissions. Failure to do so will result in notifications not being displayed on devices running Android 13 or newer.

Using Intercept Action Sets Within Your App to Show Different Creatives​

Use Action Sets With the action sets capabilities, you can configure the same intercept to show multiple different creatives. This enables you to essentially have different intercepts (and surveys) display in different parts of your app.

In the example below, different creatives are shown depending on custom property values evaluated in the logic set condition.

FOR SDK.png

Note: With action sets, each time the intercept is evaluated, only ONE of the action sets will evaluate to true and only that particular creative+survey combination will be displayed. Additionally, with this approach all of the underlying creatives will inherit the same sampling and repeated display prevention settings.

Personalizing App Intercepts with Qualtrics XM Directory​

In order to personalize your app intercepts using the Qualtrics XM Directory, you will need to use the version of the InitializeProject API that accepts an optional External Reference ID parameter.

Qtip: This External Reference ID can be any ID (such as a customer number) that uniquely identifies each app user and that is associated with this user in the XM Directory.

initializeProject

Function Signature

MainActivity.java
public void initializeProject(String brandId, String zoneId, String extRefId, Context context, IQualtricsProjectInitializationCallback callback)

This method initializes the Qualtrics singleton using the specified brand ID, project ID (See Finding your Intercept IDs), optional external reference ID, and completion handler. You typically call this method in the app delegate's applicationDidBecomeActive method. This function will initialize all active intercepts in your project and make them available to evaluate and display.

The method's InitializationResult dictionary (returned in the completion handler) indicates the state of initialization for each intercept. See InitializationResult Class for more information.

Example usage

MainActivity.java
Qualtrics.instance().initializeProject(
"BRAND_ID", "PROJECT_ID", "EXT_REF_ID", MainActivity.this, (initializationResults) -> {
for (Map.Entry<String, InitializationResult> result: initializationResults.entrySet()) {
if (result.getValue().passed()) {
...
}
}
}
);