Get attribution info
This page covers every SDK platform and version. A part that applies only to some platforms starts with Platform: …, and a part that applies only to some SDK versions starts with SDK version: ….
The justtrack SDK automatically determines a user’s identity and attribution after setup. This includes details about the ad the user clicked (if any), the campaign that ad belongs to, and the associated network and channel.
Platform: Android, iOSYou can access attribution data in your app through the JustTrackSdk::attribution field:
You can access attribution data in your app through the JustTrackSdk::getAttribution method:
You can access attribution data in your app through the JusttrackSdk::getAttribution method:
You can access attribution data in your app by connecting to the attribution_received signal and
calling get_attribution():
You can access attribution data in your app through the JustTrackSDKBehaviour::GetAttribution
method:
You can access attribution data in your app through the UJustTrackSubsystem::GetAttribution
function. It needs an initialized SDK and reports the result on the game thread:
- Android
- iOS
- Unity
- React Native
- Flutter
- Godot
- Unreal
Platform: Android
SDK version: 8.X.Xval attribution = sdk.attribution.await()
val userType = attribution.userType
val campaign = attribution.campaign
val campaignName = campaign.name
val campaignId = campaign.id
val campaignType = campaign.type
val campaignIsOrganic = campaign.isOrganic
val channel = attribution.channel
val channelName = channel.name
val channelId = channel.id
val channelIsIncent = channel.isIncent
val partner = attribution.partner
val partnerName = partner.name
val partnerId = partner.id
val sourceId = attribution.sourceId
val sourceBundleId = attribution.sourceBundleId
val sourcePlacement = attribution.sourcePlacement
val adsetId = attribution.adsetId
val createdAt = attribution.createdAt
val isRedownload = attribution.isRedownload
val attribution = sdk.attribution.await()
val userType = attribution.userType
val campaign = attribution.campaign
val campaignName = campaign.name
val campaignId = campaign.id
val campaignType = campaign.type
val campaignIsOrganic = campaign.isOrganic
val type = attribution.type
val channel = attribution.channel
val channelName = channel.name
val channelId = channel.id
val channelIsIncent = channel.isIncent
val partner = attribution.partner
val partnerName = partner.name
val partnerId = partner.id
val sourceId = attribution.sourceId
val sourceBundleId = attribution.sourceBundleId
val sourcePlacement = attribution.sourcePlacement
val adsetId = attribution.adsetId
val createdAt = attribution.createdAt
val isRedownload = attribution.isRedownload
val attribution = sdk.attribution.await()
val justtrackUserId = attribution.getJusttrackUserId()
val userType = attribution.getUserType()
val campaign = attribution.getCampaign()
val campaignName = campaign.getName()
val campaignId = campaign.getId()
val campaignType = campaign.getType()
val campaignIsOrganic = campaign.isOrganic()
val type = attribution.getType()
val channel = attribution.getChannel()
val channelName = channel.getName()
val channelId = channel.getId()
val channelIsIncent = channel.isIncent()
val partner = attribution.getPartner()
val partnerName = partner.getName()
val partnerId = partner.getId()
val sourceId = attribution.getSourceId()
val sourceBundleId = attribution.getSourceBundleId()
val sourcePlacement = attribution.getSourcePlacement()
val adsetId = attribution.getAdsetId()
val createdAt = attribution.getCreatedAt()
val isRedownload = attribution.getRedownload()
Platform: iOS
SDK version: 8.X.Xsdk.attribution.observe { result in
switch result {
case let .failure(error):
// handle error
case let .success(response):
let userType = response.userType
let isRedownload = response.isRedownload
let campaign = response.campaign
let campaignName = campaign.name
let campaignId = campaign.id
let campaignType = campaign.type
let campaignIsOrganic =campaign.isOrganic
let channel = response.channel
let channelName = channel.name
let channelId = channel.id
let channelIsIncent = channel.isIncent
let partner = response.partner
let partnerName = partner.name
let partnerId = partner.id
let sourceId = response.sourceId
let sourceBundleId = response.sourceBundleId
let sourcePlacement = response.sourcePlacement
let adsetId = response.adsetId
let createdAt = response.createdAt
}
}
sdk.attribution.observe { result in
switch result {
case let .failure(error):
// handle error
case let .success(response):
let userType = response.userType
let isRedownload = response.isRedownload
let campaign = response.campaign
let campaignName = campaign.name
let campaignId = campaign.id
let campaignType = campaign.type
let campaignIsOrganic =campaign.isOrganic
let type = response.type
let channel = response.channel
let channelName = channel.name
let channelId = channel.id
let channelIsIncent = channel.isIncent
let partner = response.partner
let partnerName = partner.name
let partnerId = partner.id
let sourceId = response.sourceId
let sourceBundleId = response.sourceBundleId
let sourcePlacement = response.sourcePlacement
let adsetId = response.adsetId
let createdAt = response.createdAt
}
}
sdk.attribution.observe { result in
switch result {
case let .failure(error):
// handle error
case let .success(response):
let userType = response.userType
let redownload = response.redownload
let campaign = response.campaign
let campaignName = campaign.name
let campaignId = campaign.id
let campaignType = campaign.type
let campaignIsOrganic =campaign.isOrganic
let type = response.type
let channel = response.channel
let channelName = channel.name
let channelId = channel.id
let channelIsIncent = channel.isIncent
let partner = response.partner
let partnerName = partner.name
let partnerId = partner.id
let sourceId = response.sourceId
let sourceBundleId = response.sourceBundleId
let sourcePlacement = response.sourcePlacement
let adsetId = response.adsetId
let createdAt = response.createdAt
let installId = response.installId
}
}
Platform: Unity
SDK version: 8.X.Xusing JustTrack;
JustTrackSDKBehaviour.GetAttribution((attribution) => {
var campaign = attribution.Campaign;
var campaignName = campaign.Name;
var campaignId = campaign.Id;
var campaignType = campaign.Type;
var userType = attribution.UserType;
var channel = attribution.Channel;
var channelName = channel.Name;
var channelId = channel.Id;
var channelIsIncent = channel.IsIncent;
var partner = attribution.Partner;
var partnerName = partner.Name;
var partnerId = partner.Id;
var sourceId = attribution.SourceId;
var sourceBundleId = attribution.SourceBundleId;
var sourcePlacement = attribution.SourcePlacement;
var adsetId = attribution.AdsetId;
var createdAt = attribution.CreatedAt;
}, (error) => {
// handle error and wait for the attribution request to be retried automatically
});
using JustTrack;
JustTrackSDKBehaviour.GetAttribution((attribution) => {
var campaign = attribution.Campaign;
var campaignName = campaign.Name;
var campaignId = campaign.Id;
var campaignType = campaign.Type;
var userType = attribution.UserType;
var type = attribution.Type;
var channel = attribution.Channel;
var channelName = channel.Name;
var channelId = channel.Id;
var channelIsIncent = channel.IsIncent;
var partner = attribution.Partner;
var partnerName = partner.Name;
var partnerId = partner.Id;
var sourceId = attribution.SourceId;
var sourceBundleId = attribution.SourceBundleId;
var sourcePlacement = attribution.SourcePlacement;
var adsetId = attribution.AdsetId;
var createdAt = attribution.CreatedAt;
}, (error) => {
// handle error and wait for the attribution request to be retried automatically
});
using JustTrack;
JustTrackSDKBehaviour.GetAttribution((attribution) => {
var justtrackUserId = attribution.JusttrackUserId;
var campaign = attribution.Campaign;
var campaignName = campaign.Name;
var campaignId = campaign.Id;
var campaignType = campaign.Type;
var userType = attribution.UserType;
var type = attribution.Type;
var channel = attribution.Channel;
var channelName = channel.Name;
var channelId = channel.Id;
var channelIsIncent = channel.IsIncent;
var partner = attribution.Partner;
var partnerName = partner.Name;
var partnerId = partner.Id;
var sourceId = attribution.SourceId;
var sourceBundleId = attribution.SourceBundleId;
var sourcePlacement = attribution.SourcePlacement;
var adsetId = attribution.AdsetId;
var createdAt = attribution.CreatedAt;
}, (error) => {
// handle error and wait for the attribution request to be retried automatically
});
Platform: React Native
SDK version: 8.X.Xconst attribution = await JustTrackSdk.getAttribution();
const userType = attribution.userType;
const campaign = attribution.campaign;
const campaignName = campaign.name;
const campaignId = campaign.id;
const campaignType = campaign.type;
const campaignIsOrganic = campaign.isOrganic;
const partner = attribution.partner;
const partnerName = partner.name;
const partnerId = partner.id;
const channel = attribution.channel;
const channelName = channel.name;
const channelId = channel.id;
const channelIsIncent = channel.isIncent;
const sourceId = attribution.sourceId;
const sourceBundleId = attribution.sourceBundleId;
const sourcePlacement = attribution.sourcePlacement;
const adsetId = attribution.adsetId;
const isRedownload = attribution.isRedownload;
const attribution = await JustTrackSdk.getAttribution();
const userType = attribution.userType;
const type = attribution.type;
const campaign = attribution.campaign;
const campaignName = campaign.name;
const campaignId = campaign.id;
const campaignType = campaign.type;
const campaignIsOrganic = campaign.isOrganic;
const partner = attribution.partner;
const partnerName = partner.name;
const partnerId = partner.id;
const channel = attribution.channel;
const channelName = channel.name;
const channelId = channel.Id;
const channelIsIncent = channel.isIncent;
const sourceId = attribution.sourceId;
const sourceBundleId = attribution.sourceBundleId;
const sourcePlacement = attribution.sourcePlacement;
const adsetId = attribution.adsetId;
const isRedownload = attribution.isRedownload;
const attribution = await JustTrackSdk.getAttribution();
const justtrackUserId = attribution.justtrackUserId;
const userType = attribution.userType;
const type = attribution.type;
const campaign = attribution.campaign;
const campaignName = campaign.name;
const campaignId = campaign.id;
const campaignType = campaign.type;
const campaignIsOrganic = campaign.isOrganic;
const partner = attribution.partner;
const partnerName = partner.name;
const partnerId = partner.id;
const channel = attribution.channel;
const channelName = channel.name;
const channelId = channel.Id;
const channelIsIncent = channel.isIncent;
const sourceId = attribution.sourceId;
const sourceBundleId = attribution.sourceBundleId;
const sourcePlacement = attribution.sourcePlacement;
const adsetId = attribution.adsetId;
Platform: Flutter
final attribution = await JusttrackSdk.getAttribution();
final userType = attribution.userType;
final type = attribution.type;
final campaign = attribution.campaign;
final campaignName = campaign.name;
final campaignId = campaign.id;
final campaignType = campaign.type;
final campaignIsOrganic = campaign.isOrganic;
final channel = attribution.channel;
final channelName = channel.name;
final channelId = channel.id;
final partner = attribution.partner;
final partnerName = partner.name;
final partnerId = partner.id;
final sourceId = attribution.sourceId;
final sourceBundleId = attribution.sourceBundleId;
final sourcePlacement = attribution.sourcePlacement;
final adsetId = attribution.adsetId;
final createdAt = attribution.createdAt;
final isRedownload = attribution.isRedownload;
Platform: Godot
func _ready() -> void:
JustTrackSdk.attribution_received.connect(_on_attribution)
JustTrackSdk.attribution_failed.connect(_on_attribution_failed)
JustTrackSdk.get_attribution()
func _on_attribution(attribution: Dictionary) -> void:
var userType = attribution.get("userType")
var type = attribution.get("type")
var isRedownload = attribution.get("isRedownload")
var createdAt = attribution.get("createdAt")
var campaign = attribution.get("campaign") as Dictionary
var campaignId = campaign.get("id")
var campaignName = campaign.get("name")
var campaignType = campaign.get("type")
var campaignIsOrganic = campaign.get("isOrganic")
var channel = attribution.get("channel") as Dictionary
var channelId = channel.get("id")
var channelName = channel.get("name")
var channelIsIncent = channel.get("isIncent")
var partner = attribution.get("partner") as Dictionary
var partnerId = partner.get("id")
var partnerName = partner.get("name")
var sourceId = attribution.get("sourceId")
var sourceBundleId = attribution.get("sourceBundleId")
var sourcePlacement = attribution.get("sourcePlacement")
var adsetId = attribution.get("adsetId")
func _on_attribution_failed(code: String, message: String) -> void:
push_error("Attribution failed [%s]: %s" % [code, message])
Platform: Unreal
void AMyActor::RequestAttribution()
{
UJustTrackSubsystem* JustTrack = GetGameInstance()->GetSubsystem<UJustTrackSubsystem>();
FJustTrackAttributionResult OnComplete;
OnComplete.BindUFunction(this, GET_FUNCTION_NAME_CHECKED(AMyActor, HandleAttribution));
JustTrack->GetAttribution(OnComplete);
}
void AMyActor::HandleAttribution(
bool bSuccess,
const FJustTrackAttribution& Attribution,
const FJustTrackError& Error)
{
if (!bSuccess)
{
UE_LOG(LogTemp, Warning, TEXT("Attribution failed: %s (%s)"), *Error.Message, *Error.Code);
return;
}
const FString UserType = Attribution.UserType;
const bool bIsRedownload = Attribution.bRedownload;
const FDateTime CreatedAt = Attribution.CreatedAt;
const FJustTrackCampaign& Campaign = Attribution.Campaign;
const FString CampaignId = Campaign.Id;
const FString CampaignName = Campaign.Name;
const FString CampaignType = Campaign.Type;
const bool bCampaignIsOrganic = Campaign.bOrganic;
const FJustTrackChannel& Channel = Attribution.Channel;
const int32 ChannelId = Channel.Id;
const FString ChannelName = Channel.Name;
const bool bChannelIsIncent = Channel.bIncent;
const FJustTrackPartner& Partner = Attribution.Partner;
const int32 PartnerId = Partner.Id;
const FString PartnerName = Partner.Name;
const FString SourceId = Attribution.SourceId;
const FString SourceBundleId = Attribution.SourceBundleId;
const FString SourcePlacement = Attribution.SourcePlacement;
const FString AdsetId = Attribution.AdsetId;
}
If you are only using the justtrack dashboard to keep track of your install sources, you don't need to call getAttribution yourself.
If the attribution can not be performed because the user is offline, it will eventually fail. The
SDK will then wait for a new internet connection and retry the attribution. An attribution
obtained after the returned Future resolved to a failure value won't update the future. You have
to subscribe to updates of the attribution using register(attributionListener:) to receive the
attribution. For more information, see Listen for attribution
updates.
If the attribution failed because we couldn't reach the justtrack backend (user might be offline), we will automatically retry it as soon as network connectivity is restored. In that case, you need to subscribe to the OnAttributionResponse callback to be notified about the attribution. Keep in mind that the callback can also be called if a user is attributed to a retargeting campaign.
using JustTrack;
JustTrackSDK.OnAttributionResponse += (attribution) => {
Debug.Log(attribution.Campaign.Name);
};
In Blueprint, use Get justtrack followed by Get Attribution and bind the delegate to a custom event with the Success, Attribution, and Error outputs.
Platform: Android, iOS, React NativeListen for attribution updates
A user's attribution can change while your app is running. For example, the SDK retries a failed attribution once the device is back online, and it can re-attribute a returning user to a retargeting campaign. The attribution you requested earlier doesn't update in these cases.
To get notified every time the SDK receives a new attribution, register an attribution listener. If you register the listener before the first attribution response arrives, the SDK also calls it for that response. The listener isn't called for attributions received before you registered it, so register it right after you initialize the SDK.
Platform: AndroidregisterAttributionListener takes an AttributionListener and returns a Subscription. Call unsubscribe() on the subscription when you no longer need updates:
import io.justtrack.AttributionListener
import io.justtrack.attribution.Attribution
val subscription = sdk.registerAttributionListener(object : AttributionListener {
override fun onAttributionReceived(attribution: Attribution) {
val userType = attribution.userType
val campaignName = attribution.campaign.name
// update your app with the new attribution
}
})
// Stop receiving attribution updates, for example in onDestroy()
subscription.unsubscribe()
register(attributionListener:) takes a closure and returns a Subscription. The SDK calls the closure on the main queue. Call unsubscribe() on the subscription when you no longer need updates:
let subscription = sdk.register(attributionListener: { attribution in
let userType = attribution.userType
let campaignName = attribution.campaign.name
// update your app with the new attribution
})
// Stop receiving attribution updates
subscription.unsubscribe()
registerAttributionListener takes a callback and returns an EmitterSubscription. Call remove() on the subscription when you no longer need updates, for example when your component unmounts:
useEffect(() => {
const subscription = JustTrackSdk.registerAttributionListener((attribution) => {
const userType = attribution.userType;
const campaignName = attribution.campaign.name;
// update your app with the new attribution
});
// Stop receiving attribution updates
return () => subscription.remove();
}, []);
The SDK provides similar listeners for retargeting parameters. To learn more, see Retargeting users.