CleverTap Destination
CleverTap quick info
CleverTap accepts Track, Page, Identify, and Alias calls. If you reference it in the Integrations object, call it “CleverTap”.
CleverTap accepts cloud-mode data from all Segment source types. It can accept device-mode data from both web and mobile sources.
Getting Started
Once the Segment library is integrated, toggle CleverTap on in your Segment destinations, and add your CleverTap Account ID and CleverTap Account Token which you can find in the CleverTap Dashboard under Settings.
You can integrate CleverTap using 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 toName
birthday
maps toDOB
avatar
maps toPhoto
gender
maps toGender
phone
maps toPhone
email
maps toEmail
All other traits will be sent to CleverTap as custom attributes. Please also note that the default logic will lower case and snake_case any user traits - custom or special - passed to CleverTap.
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.
Please also note that the default logic for our cloud mode connection to CleverTap will lower case and snake_case any event properties passed from Segment’s servers to CleverTap. Our device mode connection will not lower case or snake_case any event properties passed directly to CleverTap from the client.
Order Completed
When you track
an event using 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 using the server-side destination, we will send that event to CleverTap as a Web Page Viewed event.
Screen
When you send a screen
event using the server-side destination or the iOS bundled SDK, we will send that event to CleverTap as an App Screen Viewed event.
Android
Integrating
-
Add the CleverTap Segment Destination dependency to your app build.gradle:
compile 'com.clevertap.android:clevertap-segment-android:+'
Note: Our group Id is
com.clevertap.android
, notcom.segment.analytics.android.integrations
. -
Next, declare CleverTap’s destination in your Analytics instance:
Analytics analytics = new Analytics.Builder(context, "YOUR_WRITE_KEY_HERE") .use(CleverTapIntegration.FACTORY) ... .build();
Integrating Push
-
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>
-
For more in-depth information, visit our Android push integration documentation.
In-App Notifications
-
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 using Segment. Check it out at the GitHub repo.
iOS
Integrating
-
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.
-
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
-
Follow the directions to register for push at: https://segment.com/docs/connections/sources/catalog/libraries/mobile/ios/#how-do-i-use-push-notifications.
-
In your application’s application:didReceiveRemoteNotification: method, add the following:
[[SEGAnalytics sharedAnalytics] receivedRemoteNotification:userInfo];
-
If you integrated the application:didReceiveRemoteNotification:fetchCompletionHandler: in your app, add the following to that method:
[[SEGAnalytics sharedAnalytics] receivedRemoteNotification:userInfo];
-
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 using Segment. Check it out at the GitHub repo.
React Native
To add the CleverTap device-mode SDK to a React Native project:
- Navigate to the root folder of your project, and run a
yarn add clevertap
command to add the destination SDK to your project. - Add an
import
statement to your project, as in the example below.import CleverTap from '@segment/analytics-react-native-clevertap'
- In the same project file, add the destination to the
using
list in theawait
command.await analytics.setup('YOUR_WRITE_KEY', { // Add any of your Device-mode destinations. This ensures they load before continuing. using: CleverTap // ... })
- Finally, change to your iOS development folder (
cd ios
) and runpod install
.
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 using the server-side destination. You can do this by sending it inside context.device.token.
Personas
You can send computed traits and audiences generated using Segment Personas to this destination as a user property. To learn more about Personas, contact us for a demo.
For user-property destinations, an identify call is sent to the destination for each user being added and removed. The property name is the snake_cased version of the audience name, with a true/false value to indicate membership. For example, when a user first completes an order in the last 30 days, Personas sends an Identify call with the property order_completed_last_30days: true
. When the user no longer satisfies this condition (for example, it’s been more than 30 days since their last order), Personas sets that value to false
.
When you first create an audience, Personas sends an Identify call for every user in that audience. Later audience syncs only send updates for users whose membership has changed since the last sync.
Supported Sources and Connection Modes
Before you start, make sure CleverTap supports the source type and connection mode you’ve chosen to implement. You can learn more about connection modes here.
Web | Mobile | Server | |
---|---|---|---|
📱 Device-mode | ✅ | ✅ | ⬜️ |
☁️ Cloud-mode | ✅ | ✅ | ✅ |
Segment offers an optional Device-based Connection Mode for Mobile data going to CleverTap, so that you can use CleverTap features that collect data directly from the mobile device. To do this, you must package the Segment-CleverTap mobile SDK with the Segment mobile library.
Settings
Segment lets you change these destination settings from the Segment app without having to touch any code.
Account ID
Add your CleverTap Account ID which you can find in the CleverTap Dashboard under Settings.
Account Token
Mobile Only:Add your CleverTap Account Token which you can find in the CleverTap Dashboard under Settings.
Region
Server Only: Your dedicated Clevertap region.
This page was last modified: 23 Mar 2021
Need support?
Questions? Problems? Need more info? Contact us, and we can help!