Analytics Kotlin Destination Plugins


Analytics Kotlin uses its timeline/plugin architecture to support sending data to bundled SDKs when a Cloud Mode connection is not possible. Destination Plugins are similar to traditional Device Mode integrations available in Analytics Android in that Segment makes calls directly to the destination tool’s API from the device. However, Destination Plugins are more customizable, giving you the ability to control and enrich your data at a much more granular level on the device itself.

Choosing the right destination

Segment built device mode destination plugins to be used with the classic/legacy destinations, not Actions destinations. The exception to this is the Amplitude plugin. The Amplitude plugin is a session plugin meant to be used with Amplitude Actions. If a classic/legacy destinations is in maintenance mode, Segment continues to make updates pertaining to the mobile plugins, but not the server or web components. If you run into any issues setting up your destination, reach out to support.

Device-mode Vs. Cloud-Mode

Analytics Kotlin allows you to choose how you send data to Segment and your connected destinations from your app. There are two ways to send data:

Cloud-mode: The sources send data directly to the Segment servers, which then translate it for each connected downstream destination, and send it on. Translation is done on the Segment servers, keeping your page size, method count, and load time small.

Device-mode: You include additional code on your app which allows Segment to use the data you collect on the device to make calls directly to the destination tool’s API, without sending it to the Segment servers first. (You still send your data to the Segment servers, but this occurs asynchronously.) This is also called wrapping or bundling, and it might be required when the source has to be loaded on the page to work, or loaded directly on the device to function correctly.

Supported Device-mode Plugins

Analytics Kotlin supports the following Device-mode Plugins:

Build your own destination

If Segment doesn’t support your Kotlin destination, you can build your own with the template Segment provides.

To build your own Kotlin destination using a plugin template:

  1. Go to the Kotlin Destination Plugin Template.
  2. Click Use this template.
  3. Enter a name for the repository.
  4. Click Create repository from template.
  5. Go to lib > src > main > java/dmn/your/pkg/destination in your repository.
  6. Click the MyDestination.kt.
  7. Complete the TODO sections in the sample code with the appropriate information for your destination. Segment recommends you to change the package name before you finalize your build.
  8. Commit your changes.

You can unit test your destination to make sure it works. Segment recommends you to use the testing template as a starter and to build upon it to get test coverage of most scenarios.

To test your destination:

  1. Go to lib > src > test > java/dmn/your/pkg/destination.
  2. Click MyDestinationTests.kt.
  3. Complete the TODO sections in the sample code with the appropriate information for your destination.
  4. Commit your changes.

Segment recommends that you test your destination implementation end-to-end. Send some sample analytics events and ensure that they reach the destination.

For more information about the Analytics Kotlin Plugin architecture and how it can help you customize your tracking implementation to suit your needs, refer to the Plugin Architecture guide.

This page was last modified: 27 Feb 2024



Get started with Segment

Segment is the easiest way to integrate your websites & mobile apps data to over 300 analytics and growth tools.
or
Create free account