Context Insights
This page explains how to use ContextSDK to get insights into how your app is being used in the real world for Context Insights.
Overview
- Step 1: Add ContextSDK to your app
- Step 2: Log events
- Step 3: Ship an App Store update with ContextSDK
Impact on your app
Less than 0.2% CPU Usage
0.6 MB Memory Usage
Adds less than 700kb to your app's binary size
No PII processed or stored
No app permissions required
Operates without ATT
Installation
Add https://github.com/context-sdk/context-sdk-releases
as dependency.
- Download the latest release: https://storage.googleapis.com/de73e410-context-sdk-releases/latest/ContextSDK.zip
- Drag & Drop the
ContextSDK.xcframework
folder into the Xcode file list - Go to your project settings, scroll down to
Frameworks, Libraries, and Embedded Content
, addContextSDK.xcframework
, and selectEmbed & Sign
If you want to download a specific version, you can replace latest
with the desired version number, e.g. https://storage.googleapis.com/de73e410-context-sdk-releases/3.1.0/ContextSDK.zip
Step 1: Add the ContextSDK maven repository in your project level settings.gradle.kts
file:
dependencyResolutionManagement {
repositories {
...
// Add the ContextSDK maven repo:
maven {
url = uri("https://storage.googleapis.com/fc4073e9-contextsdk-maven/")
}
}
}
Step 2: Add the ContextSDK dependency in your module level build.gradle.kts
:
Step 1: Choose your preferred package manager:
Step 2: Ensure minimum Deployment Target
ContextSDK requires a minimum deployment target of iOS 14.0, be sure to update your ios/Podfile
to specify 14.0 or higher:
- Download the latest version of ContextSDK: https://storage.googleapis.com/de73e410-context-sdk-releases/latest/ContextSDK.zip
- Drag & drop the ContextSDK.xcframework into the
Assets/Plugins/iOS
folder of your Unity project - Add the
ContextSDKBinding.cs
script next to it
License Key
After you installed ContextSDK, you need to add your license key. Register here to get started.
In your willFinishLaunchingWithOptions:
(or anywhere before you access the SDK) setup the ContextManager
:
- Create a new custom Swift class named
AppDelegate.swift
- In your
App
sceneUIApplicationDelegateAdaptor
property wrapper
Note: Android is still in beta - to obtain a license key contact us at support@contextsdk.com
- In your
Application
sub-class call the following code:
class MainApplication : Application() {
override fun onCreate() {
super.onCreate()
ContextSDK.setup(this, "YOUR_LICENSE_KEY_HERE")
}
}
- In your primary
Activity
subclass, or in everyActivity
in your application, allow ContextSDK to attach and detach:
- In your
Application
sub-class call the following code:
public class MainApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
ContextSDK.Companion.setup(this, "YOUR_LICENSE_KEY_HERE", new ContextSDKConfiguration());
}
}
- In your primary
Activity
subclass, or in everyActivity
in your application, allow ContextSDK to attach and detach:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ContextSDK.Companion.attachToActivity(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
ContextSDK.Companion.detachFromActivity(this);
}
}
Notes:
- If the above isn't setup correctly, ContextSDK won't be able to start and stop collection of accelerometer & gyroscope data.
- The
Activity
must conform toLifecycleOwner
(e.g.AppCompatActivity
). PlainActivities
are not supported.
Call the following code on app start:
In the Start()
of a MonoBehaviour
that is run early in your game (or anywhere before you access the SDK) setup the ContextManager
:
Log Events
We recommend you log specific events to get a better understanding of how the real world context influences your app.
Page Views
Use this to track users navigating through different screen in your app. It allow us to provide you insights into which screen is most commonly used in which real world context.
User Actions
Use this to track certain user actions, like when a user enabled a certain feature, when a user tapped a button, when the user created an account, or when the user shared something. This allows us to provide you insights into which user actions are most commonly done in which real world context.
Generic Events
Use this to track certain events in your app. This can be used generically to track any type of event. For example, you can add this to your existing analytics code to log all your existing events into ContextSDK. This allows us to provide you insights into which events are most commonly triggered in which real world context.
Conversion & Upsells
Logging the outcome of sales events (e.g. in-app purchases, orders, etc.) allows us to provide you with detailed insights in which real world context has a positive or negative effect on your app's conversion rates.
The integration is slightly more complex, as you need to track the context before before you show the prompt, and then log the outcome after the user has made a decision.
- Use a different, unique
flowName
for each upsell funnel (e.g.upsell_prompt
,upsell_onboarding
, etc.)- If you have the same purchase flow, but from different parts of your app, use a different
flowName
for each. - We automatically analyze the overlap between different flows, to decide if there should be one, or more models.
- If you have the same purchase flow, but from different parts of your app, use a different
- The timing is crucial: You need to create the
context
object right before showing your prompt, and then log the outcome of the user interaction after the user has either accepted or dismissed the prompt. - For each
context
object you create, be sure to log an outcome, even if the user dismisses the prompt.
In most cases, ContextSDK will execute your block instantly. Only if your app was recently launched, or resumed from the background, it will take up to a few seconds to get a full context.
import { optimize } from 'react-native-context-sdk';
import { Outcome } from 'react-native-context-sdk/lib/typescript/src/context';
optimize({
flowName: 'upsell',
onGoodMoment: async (context) => {
// Show the upgrade prompt here right after fetching the context
// Once you know if the user purchased or dismissed the upsell, log the outcome:
context.log(Outcome.positive); // or Outcome.negative
},
});
It's critical you trigger your prompt inside the block, which behaves as follows:
- The callback is instantly executed if your app has been running for at least 3 seconds
- The callback being executed within 3 seconds if your app was just put into the foreground recently
If you decide to use Context Decision in the future to start optimizing your app, your block will only be executed when we deem it to be a good moment.
Forcing instant callbacks when tracking conversions
There are cases where you may prefer to always instantly have your callback executed. For example, when you want to show a prompt right after a certain user-action, to prevent the prompt showing up when the user already left the screen. For those cases, you'd need to use the ContextManager.optimize
method with the maxDelay: 0
parameter:
import { optimize } from 'react-native-context-sdk';
import { Outcome } from 'react-native-context-sdk/lib/typescript/src/context';
optimize({
flowName: 'upsell',
maxDelay: 0,
onGoodMoment: async (context) => {
// Show the upgrade prompt here right after fetching the context
// Once you know if the user purchased or dismissed the upsell, log the outcome:
context.log(Outcome.positive); // or Outcome.negative
},
});
ContextSDKBinding.Optimize("upsell", delegate (Context context) {
// Setting maxDelay to 0 (below as extra parameter) causes the callback to be called immediately.
// Show the upgrade prompt here right after fetching the context
// Once you know if the user purchased or dismissed the upsell, log the outcome:
context.Log(Outcome.Positive); // or Outcome.Negative
}, null, 0);
Using maxDelay: 0
means that the context
object may not be fully ready, which will reduce data quality. We recommend not using this approach right after the app start, but only in places where the app usually has already been running for a few seconds.
We also support some additional helpers, which you can find in our Context Decision Docs.
Go Live
Now all that's left is to ship your update to the App Store to start gaining context insights. Continue to the release page for a final check before shipping, as well as other deployment tips.