Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Analytics Kotlin Survicate Plugin


Survicate(link takes you to an external page) is an all-in-one customer feedback platform that helps you collect and act on feedback from your customers. With Survicate, you can better understand your customers and improve their experience with your product or service.

Add Survicate device-mode support to your applications using the plugin for Analytics-Kotlin(link takes you to an external page).


Getting started

getting-started page anchor

To get started, you need to provide a Survicate workspace key.

You can do this in two ways:

  1. Add the key in the Segment panel. Navigate to Connections > Destinations and locate your Android app destination. Click Settings, then enter the key inside the Connection Settings as a "Workspace Key".

  2. Alternatively, you can add your Survicate workspace key as metadata inside AndroidManifest:

    1
    <application
    2
    android:name=".MyApp"
    3
    >
    4
    <!-- ... -->
    5
    <meta-data android:name="com.survicate.surveys.workspaceKey" android:value="YOUR_WORKSPACE_KEY"/>
    6
    </application>

To define the Maven repository:

1
allprojects {
2
repositories {
3
// ...
4
maven { url 'https://repo.survicate.com' }
5
}
6
}

Add the dependency to your app's build.gradle file:

1
dependencies {
2
// ...
3
implementation 'com.survicate:survicate-segment-analytics-kotlin:<latest_version>'
4
}

You can find the current version in the plugin repository(link takes you to an external page).


Using the plugin in your app

using-the-plugin-in-your-app page anchor

To activate the Survicate plugin, you have to add a SurvicateDestination to the Analytics instance.

1
analytics = Analytics(segmentKey, applicationContext) {
2
// ...
3
}
4
analytics.add(SurvicateDestination(applicationContext))

Only keep one instance of the Analytics. For example, initialize it inside the application's onCreate method. This is important because the Survicate SDK can only be initialized once.

Now, you can use the Analytics, having the events mapped to the Survicate SDK.

Identify

identify page anchor

In the SurvicateDestination plugin, the Identify method from Segment is transferred to the setUserTraits method of Survicate. You can provide multiple key-value pairs. The userId argument of Analytics.identify is also set as a user trait with the key "user_id".

The Track method from Segment is used as the invokeEvent method in Survicate. This means that when you track an event in Segment, it will be invoked in Survicate.

Similarly, the Screen method from Segment is used as the enterScreen method in Survicate. This means that when you track a screen in Segment, it will be entered in Survicate.

The Reset method from Segment is used as the reset method in Survicate. This means that when you reset the Segment client, the Survicate client is also reset.