Using the In-App SDK

Updated 

The SDK for In-App Surveys allows brands to seamlessly integrate solicited feedback collection into their mobile apps during key customer interactions. Surveys can be triggered based on predefined conditions such as browsing behavior, session duration, or through custom events to capture targeted feedback. Once the SDK is set up, all survey creation and management can be handled directly within Sprinklr, with no further development required.

Please consult the article on Introduction to In-App Surveys for additional information regarding use cases and benefits.

Business Use Cases

  • Profile Authentication: Identifies the survey respondent as a known authenticated profile and links survey activity to the correct customer/user record.

  • User Context: Adds profile-level attributes that can be used for targeting, segmentation, and analytics across the user journey.

  • Survey Response Context: Adds response-level metadata for the current survey interaction, making each response more actionable in reporting.

  • Locale / Translations: Ensures you see surveys in the right language during initialization or after the app language changes.

This feature simplifies the integration of in‑app surveys, significantly reducing development time and effort while enabling real‑time user feedback collection to quickly identify issues and areas for improvement. With only a one‑time SDK setup required, all subsequent survey creation and management can be handled entirely within Sprinklr, eliminating the need for additional development and streamlining the overall workflow.

Installing the SDK

Before installing the SDK, ensure you have access to In-App Distribution in Customer Feedback Management (CFM) and collect the following details.

Prerequisites

  • This module is generally available as part of CFM In-App Surveys. To enable CFM, follow the setup instructions outlined in the CFM enablement documentation.

  • SDK support is currently available for Android, iOS, Flutter, and React Native.

Granular permissions are planned for additional areas, including Builder, Translations, Distribution, Responses & Analytics, and Settings.

Setting Up SDK Support for In-Apps

Use the SDK methods below to configure profile authentication, user context, survey response context, and locale handling. Please also go through the developer documentation for more details.

Profile Authentication

Profile authentication lets the SDK identify the respondent as a known user profile. Use it when the app already has an authenticated user and survey responses should be linked to that profile.

SPRSurveyUser type

import com.spr.surveykit.config.SPRSurveyUser;

SPRSurveyUser user = new SPRSurveyUser()

.setUserId("USER_ID")

.setFirstName("FIRST_NAME")

.setLastName("LAST_NAME")

.setEmail("EMAIL")

.setPhoneNumber("PHONE_NUMBER")

.setProfileImageUrl("PROFILE_IMAGE_URL")

.setHash(HASH)

.setHashCreationTime(HASH_CREATION_TIME);

Initialize with user

SPRSurveyProjectConfig config = new SPRSurveyProjectConfig()

.setAppId("APP_ID")

.setEnvironment("ENVIRONMENT")

.setDeviceId("DEVICE_ID")

.setUser(surveyUser);

SPRSurveyManager.shared.initializeProject(application, config);

updateUser

SPRSurveyManager.shared.updateUser(surveyUser);

logout

SPRSurveyManager.shared.logout();

SPRSurveyUser type

import SPRSurveyKit

let user = SPRSurveyUser()

user.userId = "USER_ID"

user.firstName = "FIRST_NAME"

user.lastName = "LAST_NAME"

user.email = "EMAIL"

user.phoneNo = "PHONE_NUMBER"

user.profileImageUrl = "PROFILE_IMAGE_URL"

user.hashString = hash

user.hashCreationTime = hashCreationTime

Initialize with user

let config = SPRSurveyProjectConfig()

config.appId = "APP_ID"

config.environment = "ENVIRONMENT"

config.deviceId = "DEVICE_ID"

config.user = surveyUser

SPRSurveyManager.shared.initializeProject(from: config)

updateUser

SPRSurveyManager.shared.updateUser(surveyUser)

logout

SPRSurveyManager.shared.logout()

SurveyUser type

import 'package:spr_survey_kit/spr_survey_kit.dart';

final user = SurveyUser(

userId: 'USER_ID',

hash: HASH,

hashCreationTime: HASH_CREATION_TIME,

firstName: 'FIRST_NAME',

lastName: 'LAST_NAME',

email: 'EMAIL',

phoneNumber: 'PHONE_NUMBER',

profileImageUrl: 'PROFILE_IMAGE_URL',

);

Initialize with user

await surveyKit.initializeProject(

appId: APP_ID,

environment: ENVIRONMENT,

deviceId: DEVICE_ID,

user: surveyUser,

);

updateUser

surveyKit.updateUser(surveyUser);

logout

surveyKit.logout();

SurveyUser type

import type { SurveyUser } from '@sprinklrjs/survey-kit';

const user: SurveyUser = {

userId: 'USER_ID',

hash: HASH,

hashCreationTime: HASH_CREATION_TIME,

firstName: 'FIRST_NAME',

lastName: 'LAST_NAME',

email: 'EMAIL',

phoneNumber: 'PHONE_NUMBER',

profileImageUrl: 'PROFILE_IMAGE_URL',

};

Initialize with user

await initializeProject({

appId: APP_ID,

environment: ENVIRONMENT,

deviceId: DEVICE_ID,

user: surveyUser,

});

updateUser

import { updateUser } from '@sprinklrjs/survey-kit';

updateUser(surveyUser);

logout

import { logout } from '@sprinklrjs/survey-kit';

logout();

User Context

User context adds profile-level custom fields for segmentation, targeting, and analytics. The context shape is a map from custom field ID to a list of values.

{ "_c_69a26fe929147f2bed8c7452": ["Maruti", "Hyundai"] }

updateSurveyResponseContext

Map<String, List<String>> patch = new HashMap<>();

patch.put("_c_69a26fe929147f2bed8c7452", Arrays.asList("Maruti", "Hyundai"));

SPRSurveyManager.shared.updateSurveyResponseContext(patch);

clearSurveyResponseContext

SPRSurveyManager.shared.clearSurveyResponseContext();

updateSurveyResponseContext

let patch: SurveyResponseContext = [

"_c_69a26fe929147f2bed8c7452": ["Maruti", "Hyundai"]

]

SPRSurveyManager.shared.updateSurveyResponseContext(patch)

clearSurveyResponseContext

SPRSurveyManager.shared.clearSurveyResponseContext()

updateSurveyResponseContext

final SurveyResponseContext patch = {

'_c_69a26fe929147f2bed8c7452': ['Maruti', 'Hyundai'],

};

surveyKit.updateSurveyResponseContext(patch);

clearSurveyResponseContext

surveyKit.clearSurveyResponseContext();

updateSurveyResponseContext

import {

updateSurveyResponseContext,

type SurveyResponseContext,

} from '@sprinklrjs/survey-kit';

const patch: SurveyResponseContext = {

_c_69a26fe929147f2bed8c7452: ['Maruti', 'Hyundai'],

};

updateSurveyResponseContext(patch);

clearSurveyResponseContext

import { clearSurveyResponseContext } from '@sprinklrjs/survey-kit';

clearSurveyResponseContext();

Locale / Translations

Locale support lets the SDK load the correct translated survey experience. Set locale during initialization or update it when the app language changes.

Initialize with locale

SPRSurveyProjectConfig config = new SPRSurveyProjectConfig()

.setAppId("APP_ID")

.setEnvironment("ENVIRONMENT")

.setDeviceId("DEVICE_ID")

.setLocale("en");

SPRSurveyManager.shared.initializeProject(application, config);

updateLocale

SPRSurveyManager.shared.updateLocale("en");

Initialize with locale

let config = SPRSurveyProjectConfig()

config.appId = "APP_ID"

config.environment = "ENVIRONMENT"

config.deviceId = "DEVICE_ID"

config.locale = "en"

SPRSurveyManager.shared.initializeProject(from: config)

updateLocale

SPRSurveyManager.shared.updateLocale("en")

Initialize with locale

await surveyKit.initializeProject(

appId: APP_ID,

environment: ENVIRONMENT,

deviceId: DEVICE_ID,

locale: 'en',

);

updateLocale

surveyKit.updateLocale('en');

Initialize with locale

await initializeProject({

appId: APP_ID,

environment: ENVIRONMENT,

deviceId: DEVICE_ID,

locale: 'en',

});

updateLocale

import { updateLocale } from '@sprinklrjs/survey-kit';

updateLocale('en');

Events reference

Event

Payload

UPDATE_USER_SUCCESS

{ "userId": "" }

UPDATE_USER_FAILED

{ "userId": "" }

UPDATE_USER_CONTEXT_SUCCESS

{ "userId": "" }

UPDATE_USER_CONTEXT_FAILED

{ "userId": "" }

LOGOUT_SUCCESS

{}

LOGOUT_FAILED

{ "error": "" }

UPDATE_LOCALE_SUCCESS

{ "locale": "" }

UPDATE_LOCALE_FAILED

{ "reason": "", "locale": "", "message": "" }

UPDATE_SURVEY_RESPONSE_CONTEXT_SUCCESS

{}

UPDATE_SURVEY_RESPONSE_CONTEXT_FAILED

{ "message": "" }

CLEAR_SURVEY_RESPONSE_CONTEXT_SUCCESS

{}

CLEAR_SURVEY_RESPONSE_CONTEXT_FAILED

{ "message": "" }

Developer portal pages to update

Platform

Developer portal page

Updates required

Android

Add user type, user context, locale, methods, and events.

iOS

Add user type, user context, locale, methods, and events.

Flutter

Add user type, user context, locale, methods, and events.

React Native

Add user type, user context, locale, methods, and events.

Testing the feature

  • Initialize the SDK on the supported platform using the relevant app ID, environment, and device ID.

  • Validate profile authentication by initializing or updating a known user and checking whether survey activity is linked to the intended profile.

  • Pass user context and survey response context, trigger a survey, and verify that the metadata is available for targeting, segmentation, and reporting.

  • Update the locale and verify that the translated survey experience loads for the selected language.

  • Refer to the developer documentation for platform-specific implementation details.

Steps to determine the App ID:

  1. Log in to the Sprinklr platform.

  2. From Sprinklr Insights, open the Customer Feedback Management (CFM) persona app.

  3. Open an existing Survey Project or create a new one.

  4. Open the survey and navigate to the Distributions tab.

  5. Locate the required In-App distribution, or create a new one as required.

  6. Click the three-dot menu next to the distribution.

  7. Select Copy Live Chat ID.

The copied value is your App ID.

 Environment:

The environment refers to the live production environment where your Sprinklr instance is hosted (for example:

Once you have collected the required information, navigate to the Sprinklr Developer Portal to review the SDK setup and installation details. Follow this link for more details.

 


FAQs

Android, iOS, Flutter, and React Native are covered in this SDK support document.

Yes. Use the relevant updateLocale method for the platform when the app language changes.

User context is profile-level information used for segmentation and targeting across the user journey. Survey response context is response-level metadata for the current survey interaction.