public static class Tracker.Configuration
extends java.lang.Object
The Tracker can be configured on any thread but it is recommended that it be configured directly in Application.onCreate on the main thread. Minimal initialization is performed during configuration prior to dispatching to a background thread and returning to the caller. Once the configure method returns all other methods are available to use immediately.
//Basic Configuration
Tracker.configure(new Tracker.Configuration(getApplicationContext())
.setAppGuid("_YOUR_APP_GUID_")
);
//Configuration With Debug Logging
Tracker.configure(new Tracker.Configuration(getApplicationContext())
.setAppGuid("_YOUR_APP_GUID_")
.setLogLevel(Tracker.LOG_LEVEL_DEBUG)
);
//Configuration With Attribution Listener
Tracker.configure(new Configuration(getApplicationContext())
.setAppGuid("_YOUR_APP_GUID_")
.setAttributionListener(new AttributionListener() {
public void onAttributionReceived(@NonNull String attribution) {
}
})
);
//Configuration with Intelligent Consent Management
Tracker.configure(new Configuration(getApplicationContext())
.setAppGuid("_YOUR_APP_GUID_")
.setIntelligentConsentManagement(true)
.setConsentStatusChangeListener(new ConsentStatusChangeListener() {
public void onConsentStatusChange() {
}
})
);
Multiple Processes
The Tracker SDK can only be configured in a single process. If the app uses multiple processes a check must be performed in the Application.onCreate method to ensure the Tracker is only configured in the desired process. Typically this would be the same process your UI runs in as running the Tracker in a different process will prevent session tracking.
If running the Tracker in a process other than the default the ReferralReceiver Broadcast Receiver must be updated to use that process.
This should be done by following the Multiple Receivers instructions where your broadcast receiver is defined as running in the same process as the Tracker.
Other processes can send events by bundling them in an Intent as type Parcelable that is sent to an internal Broadcast Receiver that runs on the same process as the Tracker.
The Broadcast Receiver then extracts the Event from the Intent and forwards it to the Tracker.sendEvent(Event) method.
Tracker.configure(Configuration)| Constructor and Description |
|---|
Configuration(android.content.Context context)
Creates a Configuration Builder that is used to configure the Tracker
|
| Modifier and Type | Method and Description |
|---|---|
Tracker.Configuration |
addCustom(org.json.JSONObject custom)
Adds a custom parameter json object.
|
Tracker.Configuration |
addCustom(java.lang.String key,
java.lang.String value)
Adds a custom parameter.
|
Tracker.Configuration |
setAppGuid(java.lang.String appGuid)
Sets the App Guid for this app.
|
Tracker.Configuration |
setAppLimitAdTracking(boolean appLimitAdTracking)
Sets if app level advertising tracking should be limited.
|
Tracker.Configuration |
setAttributionUpdateListener(AttributionUpdateListener attributionUpdateListener)
Sets an attribution update listener.
|
Tracker.Configuration |
setConsentStatusChangeListener(ConsentStatusChangeListener consentStatusChangeListener)
Sets the Intelligent Consent Management status change listener.
|
Tracker.Configuration |
setIdentityLink(Tracker.IdentityLink identityLink)
Sets a user identity link that is used for linking based off of external criteria such as a user login.
|
Tracker.Configuration |
setInstantAppGuid(java.lang.String instantAppGuid)
Sets the Instant App Guid for this app.
|
Tracker.Configuration |
setIntelligentConsentManagement(boolean intelligentConsentManagement)
Enables Intelligent Consent Management.
|
Tracker.Configuration |
setLogLevel(int logLevel)
Sets the log level for the Tracker.
|
Tracker.Configuration |
setManualManagedConsentRequirements(boolean manualManagedConsentRequirements)
Enables Manual Management of the consent requirements.
|
Tracker.Configuration |
setPartnerName(java.lang.String partnerName)
Sets the Partner Name for Auto Provisioning.
|
Tracker.Configuration |
setSleep(boolean sleep)
Sets the Tracker sleep state.
|
public Configuration(android.content.Context context)
Once all desired parameters are set pass this object to Tracker.configure(Configuration)
context - Application Context.public final Tracker.Configuration setAppGuid(java.lang.String appGuid)
Required unless otherwise specified by your Client Success Manager.
Set this or setPartnerName(String) but not both.
appGuid - Your App Guidpublic final Tracker.Configuration setInstantAppGuid(java.lang.String instantAppGuid)
Setting this will enable the Instant App Feature. This must be set in both the Instant and Full app.
instantAppGuid - Your Instant App Guidpublic final Tracker.Configuration setPartnerName(java.lang.String partnerName)
Set this or setAppGuid(String) but not both.
partnerName - Partner Namepublic final Tracker.Configuration setLogLevel(int logLevel)
Use of a log level beyond Tracker.LOG_LEVEL_INFO in production is discouraged.
logLevel - Log Level type def Tracker.LogLevelTracker.LogLevelpublic final Tracker.Configuration setAttributionUpdateListener(AttributionUpdateListener attributionUpdateListener)
Attribution information is assessed and stored within Kochava’s Servers, where it is reported back to you through your Kochava account.
You may also retrieve this information from within your app by passing in an implementation of AttributionUpdateListener.
NOTE: Retrieving the information within your app should only be done if your app makes use of this information, otherwise it causes needless network communication.
attributionUpdateListener - Attribution listener.AttributionUpdateListener,
Tracker.getAttribution()public final Tracker.Configuration setConsentStatusChangeListener(ConsentStatusChangeListener consentStatusChangeListener)
Use with setIntelligentConsentManagement(boolean).
consentStatusChangeListener - Consent Status Listener.public final Tracker.Configuration setIntelligentConsentManagement(boolean intelligentConsentManagement)
Intelligent Consent Management must be enabled both here and on the Kochava Dashboard in order to function.
Refer to our Intelligent Consent Management support documentation for more information on usage.
Sample Code Implementation
// Example implementation with Intelligent Consent Management. This is an example only and is not expected to be used as is.
public class MyActivity extends Activity implements ConsentStatusChangeListener {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Configure the Tracker with Intelligent Consent Management and a Consent Status Change Listener.
Tracker.configure(new Configuration(getApplicationContext())
.setAppGuid("_YOUR_APP_GUID_")
.setIntelligentConsentManagement(true)
.setConsentStatusChangeListener(this)
);
// Check if we know our consent status from a previous launch.
if(Tracker.isConsentGrantedOrNotRequired()) {
// You are good to go with normal operation.
// ...
} else {
// You lack consent. Start in restricted mode.
// ...
// At this point we are required and not granted. We should see if we are supposed to prompt the user.
if(Tracker.isConsentShouldPrompt()) {
// Depending on your implementation you may want to schedule this into your app lifecycle instead of prompting right now.
promptForConsent();
}
}
}
// Consent Status Change callback from the Tracker.
public final void onConsentStatusChange() {
if(Tracker.isConsentGrantedOrNotRequired()) {
// You are good to go with normal operation.
// ...
} else {
// Make sure nothing that requires consent is running. Some items may require being shut down if we previously had consent.
// ...
// At this point we are required and not granted. We should see if we are supposed to prompt the user.
if(Tracker.isConsentShouldPrompt()) {
// Depending on your implementation you may want to schedule this into your app lifecycle instead of prompting right now.
promptForConsent();
}
}
}
// Prompt the user for consent. Important: This dialog is an example only and is not GDPR compliant.
private void promptForConsent() {
StringBuilder message = new StringBuilder("We share data with the following partners.\n\n");
// Retrieve the list of consent partners and add them to the message.
ConsentPartner[] partners = Tracker.getConsentPartners();
for(int i=0; i<partners.length; i++) {
message.append(partners[i].name);
if(i < partners.length - 1) {
message.append(", ");
}
}
// Build and show the dialog.
new AlertDialog.Builder(this)
.setTitle("Do you grant consent?")
.setMessage(message.toString())
.setPositiveButton("YES", new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Tracker.setConsentGranted(true);
// Consent is now granted, operate normally.
// ...
}
})
.setNegativeButton("NO", new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Tracker.setConsentGranted(false);
// Consent is now declined, operate as restricted.
// ...
}
})
.show();
// Indicate to the Tracker that we have prompted the user. This must be set regardless of if we receive a response.
Tracker.clearConsentShouldPrompt();
}
}
intelligentConsentManagement - True to enable Kochava Intelligent Consent Management. False (default) to operate normally.setConsentStatusChangeListener(ConsentStatusChangeListener).public final Tracker.Configuration setManualManagedConsentRequirements(boolean manualManagedConsentRequirements)
Requires Intelligent Consent Management (ICM) to be enabled. See setIntelligentConsentManagement(boolean).
With ICM the requirements for if Consent is required for a specific user is decided by a handshake between the SDK and Kochava's servers. With Manual Managed mode that handshake is disabled and the SDK waits for an update from the App. Consent is considered to be required until otherwise specified by the app.
Consent can be granted and declined or marked as required or not when using manual managed mode and the SDK will properly handle when it can or cannot gather and send data.
Other ICM features such as the partner list, consent status change callbacks, and the should prompt feature do not function in manual managed mode and should not be called.
manualManagedConsentRequirements - True to enable Manual Management of Consent Requirements. False (default) to use Kochava Managed Consent Requirements.public final Tracker.Configuration setAppLimitAdTracking(boolean appLimitAdTracking)
This value is unrelated to and is sent in addition to the operating system limit ad tracking value.
Default False.
appLimitAdTracking - True to limit ad tracking for this app. False for normal operation.Tracker.setAppLimitAdTracking(boolean)public final Tracker.Configuration setSleep(boolean sleep)
Sleep mode on prevents the Tracker from sending any network requests. It will still process all incoming events and sessions. Any queued items will be sent as soon as sleep mode is disabled. Sleep mode state is not preserved across launches.
This should only be used if there is some additional information needed before the Tracker continues such as an identity link, runtime permission, waiting on user to accept privacy policy, or other.
Example: Your app is using email attribution and is running on an Android device with Runtime Permissions. Start the Tracker in Application.onCreate, set sleep==true and in the onRequestPermissionsResult method for your GET_ACCOUNTS permission set sleep==false to continue Tracker initialization.
Default False.
sleep - True to enable sleep, False for normal operation.Tracker.setSleep(boolean)public final Tracker.Configuration setIdentityLink(Tracker.IdentityLink identityLink)
identityLink - IdentityLink that maps key names with values.Tracker.IdentityLink,
Tracker.setIdentityLink(IdentityLink)public final Tracker.Configuration addCustom(java.lang.String key, java.lang.String value)
key - Parameter key.value - Parameter Value.public final Tracker.Configuration addCustom(org.json.JSONObject custom)
custom - Parameter Object.