Skip to content

CleverTap/clevertap-segment-integration-docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 

Repository files navigation

Getting Started

Once the Segment library is integrated, toggle CleverTap on in your Segment integrations, and add your CleverTap Account ID and CleverTap Account Token which you can find in the CleverTap Dashboard under Settings.

You can integrate CleverTap via a server-side or mobile destination (iOS or Andriod). If you are interested in using CleverTap’s push notifications or in-app notifications products, you should use the mobile destinations.

All server-side destination requests require either a Segment Anonymous ID or a userId in the payload.

CleverTap supports the identify, track, page (server-side only), and screen (iOS and server-side only) methods.

Identify

When you identify a user, we'll pass that user's information to CleverTap with userId as CleverTap's Identity value. A number of Segment's special traits map to CleverTap's standard user profile fields. You’ll pass the key on the left into Segment and we will transform it to the key on the right before sending to CleverTap.

  • name maps to Name
  • birthday maps to DOB
  • avatar maps to Photo
  • gender maps to Gender
  • phone maps to Phone
  • email maps to Email

All other traits will be sent to CleverTap as custom attributes.

Track

When you track an event, we will send that event to CleverTap as a custom event. Note that CleverTap does not support arrays or nested objects for custom track event properties.

Order Completed

When you track an event via the server-side destination with the name Order Completed using the e-commerce tracking API, we will map that event to CleverTap's Charged event.

Page

When you send a page event via the server-side destination, we will send that event to CleverTap as a Web Page Viewed event.

Screen

When you send a screen event via the server-side destination or the iOS bundled SDK, we will send that event to CleverTap as an App Screen Viewed event.

Android

Integrating

  1. Add the CleverTap Segment Integration dependency to your app build.gradle:

    compile 'com.clevertap.android:clevertap-segment-android:+'

    Note: Our group Id is com.clevertap.android, not com.segment.analytics.android.integrations.

  2. Next, declare CleverTap's integration in your Analytics instance:

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

Integrating Push

  1. In your AndroidManifest.xml, register the following CleverTap services.

    <service
        android:name="com.clevertap.android.sdk.FcmTokenListenerService">
        <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
        </intent-filter>
    </service>
    
    <service
        android:name="com.clevertap.android.sdk.FcmMessageListenerService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT"/>
        </intent-filter>
    </service>
    
  2. For more in-depth information, visit our Android push integration documentation.

In-App Notifications

  1. In your AndroidManifest.xml, add the CleverTap InAppNotificationActivity.

    <activity  
            android:name="com.clevertap.android.sdk.InAppNotificationActivity"  
            android:configChanges="orientation|keyboardHidden"  
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />  
    

    No further action is required to integrate in-app notifications, which are registered for and requested by default by our CleverTap Segment integration.

Sample App

CleverTap has created a sample Android application that integrates CleverTap via Segment. Check it out at the Github repo.

iOS

Integrating

  1. Add the CleverTap Segment Pod to your Podfile:

    pod 'Segment-CleverTap'

    We recommend using the latest version on CocoaPods since it will contain the most up to date features and bug fixes.

  2. Next, declare CleverTap's integration in your app delegate instance:

    SEGAnalyticsConfiguration *config = [SEGAnalyticsConfiguration configurationWithWriteKey:@"YOUR_WRITE_KEY_HERE"];
    [config use:[SEGCleverTapIntegrationFactory instance]];
    [SEGAnalytics setupWithConfiguration:config];
    

Integrating Push

  1. Follow the directions to register for push at: https://segment.com/docs/libraries/ios/#how-do-i-use-push-notifications-.

  2. In your application's application:didReceiveRemoteNotification: method, add the following:

    [[SEGAnalytics sharedAnalytics] receivedRemoteNotification:userInfo];

  3. If you integrated the application:didReceiveRemoteNotification:fetchCompletionHandler: in your app, add the following to that method:

    [[SEGAnalytics sharedAnalytics] receivedRemoteNotification:userInfo];

  4. If you implemented handleActionWithIdentifier:forRemoteNotification:, add the following to that method:

    [[SEGAnalytics sharedAnalytics] handleActionWithIdentifier:identifier forRemoteNotification:userInfo];

In-App Notifications

No further action is required to integrate in-app notifications, which are registered for and requested by default by our CleverTap Segment integration.

Sample App

CleverTap has created a sample iOS application that integrates CleverTap via Segment. Check it out at the Github repo.

Server-Side Push Tokens

If you chose not to bundle the CleverTap Mobile SDK, then you will have to implement your own Push Message processors (and you won’t have access to CleverTap’s In-App feature).

If you decide to implement your own Push Message processors, then you can pass push tokens to CleverTap via the server-side destination. You can do this by sending it inside context.device.token.

Settings

CleverTapAccountID

The Account ID found in your CleverTap dashboard, used to identify your application.

CleverTapAccountToken

Mobile Only: The Account Token found in your CleverTap dashboard, used to identify your application.

About

CleverTap Segment integration docs

Resources

Stars

Watchers

Forks