React Native
Prerequisites
Please have the following handy before beginning the integration:
Application identifier generated on the Apxor dashboard for your app (Read more on how to fetch the application identifier from Apxor dashboard)
App Bundle Id : Every app has a unique application ID that looks like
com.example.myapp
. This id uniquely identifies the app on the device and also on the app store. (Know more about bundle ids here)The list of events to setup triggers and track goals, user properties that allows to personalize messages and to target better. (Read more on how you can setup here)
React Native Integration
Check here the latest release notes.
Android Integration
Step 1: Add Apxor Repository
Add Maven URL in root/project level build.gradle
Path: <project>/build.graddle
:
Step 2: Add dependencies
Add the following into the build.gradle file in app-level
Path: <project>/<app-module>/build.gradle
:
2.1 ApxorSDK dependencies (mandatory)
2.2 Add exoplayer in your app (optional)
2.3 Enable uninstall tracking for your users (optional)
After completing the expandable section, integrate Apxor Push with @react-native-firebase
Add the following block wherever you have AppRegistry.registerComponent(appName, () => App);
. Ideally, it's located in your src/index.js
or src/index.tsx
.
Step 3: Add the following in proguard-rules.pro
Note
If you use proguard to obfuscate the classes, you have to add the following to ignore obfuscation for Apxor SDK classes
Configure the below rules in your proguard-rules.pro
file
Path: <project>/<app-module>/gradle.properties
:
Note:
If you use androidx
libraries, add the following property in gradle.properties
file
Step 4: Disable Dexing Artifact Transformation
Note
In Android Gradle Plugin 3.5.0, we use Gradle artefact transforms for desugaring and dexing, enabling greater parallelism and caching. This process depends on libraries having accurate Maven information since dependencies specified in POM files are used to set up the desugaring classpath. If we encounter issues with missing dependencies during desugaring, it's necessary to disable parallel transformation to facilitate the process by adding the following property:
Add the following to gradle.properties
file
Path: <project>/<app-module>/gradle.properties
:
Step 5: Initialize Apxor Android SDK
Add following
meta-data
tag inside yourapplication
tag in yourAndroidManifest.xml
file
Click here to Add New App and how to get the app id
You are all set: Verify your SDK integration
We have to verify for two things as follows :
SDK Initialization
On running your android project lookout for the following log in logcat :
Plugin Initialization
By default, only error logs are enabled. To see debug logs for plugin initialization and to confirm tracking event triggers, user properties. Please run the below command in terminal
Note
Apxor uploads data only when the app is minimized to the background. If you are running from Android Studio (emulators or devices), do not stop the app, just press on the "home" button in order for data to be uploaded.
iOS Integration
Step 1: Initialize Apxor iOS SDK
Note
If you are unable to find our plugins in your pods, then do
pod update
Note
To get your app ID, please email us at contact@apxor.com or contact your assigned CSM
Configuring Test Device
First, you need to configure your app to ensure there is a URL Scheme with your application's bundle identifier as the value.
If your app already has a URL Scheme with your application's bundle identifier as the value, you can skip this step.
Configure URL Scheme
To configure URL scheme, go to your project settings, select
Targets
. Click on theInfo
tab.Select the
URL Types
, and click on the+
button to add a new URL Scheme.Add a new URL Scheme with your
bundle identifier
as the value.Your bundle identifier will be in the format,
com.xxxx.xxxx
Use the image below for reference.
Note
Make sure the URL scheme has the value of your bundle identifier that was provided in the dashboard while registering with us. Also, the app must have same bundle identifier.
Handling the deep link
You are all set: Verify your SDK Integration
Lookout for the following log
Add-Ons
Now that you have completed the basic integration, you can proceed to set up event triggers, capture data for targeting, add slots for embed cards and stories, and personalize messaging. Include the following sections as needed.
Note
Add the following import statement in every component where you use Apxor APIs
Identifying Users
This section is mandatory if you intend to use Segments and Cohorts.
The Apxor SDK automatically captures device IDs and this is used to identify users uniquely by Apxor. Apart from this, you can log a custom user identifier that you use to uniquely identify users in your app.
This identifier would be very instrumental especially when exporting data of a certain campaign or survey to your analytics system to create a cohort and measure the results of the campaign.
Similarly, when you are importing data to Apxor from your system that your marketing/product / data science team has identified and wants to run campaigns specifically to them the custom user identifier
will serve as the bridge to communicate between your systems and Apxor effectively.
Here is how you can set your user identifier for Apxor to recognize your users :
Log events and user data for Targeting, Triggering and goal Tracking
The product/marketing or the growth team lists out the use cases with an idea of when to launch and to whom to launch. To do this we need to capture data in the form of events. Let us consider the following use case as an example :
App Events
In the above scenario, we want to trigger the campaign for users who have spent 'x' seconds and haven't tapped on a product. To understand that if the user has tapped the product we should log an event along with its attributes as follows to capture data:
Similarly if you want to send promotions to users who have viewed at least five products of the category shoes in the last three days or you want to measure how many people added an item to a cart from the campaign as a goal all this information is captured in the form of events.
These types of events are classified as app events
- the data that is transferred to the servers at Apxor where you can segment users based on historic behaviour or measure your goals as specified above.
Here is how we track app events :
Client Events
In the below scenario, let's assume you want to launch a survey when the soft back button is pressed asking the user for product feedback. In this, we don't need to capture the data of how many people pressed the back button which is useless and it bloats your event storage as it is a high-frequency event which increases your cost unnecessarily. This data point doesn't potentially answer any of your product questions and hence there is no ROI in storing data from this event.
So for such scenarios where we need the behavioral data to launch a campaign or to collect feedback, which doesn't provide ROI on storing for measuring goals, answering your product questions or segmenting your target audience, we log these events as Client Events
which involves zero transfer of data and is used only to set up your triggers on behavioral information from the user.
User Attributes
We can personalize the messaging copy in the experiences we build for the user or target based on his persona using information that is centric to individual users. Let us consider the following example where we know the user is an English
with Gold
membership.
This information helps to tailor content in English to that specific user and gives us the flexibility to different messaging to different membership tiers. This is how the information captured here is used for segmenting.
Similarly capturing attributes like Name
can help to personalize your message copy where it reads Hi {username} can't find your product? where the username is replaced by the attribute value of the property from the nudges dashboard along with providing meaningful defaults in their absence.
This is how you log user information to Apxor :
Track Screen
In the scenario discussed in this guide, how will we know if the user has spent thirty seconds on the home screen and did not click on the product? For this reason, it is important to use track the screens to set them up as triggers and also to capture the time spent on the screens.
By using the following API to track the screens in the app you can setup campaigns on inactivity or time spent on those screens:
Track Navigation
If you are already using a navigation library like @react-navigation
, please follow below mentioned steps for Apxor SDK to automatically track screen navigation
Note
You will need it on both
onReady
andonStateChange
as the SDK needs to log navigation events on the initial app launch and also on futher navigations between screens.The
NavigationContainer
need not be straight from@react-navigation
. It can be from any 3rd party wrapper aroundNavigationContainer
(like BugSnag)
Otherwise use the following API to track navigations on every screen/route change
Configuring View IDs for Views
Note:
This step is necessary to identify the app screens' UI elements/ views. Configuring View IDs will help anchor the Tooltips, Coachmarks, and Badges to the specific UI element.
This step will take 30 minutes to 1 hour, based on the number of screens and views you want to configure ids for.
If you already have view IDs for the views, this step can be skipped.
React Native Apxor RTM plugin (react-native-apxor-rtm-plugin) will show Inline messages (also called as Tooltips) and CoachMark messages for a given View ID/Tag.
In React Native apps, you can mention View IDs for views by adding nativeID
attribute to the Components. If any View
that does not have nativeID
attribute, Inline or Coachmark messages will not be shown.
For example, you want to show tooltip for a button. You can't directly give a unique id for Button. Instead, you need to wrap it up with a View
tag like:
So, the same value for nativeID
attribute can be configured in Apxor dashboard to identify the Button and display Inline or Coachmark message.
Embed and Story Slot
Add Embed Card Slot
Note
For using Embed Cards, the versions of the following plugins should be greater than or equal to the ones mentioned below
Core: 3.1.0
qe: 1.7.5
rtm: 2.4.8
WYSIWYG: 1.5.6
react-native-rtm: 1.6.2
react-native-apxor-sdk: 1.7.4
In all areas of the app where you may want to show an in-line widget, insert the following code
Rename <Tag> to any unique ID (any positive Integer). Ensure that you keep the ID unique across different IDs and across different Apxor-Widget instances.
Add Story Slot
Note
For using Apxor Stories, the versions of the following plugins should be greater than or equal to the ones mentioned below
Core: 3.1.0
qe: 1.7.5
rtm: 2.4.8
WYSIWYG: 1.5.6
react-native-rtm: 1.6.2
react-native-apxor-sdk: 1.7.4
In all areas of the app where you may want to show stories, insert the following code
Replace <ID> with any unique integer(any positive Integer). Ensure that you keep the ID unique across different ApxorStoryWidget instances.
Handle custom redirection using Key-Value pairs
If your app wants to redirect users based on simple key-value pairs instead using Deeplink URLs or Activity, you can follow below approach
Handle Deeplinks
Follow the instructions given in here to enable deeplinks in your application.
Whenever Apxor React Native SDK sends the deeplink URL to the app, the following callback will be executed and you have to interpret the URL and navigate the user to the necessary page or tab.
Add the following code snippet in your root component to handle deeplink URLs
Last updated