|
| 1 | +--- |
| 2 | +title: Analytics Swift Survicate Plugin |
| 3 | +strat: swift |
| 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-Swift](https://github.com/segmentio/analytics-swift){:target="_blank"}. |
| 9 | + |
| 10 | +## Adding the dependency |
| 11 | + |
| 12 | +When you add the Analytics Swift Survicate Plugin, the Survicate library is installed as an additional dependency. |
| 13 | + |
| 14 | +### Using Xcode |
| 15 | +In the Xcode `File` menu, click `Add Packages`. You'll see a dialog where you can search for Swift packages. In the search field, enter the URL to this repo: |
| 16 | + |
| 17 | +https://github.com/survicate/analytics-swift-survicate.git |
| 18 | + |
| 19 | +You'll then have the option to pin to a version or specific branch, and select which project in your workspace to add it to. Once you've made your selections, click the `Add Package` button. |
| 20 | + |
| 21 | +### Using Package.swift |
| 22 | + |
| 23 | +Open your Package.swift file and add the following to your the `dependencies` section: |
| 24 | + |
| 25 | +```swift |
| 26 | +.package( |
| 27 | +name: "SurvicateDestination", |
| 28 | +url: "https://github.com/survicate/analytics-swift-survicate.git", |
| 29 | +from: "3.0.2" |
| 30 | +), |
| 31 | +``` |
| 32 | + |
| 33 | +```swift |
| 34 | +import Segment |
| 35 | +import SurvicateDestination // <-- Add this line |
| 36 | +``` |
| 37 | + |
| 38 | + |
| 39 | +> info " " |
| 40 | +> When you add the Analytics Swift Survicate Plugin, the Survicate library is installed as an additional dependency. |
| 41 | +
|
| 42 | + |
| 43 | +## Using the Plugin in your App |
| 44 | + |
| 45 | +Open the file where you setup and configure the Analytics-Swift library. Add this plugin to the list of imports. |
| 46 | + |
| 47 | +Just under your Analytics-Swift library setup, call `analytics.add(plugin: ...)` to add an instance of the plugin to the Analytics timeline. |
| 48 | + |
| 49 | +Your events will now begin to flow to Survicate in device mode. |
| 50 | + |
| 51 | +### Using the SurvicateDestination plugin |
| 52 | + |
| 53 | +#### Identify |
| 54 | + |
| 55 | +In the SurvicateDestination plugin, the Identify event from Segment is transferred to the setUserTrait method of Survicate. This is achieved within the identify function of the SurvicateDestination class. The traits and userId from the Identify event are extracted and set as user traits in Survicate using the setUserTrait method. The traits are a dictionary where each key-value pair is set as a user trait. The userId is also set as a user trait with the key "userId". |
| 56 | + |
| 57 | +#### Track |
| 58 | + |
| 59 | +In the SurvicateDestination plugin, 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 user in Segment, it will be reset in Survicate. |
0 commit comments