|
| 1 | +--- |
| 2 | +title: Analytics Kotlin Survicate Plugin |
| 3 | +strat: kotlin-android |
| 4 | +--- |
| 5 | + |
| 6 | +[Survicate](https://survicate.com/){:target="_blank"} is an all-in-one customer feedback platform that helps you collect and act on feedback from your customers. It helps you understand your customers and improve their experience with your product or service. |
| 7 | + |
| 8 | +Add Survicate device mode support to your applications using this plugin for [Analytics-Kotlin](https://github.com/segmentio/analytics-kotlin){:target="_blank"}. |
| 9 | + |
| 10 | +## Getting started |
| 11 | + |
| 12 | +First you need to provide a Survicate workspace key. |
| 13 | + |
| 14 | +You can do this in 2 ways: |
| 15 | + |
| 16 | +1. Add the key in the Segment panel -> Destinations -> Your Android app destination -> Settings. You need to put the key inside the Connection Settings as a "Workspace Key". |
| 17 | + |
| 18 | +2. Alternatively, you can add your Survicate workspace key as a metadata inside AndroidManifest |
| 19 | + |
| 20 | + ```xml |
| 21 | + <application |
| 22 | + android:name=".MyApp" |
| 23 | + > |
| 24 | + <!-- ... --> |
| 25 | + <meta-data android:name="com.survicate.surveys.workspaceKey" android:value="YOUR_WORKSPACE_KEY"/> |
| 26 | + </application> |
| 27 | + ``` |
| 28 | +## Adding the dependency |
| 29 | +Add Survicate maven: |
| 30 | +``` |
| 31 | +allprojects { |
| 32 | + repositories { |
| 33 | + // ... |
| 34 | + maven { url 'https://repo.survicate.com' } |
| 35 | + } |
| 36 | +} |
| 37 | +``` |
| 38 | + |
| 39 | +## Using the Plugin in your App |
| 40 | +In order to activate the Survicate plugin, you have to add a `SurvicateDestination` to the Analytics instance. |
| 41 | + |
| 42 | +```kotlin |
| 43 | +analytics = Analytics(segmentKey, applicationContext) { |
| 44 | + // ... |
| 45 | +} |
| 46 | +analytics.add(SurvicateDestination(applicationContext)) |
| 47 | +``` |
| 48 | + |
| 49 | +Make sure to keep only one instance of the `Analytics` (e.g. initialize it inside Application's onCreate method). This is important, because the Survicate SDK underneath can only be initialized once. |
| 50 | + |
| 51 | +Now you can use the Analytics as usual, having the events mapped to Survicate SDK as described below. |
| 52 | + |
| 53 | +_**Identify**_ |
| 54 | + |
| 55 | +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". |
| 56 | + |
| 57 | +_**Track**_ |
| 58 | + |
| 59 | +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. |
| 60 | + |
| 61 | +_**Screen**_ |
| 62 | + |
| 63 | +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. |
| 64 | + |
| 65 | +_**Reset**_ |
| 66 | + |
| 67 | +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 will also be reset. |
0 commit comments