BuildConfigas a constant called
JUSTTRACK_SDK_API_TOKENfor the examples given in this document. It should look like this:
prod-57e...64 characters...e542. Keep in mind that these tokens are scoped to the package id of your app, so if you are building more than one app from a single code base, you need to use different tokens for the different apps.
prod-c6654a0ae88b2f21111b9d69b4539fb1186de983f0ad826f0febaf28e3e3b7edas the API token.
JustTrackSdk. It allows you to attribute the current user and record user events. To create an instance of the SDK you have to invoke the
JustTrackSdkBuilderclass. To create a new builder you need a
Contextfrom your app. If your application extends the Android
Applicationclass, we will automatically track the user in your app (switching between different activities of your app or sending your app to the background). You should save the reference to the SDK somewhere in your main activity. Instantiating the SDK could look like this:
onDestroyon the SDK when your app terminates. This will unregister all listeners and tear down the session tracking. You have to create a new instance of the SDK before you can use it again.
attributeUserto retrieve an attribution containing your JustTrack user id as well as information about the source of the user.
attributeUserin your app. To get the information about the user attribution in your app you need to call
geton the future returned by
attributeUser. This will block the current thread until the future resolves or throws an exception.
geton the main (UI) thread! This is a safeguard for you as a promise you get back from the SDK might actually depend on work the main/UI thread is expected to do. Blocking that thread could then deadlock your app. If you call
geton the main thread, an exception will be thrown. You can either call the method on another thread or use
sdk.toPromiseto schedule a callback when the future resolves:
Futureresolved to a failure value will not update the future. You have to subscribe to updates of the attribution using
registerAttributionListener()to receive the attribution.
AttributionResponseinterface implements the access layer to an attribution on Java side, but basically an attribution can look like this:
ExampleAdNetworkwhich belongs to the
ExampleDirectChannel. The user thus was not recruited by another user of your app, but instead was bought by a paid advertisement. The
adsetIdfields will not always be set if you paid for a user.
publishon the event:
UserEventinstance you are creating an immutable
PublishableUserEventobject which you can pass to
publishEvent()as often as you need. Calling
build()does not modify the
UserEventobject if you need to modify it again.
UserEventinstance is actually a builder for the event we later send to the backend. You can either provide all parameters via the constructor if you want or you can initialize an empty event and later call setters for the different properties. The only thing you need to create a new event is the name of the event, which may also not be empty (and can later no longer be changed). The following constructors are provided:
EventDetailsclass captures the name of a user event with some additional details. Those are the
actionof the event and can be used to group events together. For example, all events generated by the SDK regarding the session tracking share the category
unitcan only always provided together and default to
Unit.COUNT. The three dimensions default to
""if not specified. You can set the properties after initialization also with these methods:
setMillisecondsare provided for your convenience if you know for some event that it will always use a specific unit.
PROGRESSION_QUEST_STARTevents. The tracking ends once you trigger the
PROGRESSION_LEVEL_FAILevents for levels and
PROGRESSION_QUEST_FAILevents for quests. These events are then automatically modified to also carry the total time the user spend with the game open on his device.
com.ironsource.sdk:mediationsdk. It should be compatible with version 6 as well as 7 of the IronSource SDK though. You have to add the following to your
proguard-rules.profor the sdk to be able to find the IronSource SDK at runtime:
build()returns. You can enable the integration like this:
integrateWithIronSource) - using both will integrate two times and might result in duplicate events. The following code illustrates how integrating directly might look:
Intentsend to their phones. Also a user might expect some Welcome back screen upon returning into the app.
sdk.getRetargetingParameters()will return data about the campaign the user got attributed to. These include the promotion code for the campaign as well as additional parameters configured for the campaign. You can then use those to e.g. present the user with a special Welcome back! screen or grant the user a promised gift.
nullthis time, so your app can avoid granting the user gifts multiple times or similar.
sdk.registerAttributionListener: Use this to get notified about the new attribution while the app is running.
sdk.registerRetargetingParametersListener: use this to get notified about new retargeting parameters while the app is running.
Activity#getIntent()to the SDK builder.
setReAttributionTimeFrameon the SDK builder. Using those you can change the defaults of 48 hours for inactive users as well as 14 days for the maximum age of an attribution.
Intent. This can happen so fast that the JustTrack backend might still be processing the click and therefore it would take a few seconds to validate with the server that the re-attribution of the user was correct. If you want to display a special Welcome back! screen to the user, it can be useful to already know some of the parameters of the click in advance and just display the screen, even if it later turns out the user was not re-attributed. Therefore the JustTrack SDK provides a method
getPreliminaryRetargetingParametersto retrieve an instance of
PreliminaryRetargetingParametersif any are available. Those parameters are created from data not yet validated and should not be relied on for anything which can not be reversed if they do not validate.