Skip to main content

Get attribution info

Platform:
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.

You can access attribution data in your app through the JustTrackSdk::getAttribution method:

const 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;

If you are only using the justtrack dashboard to keep track of your install sources, you don't need to call getAttribution yourself.

Listen 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.

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.