logo

Segment Android

Overview

Segment is a Customer Data Platform (CDP) that collects and processes data from your users. With Segment, you can direct this data to other tools, including 1Flow, to gain insights into your product experience.
If your team already uses Segment, you can easily install the 1Flow SDK and send the necessary data for triggering surveys and targeting users.
This means any events and user identity data you’re tracking in Segment can be utilized by 1Flow – without extra development effort.

From Segment

First, go to your Segment account.
  1. From the Segment web app, click Catalog, then search for 1Flow Mobile Plugin.
  1. Click Add Destination.
  1. Select an existing Source to connect to 1Flow Mobile Plugin.
  1. Go to 1flow.ai -> Settings -> Project Settings, copy the 1Flow project API key, and paste it into the Destination Settings in Segment.
  1. Depending on the mobile source you’ve selected, include 1Flow’s library by adding the following lines to your dependency configuration.

Install 1Flow

Step 1: Install Segment1Flow Package

  • If gradle version is 6.5 or lower, include the below repository in your project’s build.gradle file:
kotlin
allprojects{ repositories{ google() jcenter() maven{url 'https://jitpack.io'} } }
• If gradle version is higher than 6.5, add the below code in settings.gradle.
kotlin
dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() maven{url 'https://jitpack.io'} } }
• Add dependency in your app’s build.gradle file:
kotlin
compileSdkVersion 34 .... defaultConfig { .... minSdkVersion 21 } dependencies { .... implementation 'com.segment.analytics.android:analytics:4.11.3' implementation "com.github.1Flow-Inc:segment-1flow-android:2023.09.26" }

Step 2: Initialize Segment and add 1Flow destination

kotlin
Analytics analytics = new Analytics.Builder(context, "YOUR_WRITE_KEY_HERE") .use(OneFlowIntegration.FACTORY) ... .build(); ... Analytics.setSingletonInstance(analytics);

Supported methods

Identify

If you’re not familiar with the Segment Specs, take a look to understand what the Identify method does. An example call would look like:
swift
analytics.identify(userId: "peter@example.com", traits: [ "name": "Peter Gibbons", "email": "peter@example.com", "mobile": 1234567890 ])
When you call identify method of segment, it will be equivalent to logUser of 1Flow. userId will be userID and traits will be userDetails.

Track

If you’re not familiar with the Segment Specs, take a look to understand what the Track method does. An example call would look like:
swift
analytics.track(name: "ButtonClicked")
Any value passed in name, will be eventName and if you have passed any event property, then it will be event parameters.

Screen

Send Screen calls to record which mobile app screens users have viewed. For example:
swift
analytics.screen(title: "Home")
Segment sends Screen calls to 1Flow as a screen_[name] event (or screen_view if a screen name isn’t provided).

Settings

Segment lets you change these destination settings from the Segment app without having to touch any code.
SETTING
DESCRIPTION
API Key(required)
string.