Mobile - Android

Installation, Implementation, and Updates.


UserLeap is now Sprig

We might have changed our name, but you don't have to change a thing!
All of your studies, integrations, and code will continue to function properly with no action required.


Official Android SDK for Sprig/UserLeap (Releases)

This SDK is designed to work with Android SDK 21 (Android Lollipop, OS 5.0) and above.

If using minSdk below 21, you can override the library in your main AndroidManifest.

<manifest xmlns:android=""

    <uses-sdk tools:overrideLibrary="com.userleap" />

Make sure to check the OS system version before calling Sprig.

    Sprig.configure(context, "ENVIRONMENT_ID")


You can install the Sprig SDK via maven central.

dependencies {
    implementation 'com.userleap:userleap-android-sdk:2.5.3'

Add Java 8 support to your project (if not added already)

android {
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  // For Kotlin projects
  kotlinOptions {
    jvmTarget = "1.8"

If you experience build issues like "Failed to find the generated class", please try adding this to your proguard rules

-keep class com.userleap.** { *; }

Software Dependencies

Maintain the same dependency versions in your app as follows:

  • Kotlin (1.5.31)
  • Gradle (4.0.0)
  • Android X
  • Java 8
  • Material Components (1.5.0-alpha04)- bottom sheet dialog for surveys
    /ConstraintLayout) (1.1.3) - flat view hierarchies for surveys
  • Coroutines (1.3.7) - asynchronous support
    Do not use newer versions. If versions do not match unexpected behavior may occur.


These permissions are automatically merged into your app Manifest.

  • INTERNET - send and receive events and studies

App size impact

The Sprig SDK AAR size is 211 KB.

The impact to an Android App Bundle is around 650 KB. Note: The Sprig SDK uses the common dependencies listed above. The actual size impact will be smaller if these dependencies are already used by the app.

Methodology: Build a ProGuarded release Android App Bundle in Android Studio with an Empty Activity project. Then compare size after adding the Sprig SDK.


Initializing the SDK

In order to use the SDK, you need to configure the SDK for your app. Do this before calling any other Sprig functions. A convenient place to configure Sprig is in your class that extends Application.

Sprig.configure(context, "ENVIRONMENT_ID")

The ENVIRONMENT_ID for your deployment can be found in the Connect page of the Sprig Dashboard.

This study always displays a debug study and the results are submitted to Sprig.

Identifying users

User ID

Sprig allows you to identify users by supplying a userId. While tracking userIds is optional, it helps to provide a consistent experience across platforms and prevents users from seeing the same study multiple times.

The user identifier should be unique and mappable to your internal user id in some way.

Set the userId after configuring if they are already logged in or after the user logs in to your app:


This user identifier is stored locally and this method can be called multiple times safely. We recommend you set the user identifier every time you configure Sprig and anytime your customer's login to be safe.

️ Warning

Sprig enforces recontact windows and study eligibility based on the user ID associated with the current user, and tracks this user ID across multiple sessions and devices. If no user ID is provided, Sprig will only enforce recontact windows against the current anonymous visitor ID.

Email address

You can also provide Sprig with the user's email address. It is not required for Web and Mobile studies but is required to enable Email-based studies.


Segmenting your users with attributes

Sprig allows you to associate attributes to each user. These attributes are surfaced as survey filter options in the Sprig dashboard, and allow you to send studies to users with certain attributes.

Sprig.setVisitorAttribute("KEY", "VALUE")

Sprig automatically tracks and attaches the following attributes:

  • App version
  • Android version
  • SDK version

Some common attributes you can set are:

  • Location
  • Referral channel
  • A/B test group
  • Network connectivity status
  • Battery level

Tracking user events

Sprig can track events inside your mobile app by calling the track() function and passing the event name as an argument.

️ Info

Your engineering team will want to place track() code after any action or context, denoting to Sprig that the event has occurred. If your colleague used the UI to add a Code event, you will need to name the event identically. The snippet is also available from the clipboard to make for fast easy copy in the UI on the Events page for that event.


These events can be used as part of your filters for triggering a survey, but will not display a survey to your users.

Displaying studies to users

Instead of strictly tracking when user events occur, we can send events to Sprig and also display a survey, should the user qualify for one. We can do this by modifying the prior track() call, and adding in a when statement as follows:

Sprig.track("EVENT_NAME") { surveyState ->
    when (surveyState) {
        SurveyState.READY -> {
            // We received a survey for the event, present it to the user
        SurveyState.NO_SURVEY -> {
            // No survey available based on event
        SurveyState.DISABLED -> {
            // Sprig has been disabled remotely

After sending each tracking event, you can check if a new survey is ready for the user. If a survey is ready, you can decide to present the survey to the user. The survey is presented on a modal bottom sheet.

Example StudyExample Study

Example Study

Verifying your Event-based Studies

There are checks in place to make sure we show studies at the right time, see Recontact Waiting Period. To test that your studies show with the right attributes and events set, be sure to set up the SDK with your development ENVIRONMENT_ID. This will bypass throttling and the recontact window.



While studies can be configured to trigger and display from multiple events, only one of those events needs to occur to display a study (assuming a user also meets your survey's filter criteria).

User logout

When a user logs out of your app, make sure to log that user out of the Sprig SDK. This will prevent any new activity from being associated with the wrong user.



We adhere to Semver for versioning our SDKs so upgrading between major versions (e.g. 1.0.1-> 1.1.0) should not present any breaking changes.

Note: 1.2.1 is the same as 2.0.0, we've bumped the major version to signify that versions below 1.2.1 will be disabled/deprecated by Feb 12, 2021

Upgrading from 1.x.x to 2.x.x

  • Sprig.visitorIdentifier which returns Int? will always return null for new visitors. Use the new Sprig.visitorIdentifierString which returns String?

The latest Sprig SDK release is shown here.