Clevertap Integration in React Native
CleverTap is a platform for customer retention that offers app integration features and also provides analytics and marketing. The main purpose of Clevertap is to track the events and also understand the number of users launching the app and also how many users are active in a day.
Clevertap also helps to:
- Track events and add the properties to the events.
- Allows to add Segments and send the campaigns to these segments.
Before starting with the installation we need to create a project in our Clevertap dashboard and and the account id and token in the project.
Installation of Clevertap
Clevertap installation can be done using npm:
npm install --save clevertap-react-native
Once installation is done we need to link the library for the projects using React native version 0.60 or less.
Linking
Auto Linking:
Run the following command to link the Clevertap automatically.
react-native link clevertap-react-native
Android Manual Linking:
Add the following code in android/settings.gradle file
include ':clevertap-react-native'project(':clevertap-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/clevertap-react-native/android')
Add the following in the android/app/build.gradle file
implementation project(':clevertap-react-native')
Add the following imports and the code in Main Application.java file
import com.clevertap.android.sdk.ActivityLifecycleCallback;import com.clevertap.react.CleverTapPackage;new CleverTapPackage()
Add the following in the Android Manifest.xml where we will get account id and token from the Clevertap dashboard.
<meta-data android:name="CLEVERTAP_ACCOUNT_ID" android:value="TEST-123"/><meta-data android:name="CLEVERTAP_TOKEN" android:value="TEST-00"/>
Read more here: https://tudip.com/blog-post/clevertap-integration-in-react-native/