Custom Settings
All of the native platforms and plugins in Attribution Analytics™ (AA) support a wide array of custom settings that you can use to identify your sessions and events. Collecting additional attributes for all of your app events is extremely important because the collected data can provide valuable insight into how your audience interacts with your app and how this impacts your ability to build effective and profitable advertising campaigns.
Settings for Advanced Tracking
The following table shows a complete list of all the Advanced Tracking setter methods that you can call in the AA SDK. Find the platform/plugin that your app supports below for the appropriate calls.
Setting | Description |
---|---|
App Level Ad Tracking | To allow users to opt-in/opt-out of app level ad tracking, you can call the "setAppAdTracking" method for the SDK. Default is YES (opt-in). |
Use Cookie Tracking | If you want the SDK to use cookie tracking, you can call the "setUseCookieTracking" method for the SDK. Default is NO. Make sure to set the Redirect URL in the app settings online on the TUNE website for your app. iOS Only |
Android SDK Advanced Tracking
Tune.setAppAdTracking(true/false);
iOS SDK Advanced Tracking
[Tune setAppAdMeasurement:YES/NO];
[Tune setUseCookieTracking:YES/NO];
Javascript SDK Advanced Tracking
Javascript does not support any of above-mentioned setter methods.
Windows SDK Adavaned Tracking
Windows Phone does not support any of above-mentioned setter methods.
Adobe Air Plugin Advanced Tracking
mobileAppTracker.setAppAdTracking(true/false);
mobileAppTracker.setUseCookieTracking(true/false);
mobileAppTracker.setRedirectUrl("url");
Cocos2dx Plugin Advanced Tracking
PluginParam pRedirectUrl("http://www.example.com");
PluginTune::setRedirectUrl("url"); &pRedirectUrl, NULL);
PhoneGap Plugin Advanced Tracking
window.plugins.tunePlugin.setAppAdTracking(successCallback, failureCallback, true/false);
window.plugins.tunePlugin.setUseCookieTracking(successCallback, failureCallback, true/false);
window.plugins.tunePlugin.setRedirectUrl(successCallback, failureCallback, "url");
Unity Plugin Advanced Tracking
Tune.SetAppAdTracking(true/false);
Tune.SetUseCookieTracking(true/false);
Xamarin Plugin Advanced Tracking
Android
Tune.Instance.SetAppAdTracking(true/false);
iOS
Tune.SetAppAdTracking(true/false);
Tune.SetUseCookieTracking(true/false);
Tune.SetRedirectUrl("url");
Settings for Device Identifiers
The following table shows a complete list of all the Device ID setter methods that you can call in the SDK. Find the platform/plugin that your app supports below for the appropriate calls.
For information about what data AA collects and how AA protects the privacy of its clients’ data, please visit our Privacy Policy.
Identifier | Type | Description |
---|---|---|
Google Advertising ID | String | To pass in the Google Advertising ID, you can set the ID by calling the setGoogleAdvertisingId method for the SDK. Android only |
iOS IFA | NSUUID | To pass in the Apple IFA, you can set the IFA by calling the setAppleAdvertisingIdentifier:advertisingTrackingEnabled: method for the SDK. iOS only |
iOS IFV | NSUUID | To pass in the Apple IFV, you can set the IFV by calling the setAppleVendorIdentifier: method for the SDK. iOS only |
Auto Collect Apple IFA | BOOL | To auto collect the Apple Advertising Identifier IFA, you will need to call the setShouldAutoCollectAppleAdvertisingIdentifier: method for the SDK. Default is YES. Set to NO to pass in your own. iOS only |
Auto Generate Apple IFV | BOOL | To auto generate the Apple Vendor Identifier, you will need to call the setShouldAutoGenerateAppleVendorIdentifier: method for the SDK. Default is YES. Set to NO to pass in your own. iOS only |
Android SDK Device Identifiers
tune.setGoogleAdvertisingId(gaid, isTrackingLimited);
iOS SDK Device Identifiers
[Tune setAppleAdvertisingIdentifier:[[ASIdentifierManager sharedManager] advertisingIdentifier]
advertisingTrackingEnabled:[[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]];
[Tune setAppleVendorIdentifier:[[UIDevice currentDevice] identifierForVendor]];
[Tune setShouldAutoCollectAppleAdvertisingIdentifier:YES/NO];
[Tune setShouldAutoGenerateAppleVendorIdentifier:YES/NO];
Javascript SDK Device Identifiers
Javascript does not support any of the above-mentioned setter methods.
Windows SDK Device Identifiers
Windows Phone does not support any of the above-mentioned setter methods.
Adobe Air Plugin Device Identifiers
Android
mobileAppTracker.setGoogleAdvertisingId("id");
iOS
mobileAppTracker.setAppleAdvertisingIdentifier(ifa, true/false);
mobileAppTracker.setAppleVendorIdentifier(ifv);
mobileAppTracker.setShouldAutoGenerateAppleVendorIdentifier(true/false);
Cocos2dx Plugin Device Identifiers
Android
PluginParam pGoogleAdvId("1234567890-1234567890-1234567890-12");
PluginParam pIsLATEnabled(true/false);
_pluginMAT->callFuncWithParam("setGoogleAdvertisingId", &pGoogleAdvId, &pIsLATEnabled, NULL);
iOS
PluginParam pAppleAdvId("1234567890-1234567890-1234567890-12");
PluginParam pAdvTrackingEnabled(true/false);
_pluginMAT->callFuncWithParam("setAppleAdvertisingIdentifier", &pAppleAdvId, &pAdvTrackingEnabled, NULL);
PhoneGap Plugin Device Identifiers
Android
mobileAppTracker.setGoogleAdvertisingId(successCallback, failureCallback, gaid, true/false);
iOS
mobileAppTracker.setAppleAdvertisingIdentifier(successCallback, failureCallback, ifa, true/false);
mobileAppTracker.setAppleVendorIdentifier(successCallback, failureCallback, ifv);
mobileAppTracker.setShouldAutoCollectAppleAdvertisingIdentifier(successCallback, failureCallback, true/false);
mobileAppTracker.setShouldAutoGenerateAppleVendorIdentifier(successCallback, failureCallback, true/false);
Unity Plugin Device Identifiers
#if UNITY_5_0
Tune.SetAppleAdvertisingIdentifier(UnityEngine.iOS.Device.advertisingIdentifier, UnityEngine.iOS.Device.advertisingTrackingEnabled);
#else
Tune.SetAppleAdvertisingIdentifier(UnityEngine.iPhone.advertisingIdentifier, UnityEngine.iPhone.advertisingTrackingEnabled);
#endif
Tune.SetAppleVendorIdentifier(UnityEngine.iPhone.vendorIdentifier);
Tune.SetShouldAutoGenerateAppleVendorIdentifier(true/false);
Tune.SetGoogleAdvertisingId(gaid, true/false);
Xamarin Plugin Device Identifiers
Android
MobileAppTracker.Instance.SetGoogleAdvertisingId(gaid, true/false);
iOS
Tune.SetAppleAdvertisingIdentifier (ASIdentifierManager.SharedManager.AdvertisingIdentifier, ASIdentifierManager.SharedManager.IsAdvertisingTrackingEnabled);
Tune.SetAppleVendorIdentifier (UIDevice.CurrentDevice.IdentifierForVendor);
Tune.SetShouldAutoGenerateAppleVendorIdentifier ("vendorId");
Settings for Event Characteristics
The following table shows a complete list of all the Event Characteristics setter methods that you can call in the AA SDK. Find the platform/plugin that your app supports below for the appropriate calls.
Parameter | Type | Description |
---|---|---|
Content ID | String | To pass in the Event Content ID (International Article Number (EAN) when applicable, or other product or content identifier), you can set the Content ID by calling the setEventContentId method for the SDK. |
Content Type | String | To pass in the Event Content Type (for example, "shoes"), you can set the Content Type by calling the setEventContentType method for the SDK. |
Date 1 | Datetime | To pass the date of the Event, you can set the first Date by calling thesetEventDate1 method for the SDK. |
Date 2 | Datetime | To pass a second date for the Event, you can set the second Date by calling the setEventDate2 method for the SDK. |
Level | Integer | To pass in the Event level, you can set the Level by calling thesetEventLevel method for the SDK. |
Quantity | Integer | To pass in a Quantity tied to the Event, you can set the Quantity by calling the setEventQuantity method for the SDK. |
Rating | Double | To pass in a Rating for an Event, you can set the Rating by calling the setEventRating method for the SDK. |
Search String | String | To pass in the Search String tied to an Event, you can set the Search String by calling setEventSearchString method for the SDK. |
Currency Code | Double | The SDK sets the currency to "USD" by default. You can override the default currency by setting the currency using the "setCurrencyCode" method. Please see ISO Currency Codes for a list of acceptable currency codes. |
Custom Attributes | String | To pass in any specific attribute about an event, the SDK provides setEventAttribute1 through setEventAttribute5 methods so you can associate arbitrary string content with any event. |
Android SDK Event Characteristics
TuneEvent tuneEvent = new TuneEvent("event_name")
.withContentId("content_id")
.withContentType("content_type")
.withDate1(date1)
.withDate2(date2)
.withLevel(level)
.withQuantity(quantity)
.withRating(rating)
.withSearchString("search_string")
.withAttribute1("my custom value")
.withAttribute2("my custom value")
.withAttribute3("my custom value")
.withAttribute4("my custom value")
.withAttribute5("my custom value");
tune.measureEvent(tuneEvent);
iOS SDK Event Characteristics
TuneEvent *event = [TuneEvent eventWithName:@"purchase"];
event.contentId = @"5768";
event.contentType = @"shoes";
event.date1 = [NSDate date];
event.date2 = nil;
event.level = 11;
event.quantity = 2;
event.rating = 4.5;
event.searchString = @"black leather shoes";
event.attribute1 = @"men";
event.attribute2 = @"black";
event.attribute3 = @"leather";
event.attribute4 = @"slip-on";
event.attribute5 = @"skid resistant sole";
[Tune measureEvent:event];
Javascript SDK Event Characteristics
MobileAppTracker.setEventContentId("content_id");
MobileAppTracker.setEventContentType("content_type");
MobileAppTracker.setEventDate1(date1);
MobileAppTracker.setEventDate2(date2);
MobileAppTracker.setEventLevel(level);
MobileAppTracker.setEventQuantity(quantity);
MobileAppTracker.setEventRating(rating);
MobileAppTracker.setEventSearchString("search_string");
MobileAppTracker.setEventAttribute1("my custom value");
MobileAppTracker.setEventAttribute2("my custom value");
MobileAppTracker.setEventAttribute3("my custom value");
MobileAppTracker.setEventAttribute4("my custom value");
MobileAppTracker.setEventAttribute5("my custom value");
Windows SDK Event Characteristics
mobileAppTracker.SetEventContentId("content_id");
mobileAppTracker.SetEventContentType("content_type");
mobileAppTracker.SetEventDate1(date1);
mobileAppTracker.SetEventDate2(date2);
mobileAppTracker.SetEventLevel(level);
mobileAppTracker.SetEventQuantity(quantity);
mobileAppTracker.SetEventRating(rating);
mobileAppTracker.SetEventSearchString("search_string");
mobileAppTracker.SetEventAttribute1("my custom value");
mobileAppTracker.SetEventAttribute2("my custom value");
mobileAppTracker.SetEventAttribute3("my custom value");
mobileAppTracker.SetEventAttribute4("my custom value");
mobileAppTracker.SetEventAttribute5("my custom value");
Adobe Air Plugin Event Characteristics
mobileAppTracker.setEventContentId("content_id");
mobileAppTracker.setEventContentType("content_type");
mobileAppTracker.setEventDate1(date1);
mobileAppTracker.setEventDate2(date2);
mobileAppTracker.setEventLevel(level);
mobileAppTracker.setEventQuantity(quantity);
mobileAppTracker.setEventRating(rating);
mobileAppTracker.setEventSearchString("search_string");
mobileAppTracker.setEventAttribute1("my custom value");
mobileAppTracker.setEventAttribute2("my custom value");
mobileAppTracker.setEventAttribute3("my custom value");
mobileAppTracker.setEventAttribute4("my custom value");
mobileAppTracker.setEventAttribute5("my custom value");
Cocos2dx Plugin Event Characteristics
PluginParam pContentId("content_id");
pluginMat->callFuncWithParam("setEventContentId", &pContentId, NULL);
PluginParam pContentType("content_type");
pluginMat->callFuncWithParam("setEventContentType", &pContentType, NULL);
PluginParam pDate1("date1");
pluginMat->callFuncWithParam("setEventDate1", &pDate1, NULL);
PluginParam pDate1("date2");
pluginMat->callFuncWithParam("setEventDate2", &pDate2, NULL);
PluginParam pLevel("level");
pluginMat->callFuncWithParam("setEventLevel", &pLevel, NULL);
PluginParam pQuantity("quantity");
pluginMat->callFuncWithParam("setEventQuantity", &pQuantity, NULL);
PluginParam pRating("rating");
pluginMat->callFuncWithParam("setEventRating", &pRating, NULL);
PluginParam pSearchString("search_string");
pluginMat->callFuncWithParam("setEventSearchString", &pSearchString, NULL);
PluginParam pAttr1("my custom value");
pluginMat->callFuncWithParam("setEventAttribute1", &pAttr1, NULL);
PluginParam pAttr2("my custom value");
pluginMat->callFuncWithParam("setEventAttribute2", &pAttr2, NULL);
PluginParam pAttr3("my custom value");
pluginMat->callFuncWithParam("setEventAttribute3", &pAttr3, NULL);
PluginParam pAttr4("my custom value");
pluginMat->callFuncWithParam("setEventAttribute4", &pAttr4, NULL);
PluginParam pAttr5("my custom value");
pluginMat->callFuncWithParam("setEventAttribute5", &pAttr5, NULL);
PhoneGap Plugin Event Characteristics
mobileAppTracker.setEventContentId(successCallback, failureCallback, "content_id");
mobileAppTracker.setEventContentType(successCallback, failureCallback, "content_type");
mobileAppTracker.setEventDate1(successCallback, failureCallback, date1);
mobileAppTracker.setEventDate2(successCallback, failureCallback, date2);
mobileAppTracker.setEventLevel(successCallback, failureCallback, level);
mobileAppTracker.setEventQuantity(successCallback, failureCallback, quantity);
mobileAppTracker.setEventRating(successCallback, failureCallback, rating);
mobileAppTracker.setEventSearchString(successCallback, failureCallback, "search_string");
mobileAppTracker.setEventAttribute1(successCallback, failureCallback, "my custom value");
mobileAppTracker.setEventAttribute2(successCallback, failureCallback, "my custom value");
mobileAppTracker.setEventAttribute3(successCallback, failureCallback, "my custom value");
mobileAppTracker.setEventAttribute4(successCallback, failureCallback, "my custom value");
mobileAppTracker.setEventAttribute5(successCallback, failureCallback, "my custom value");
Unity Plugin Event Characteristics
TuneItem item1 = new TuneItem();
item1.name = "shoes";
item1.unitPrice = 5;
item1.quantity = 2;
item1.revenue = 10;
item1.attribute1 = "men";
item1.attribute3 = "leather";
TuneItem[] eventItems = { item1 };
TuneEvent tuneEvent = new TuneEvent("purchase");
tuneEvent.revenue = 10;
tuneEvent.currencyCode = "AUD";
tuneEvent.advertiserRefId = "ref222";
tuneEvent.attribute1 = "men";
tuneEvent.attribute2 = "black";
tuneEvent.attribute3 = "leather";
tuneEvent.attribute4 = "slip-on";
tuneEvent.attribute5 = "skid resistant sole";
tuneEvent.contentType = "shoes";
tuneEvent.contentId = "5768";
tuneEvent.date1 = DateTime.UtcNow;
tuneEvent.level = 11;
tuneEvent.quantity = 2;
tuneEvent.rating = 4.5;
tuneEvent.searchString = "black leather shoes";
tuneEvent.eventItems = eventItems;
// transaction state may be set to the value received from the iOS/Android app store.
tuneEvent.transactionState = 1;
#if UNITY_IPHONE
tuneEvent.receipt = "<base64-encoded-receipt-data-from-app-store>";
#endif
Tune.MeasureEvent(tuneEvent);
Xamarin Plugin Event Characteristics
Android
MobileAppTracker.Instance.SetEventContentId("content_id");
MobileAppTracker.Instance.SetEventContentType("content_type");
MobileAppTracker.Instance.SetEventDate1(date1);
MobileAppTracker.Instance.SetEventDate2(date2);
MobileAppTracker.Instance.SetEventLevel(level);
MobileAppTracker.Instance.SetEventQuantity(quantity);
MobileAppTracker.Instance.SetEventRating(rating);
MobileAppTracker.Instance.SetEventSearchString("search_string");
MobileAppTracker.Instance.SetEventAttribute1("my custom value");
MobileAppTracker.Instance.SetEventAttribute2("my custom value");
MobileAppTracker.Instance.SetEventAttribute3("my custom value");
MobileAppTracker.Instance.SetEventAttribute4("my custom value");
MobileAppTracker.Instance.SetEventAttribute5("my custom value");
iOS
MobileAppTracker.SetEventContentId("content_id");
MobileAppTracker.SetEventContentType("content_type");
MobileAppTracker.SetEventDate1(date1);
MobileAppTracker.SetEventDate2(date2);
MobileAppTracker.SetEventLevel(level);
MobileAppTracker.SetEventQuantity(quantity);
MobileAppTracker.SetEventRating(rating);
MobileAppTracker.SetEventSearchString("search_string");
MobileAppTracker.SetEventAttribute1("my custom value");
MobileAppTracker.SetEventAttribute2("my custom value");
MobileAppTracker.SetEventAttribute3("my custom value");
MobileAppTracker.SetEventAttribute4("my custom value");
MobileAppTracker.SetEventAttribute5("my custom value");
Settings for Pre-Loaded Apps
To attribute pre-loaded apps, the TUNE SDK provides a setter method for sending (or "hard-coding") the partner info for attribution and subsequent postbacks. If multiple partners are pre-loading your mobile app, then you can create a partner-specific build of your app for distribution to each publishing partner (where each build includes different partner settings, respective to the particular partner). The partner-specific build is what the partner pre-loads onto the desired devices.
Warning
Make sure you use the setter ONLY for the first app open event, and not subsequent events/requests and MUST be excluded in the build for Google Play Store submission.
Note
If you include the hard-coded attribution parameters for all measure sessions or other requests, then all requests are attributed accordingly (to the same hard-coded partner, such as AT&T). Therefore re-engagement does not work because the attribution information is already present/set, which prevents the SDK from collecting new attribution data.
Android Pre-Loaded Apps
Setter Method
Use the regular TUNE implementation but after initialization, call this setter to enable pre-loaded attribution:
// Required setter
void setPreloadedApp(TunePreloadData preloadData);
The following sample code only includes the attribution parameters with the first measure session request:
public class MyApplication extends TuneApplication {
@Override
public void onCreate() {
super.onCreate();
// Initialize TUNE
Tune tune = Tune.init(getApplicationContext(), "your_advertiser_ID", "your_conversion_key");
// On first app open, set pre-loaded values
// You will need to determine some criteria for this
if (firstAppOpen) {
TunePreloadData preloadData = new TunePreloadData("your_publisher_id") // Required
.withOfferId("your_offer_id") // Rest are optional
.withAgencyId("your_agency_id")
.withPublisherReferenceId("your_publisher_ref_id")
.withPublisherSub1("your_pub_sub1")
.withPublisherSub2("your_pub_sub2")
.withPublisherSub3("your_pub_sub3")
.withPublisherSub4("your_pub_sub4")
.withPublisherSub5("your_pub_sub5")
.withPublisherSubAd("your_pub_sub_ad")
.withPublisherSubAdgroup("your_pub_sub_adgroup")
.withPublisherSubCampaign("your_pub_sub_campaign")
.withPublisherSubKeyword("your_pub_sub_keyword")
.withPublisherSubPublisher("your_pub_sub_publisher")
.withPublisherSubSite("your_pub_sub_site")
.withAdvertiserSubAd("your_ad_sub_ad")
.withAdvertiserSubAdgroup("your_ad_sub_adgroup")
.withAdvertiserSubCampaign("your_ad_sub_campaign")
.withAdvertiserSubKeyword("your_ad_sub_keyword")
.withAdvertiserSubPublisher("your_ad_sub_publisher")
.withAdvertiserSubSite("your_ad_sub_site");
tune.setPreloadedApp(preloadData);
}
}
}
System Properties Method
Copy the below code in your app into a new file TunePreloadSystemData.java
:
class TunePreloadSystemData {
private static final String SYSTEM_PROPERTIES_CLASS_KEY = "android.os.SystemProperties";
private static final String TUNE_BRANCH_PREINSTALL_PROP_KEY = "io.branch.tune.preinstall.apps.path";
public static void getPreinstallSystemData(TuneInternal sTuneInstance) {
if (sTuneInstance != null) {
// check if the SystemProperties has the tune<>branch file path added
String tuneFilePath = checkForTunePreloadInSystem();
if (!TextUtils.isEmpty(tuneFilePath)) {
// after getting the file path get the file contents
readTuneFile(tuneFilePath, sTuneInstance);
}
}
}
private static String checkForTunePreloadInSystem() {
String path = null;
try {
path = (String) Class.forName(SYSTEM_PROPERTIES_CLASS_KEY)
.getMethod("get", String.class).invoke(null, TUNE_BRANCH_PREINSTALL_PROP_KEY);
} catch (Exception e) {
return null;
}
return path;
}
static void readTuneFile(final String tuneFilePath, final TuneInternal sTuneInstance) {
new Thread(new Runnable() {
@Override
public void run() {
try {
final StringBuilder tuneFileContent = new StringBuilder();
JSONObject tuneFileContentJson;
File tuneFile = new File(tuneFilePath);
BufferedReader br = new BufferedReader(new FileReader(tuneFile));
String line;
while ((line = br.readLine()) != null) {
tuneFileContent.append(line);
}
br.close();
tuneFileContentJson = new JSONObject(tuneFileContent.toString().trim());
if (!TextUtils.isEmpty(tuneFileContentJson.toString())) {
getTuneFileContent(tuneFileContentJson, sTuneInstance);
} else {
throw new FileNotFoundException();
}
} catch (FileNotFoundException ignore) {
} catch (IOException ignore) {
} catch (JSONException ignore) {
}
}
}).start();
}
public static void getTuneFileContent(JSONObject tuneFileContentJson,
TuneInternal sTuneInstance) {
// check if the current app package exists in the json
Iterator<String> keys = tuneFileContentJson.keys();
while (keys.hasNext()) {
String key = keys.next();
try {
if (key.equals("apps") && tuneFileContentJson
.get(key) instanceof JSONObject) {
if (tuneFileContentJson.getJSONObject(key)
.get(sTuneInstance.getPackageName()) != null) {
JSONObject tunePreinstallData = tuneFileContentJson
.getJSONObject(key)
.getJSONObject(sTuneInstance.getPackageName());
// find the preinstalls keys and any custom data
Iterator<String> preinstallDataKeys = tunePreinstallData
.keys();
TunePreloadData updatedTunePreloadData = null;
if (!TextUtils
.isEmpty(tunePreinstallData.getString(TuneUrlKeys.PUBLISHER_ID))) {
updatedTunePreloadData = new TunePreloadData(
tunePreinstallData.getString(
TuneUrlKeys.PUBLISHER_ID));
while (preinstallDataKeys.hasNext()) {
String datakey = preinstallDataKeys.next();
if (datakey.equals(TuneUrlKeys.OFFER_ID) && !TextUtils
.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData
.withOfferId(tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.AGENCY_ID) && !TextUtils
.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData
.withAgencyId(tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.PUBLISHER_REF_ID)
&& !TextUtils.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData.withPublisherReferenceId(
tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.PUBLISHER_SUB1) && !TextUtils
.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData
.withPublisherSub1(tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.PUBLISHER_SUB2) && !TextUtils
.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData
.withPublisherSub2(tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.PUBLISHER_SUB3) && !TextUtils
.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData
.withPublisherSub3(tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.PUBLISHER_SUB4) && !TextUtils
.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData
.withPublisherSub4(tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.PUBLISHER_SUB5) && !TextUtils
.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData
.withPublisherSub5(tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.PUBLISHER_SUB_AD)
&& !TextUtils.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData
.withAdvertiserSubAd(tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.PUBLISHER_SUB_ADGROUP)
&& !TextUtils.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData
.withPublisherSubAdgroup(tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.PUBLISHER_SUB_CAMPAIGN)
&& !TextUtils.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData.withPublisherSubCampaign(
tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.PUBLISHER_SUB_KEYWORD)
&& !TextUtils.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData
.withPublisherSubKeyword(tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.PUBLISHER_SUB_PUBLISHER)
&& !TextUtils.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData.withPublisherSubPublisher(
tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.ADVERTISER_SUB_AD)
&& !TextUtils.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData
.withAdvertiserSubAd(tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.ADVERTISER_SUB_ADGROUP)
&& !TextUtils.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData.withAdvertiserSubAdgroup(
tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.ADVERTISER_SUB_CAMPAIGN)
&& !TextUtils.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData.withAdvertiserSubCampaign(
tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.ADVERTISER_SUB_CAMPAIGN)
&& !TextUtils.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData.withAdvertiserSubCampaign(
tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.ADVERTISER_SUB_KEYWORD)
&& !TextUtils.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData.withAdvertiserSubKeyword(
tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.ADVERTISER_SUB_PUBLISHER)
&& !TextUtils.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData.withAdvertiserSubPublisher(
tunePreinstallData.get(datakey)
.toString());
} else if (datakey.equals(TuneUrlKeys.ADVERTISER_SUB_SITE)
&& !TextUtils.isEmpty(tunePreinstallData.get(datakey)
.toString())) {
updatedTunePreloadData
.withAdvertiserSubSite(tunePreinstallData.get(datakey)
.toString());
}
}
// set the final TunePreloadData
sTuneInstance.setPreloadedAppData(updatedTunePreloadData);
}
}
}
} catch (Exception ignore) {
ignore.printStackTrace();
}
}
}
}
Once added, then call the below method in place of the #setPreloadedAppData()
:
TunePreloadSystemData.getPreinstallSystemData(TuneInternal.getInstance());
OEM Side Setup
{
"apps": {
"com.tune.test": {
"publisher_id": "test_publisher_id",
"publisher_sub_campaign": "test_publisher_sub_campaign"
}
}
}
The supported keys are:
- publisher_id
- offer_id
- agency_id
- publisher_ref_id
- publisher_sub_publisher
- publisher_sub_site
- publisher_sub_campaign
- publisher_sub_adgroup
- publisher_sub_ad
- publisher_sub_keyword
- publisher_sub1
- publisher_sub2
- publisher_sub3
- publisher_sub4
- publisher_sub5
- advertiser_sub_publisher
- advertiser_sub_site
- advertiser_sub_campaign
- advertiser_sub_adgroup
- advertiser_sub_ad
- advertiser_sub_keyword
The file path format can be seen in Pre-Install Analytics.
iOS Pre-Loaded Apps
The TUNE iOS SDK provides a separate class TunePreloadData to hold the publisher info (such as publisher id, offer id, publisher ref id, etc.). An object of TunePreloadData class can then be provided to the Tune class by using the following setter method:
+ (void)setPreloadData:(TunePreloadData *)preloadData;
The following sample code shows how you set the publisher info (note that publisher id is required; all other properties are optional):
TunePreloadData *pd = [TunePreloadData preloadDataWithPublisherId:@"112233"];
pd.offerId = @"offer_id";
pd.agencyId = @"agency_id";
pd.publisherReferenceId = @"publisher_ref_id";
pd.publisherSub1 = @"pub_sub1";
pd.publisherSub2 = @"pub_sub2";
pd.publisherSub3 = @"pub_sub3";
pd.publisherSub4 = @"pub_sub4";
pd.publisherSub5 = @"pub_sub5";
pd.publisherSubAd = @"pub_sub_ad";
pd.publisherSubAdgroup = @"pub_sub_adgroup";
pd.publisherSubCampaign = @"pub_sub_campaign";
pd.publisherSubKeyword = @"pub_sub_keyword";
pd.publisherSubPublisher = @"pub_sub_publisher";
pd.publisherSubSite = @"pub_sub_site";
pd.advertiserSubAd = @"ad_sub_ad";
pd.advertiserSubAdgroup = @"ad_sub_adgroup";
pd.advertiserSubCampaign = @"ad_sub_campaign";
pd.advertiserSubKeyword = @"ad_sub_keyword";
pd.advertiserSubPublisher = @"ad_sub_publisher";
pd.advertiserSubSite = @"ad_sub_site";
[Tune setPreloadData:pd];
[Tune measureSession];
Unity Plugin Pre-Loaded Apps
The TUNE Unity plugin provides a separate structure TunePreloadData to hold the publisher info (such as publisher id, offer id, publisher ref id, etc.). An instance of TunePreloadData structure can then be provided to the TuneBinding setter method:
public static void SetPreloadedApp(MATPreloadData preloadData)
The following sample code shows how you set the publisher info (note that publisher id is required; all other properties are optional):
MATPreloadData pd = new MATPreloadData("112233");
pd.offerId = @"offer_id";
pd.agencyId = @"agency_id";
pd.publisherReferenceId = @"publisher_ref_id";
pd.publisherSub1 = @"pub_sub1";
pd.publisherSub2 = @"pub_sub2";
pd.publisherSub3 = @"pub_sub3";
pd.publisherSub4 = @"pub_sub4";
pd.publisherSub5 = @"pub_sub5";
pd.publisherSubAd = @"pub_sub_ad";
pd.publisherSubAdgroup = @"pub_sub_adgroup";
pd.publisherSubCampaign = @"pub_sub_campaign";
pd.publisherSubKeyword = @"pub_sub_keyword";
pd.publisherSubPublisher = @"pub_sub_publisher";
pd.publisherSubSite = @"pub_sub_site";
pd.advertiserSubAd = @"ad_sub_ad";
pd.advertiserSubAdgroup = @"ad_sub_adgroup";
pd.advertiserSubCampaign = @"ad_sub_campaign";
pd.advertiserSubKeyword = @"ad_sub_keyword";
pd.advertiserSubPublisher = @"ad_sub_publisher";
pd.advertiserSubSite = @"ad_sub_site";
Tune.SetPreloadedApp(pd);
Tune.MeasureSession();
Settings for User Characteristics
The following table shows a complete list of all the User Characteristics setter methods that you can call in the TUNE SDK. Find the platform/plugin that your app supports below for the appropriate calls.
Parameter | Description |
---|---|
Currency Code | The SDK sets the currency to "USD" by default. You can override the default currency by setting the currency using the "setCurrencyCode" method. Please see ISO Currency Codes for a list of acceptable currency codes. |
Existing User | If you have pre-existing users before adding the TUNE SDK, you can flag existing users by setting to "true" to avoid counting existing users as new users. |
User Name | If you have a registration or login event, you want to pass in the user’s name, you can set User Name by calling the "setUserName" method for the SDK. As this constitutes PII, the returned value for this parameter is not stored or available in the UI in its raw form, only its hashed versions. |
User Email | If you have a registration or login event, you want to pass in the user’s email address, you can set User Email by calling the "setUserEmail" method for the SDK. As this constitutes PII, the returned value for this parameter is not stored or available in the UI in its raw form, only its hashed versions. |
User Phone Number | If you have a registration or reservation event, you want to pass in the user’s phone number, you can set User Phone Number by calling the "setPhoneNumber" method for the SDK. As this constitutes PII, the returned value for this parameter is not stored or available in the UI in its raw form, only its hashed versions. |
Age | To pass in the user’s age, you can set Age by calling the "setAge" method for the SDK. If the user's age is under 13, TUNE automatically enforces COPPA and limits functionality for those users. |
Privacy Protection Due to Age | Sets privacy protection. When set to true/YES, TUNE treats this user as age < 13 regardless and limits functionality for those users. When set to false/NO, the default, TUNE falls back to the user's age and enforces COPPA accordingly. Android v4.13+ and iOS v4.14+ only |
Gender | To pass in the user’s gender, you can set Gender by calling the "setGender" method for the SDK. |
Location | To pass in the user’s current GPS location, you can set their Location by calling the "setLocation" method for the SDK. |
Jailbroken Device | To pass in whether or not a user’s device has been jailbroken, you can set Jailbroken by calling the "setJailBroken" method for the SDK. iOS only |
Auto Detect Jailbroken Device | To auto detect whether or not a user’s device has been jailbroken, you will need to call the "setShouldAutoDetectJailBroken" method for the SDK. Default is YES. iOS only |
COPPA Requirements
In the US, targeting advertising to end users under 13 triggers requirements under the Children’s Online Privacy Protection Act or "COPPA." These include obtaining verified parental consent. For more, see the FTC’s 6 Steps to COPPA compliance.
When a user is under 13, such users are treated as follows:
- Automatic exclusion of an under 13 user from any segment exported via our Audiences feature.
- Automatic exclusion of an under 13 user from receiving Push Messaging Campaigns via our In-App Marketing product.
- There is no exclusion of an under 13 user from being measured by Attribution Analytics (as one of the "activities necessary for the site or service to maintain or analyze its functioning," attribution is an exception to COPPA).
setAge
vs setPrivacyProtectedDueToAge
Both the setAge
and setPrivacyProtectedDueToAge
setters can be used to enforce COPPA in different ways.
setAge
- If the user's age is set to under 13, TUNE automatically enforces COPPA and limits functionality for those users.setPrivacyProtectedDueToAge
- When set to true/YES, TUNE treats this user as age under 13 regardless, enforces COPPA, and limits functionality for those users. This setter is useful for countries in which the COPPA age is different than 13 years of age. Available in Android v4.13+ only.
Critical Privacy Outcomes
Please be aware of the following outcomes for privacy if you use both setters simultaneously.
setAge() | setPrivacyProtectedDueToAge() | isPrivacyProtected |
---|---|---|
Not Called | Not Called | ❌ False/No |
Not Called | True/Yes | ✅ True/Yes |
Not Called | False/No | ❌ False/No |
COPPA Age | Not Called | ✅ True/Yes |
COPPA Age | True/Yes | ✅ True/Yes |
COPPA Age | False/No | ✅ True/Yes |
Not COPPA Age | Not Called | ❌ False/No |
Not COPPA Age | True/Yes | ✅ True/Yes |
Not COPPA Age | False/No | ❌ False/No |
For more information on COPPA and TUNE requirements, please see Restricting End User Data Processing.
Android SDK User Characteristics
Tune.getInstance().setCurrencyCode("ISO_currencyCode");
Tune.getInstance().setExistingUser(true/false);
Tune.getInstance().setUserEmail(user_Email);
Tune.getInstance().setUserName(user_Name);
Tune.getInstance().setPhoneNumber("1234567890");
Tune.getInstance().setAge(user_age);
Tune.getInstance().setPrivacyProtectionDueToAge(true/false);
Tune.getInstance().setGender(user_gender);
Tune.getInstance().setLocation(user_location);
iOS SDK User Characteristics
[Tune setCurrencyCode:@"ISO_currencyCode"];
[Tune setExistingUser:YES/NO];
[Tune setUserEmail:user_Email];
[Tune setUserName:user_Name];
[Tune setPhoneNumber:@"1234567890"];
[Tune setAge:user_age];
[Tune setPrivacyProtectedDueToAge:YES/NO];
[Tune setGender:user_gender];
TuneLocation *loc = [TuneLocation new];
loc.latitude = @(user_latitude);
loc.longitude = @(user_longitude);
loc.altitude = @(user_altitude);
[Tune setLocation:loc];
[Tune setJailbroken:jailbroken];
[Tune setShouldAutoDetectJailbroken:YES/NO];
Javascript SDK User Characteristics
MobileAppTracker.setCurrencyCode("ISO_currencyCode");
MobileAppTracker.setExistingUser(true/false);
MobileAppTracker.setUserEmail(user_Email);
MobileAppTracker.setUserName(user_Name);
MobileAppTracker.setPhoneNumber("1234567890");
MobileAppTracker.setAge(user_age);
MobileAppTracker.setGender(user_gender);
MobileAppTracker.setAltitude(user_altitude);
MobileAppTracker.setLatitude(user_latitude);
MobileAppTracker.setLongitude(user_longitude);
Windows SDK User Characteristics
mobileAppTracker.SetCurrencycode("ISO_currencyCode");
mobileAppTracker.SetExistingUser(true/false);
mobileAppTracker.SetUserEmail(user_Email);
mobileAppTracker.SetUserName(user_Name);
mobileAppTracker.SetPhoneNumber("1234567890");
mobileAppTracker.SetAge(user_age);
mobileAppTracker.SetGender(user_gender);
mobileAppTracker.SetAltitude(user_altitude);
mobileAppTracker.SetLatitude(user_latitude);
mobileAppTracker.SetLongitude(user_longitude);
mobileAppTracker.SetEventAttribute[1-5]("event_attribute[1-5]")
Adobe Air Plugin User Characteristics
tune.setCurrencyCode("ISO_currencyCode");
tune.setExistingUser(true/false);
tune.setUserEmail(user_Email);
tune.setUserName(user_Name);
tune.setPhoneNumber("1234567890");
tune.setAge(user_age);
tune.setGender(user_gender);
tune.setJailbroken(true/false);
tune.setShouldAutodetectJailbroken(true/false);
Cocos2dx Plugin User Characteristics
PluginParam pCurrencyCode("ISO currencyCode");
_pluginMAT->callFuncWithParam("setCurrencyCode", &pCurrencyCode, NULL);
PluginParam pExistingUser(true/false);
_pluginMAT->callFuncWithParam("setExistingUser", &pExistingUser, NULL);
PluginParam pUserEmail(user_Email);
_pluginMat->callFuncWithParam("setUserEmail", &pUserEmail, NULL);
PluginParam pUserName(user_name);
_pluginMat->callFuncWithParam("setUserName", &pUserName, NULL);
PluginParam pPhoneNumber("1234567890");
_pluginMat->callFuncWithParam("setPhoneNymber", &pPhoneNumber, NULL);
PluginParam pAge(user_age);
_pluginMAT->callFuncWithParam("setAge", &pAge, NULL);
PluginParam pGender(0 for male/1 for female);
_pluginMAT->callFuncWithParam("setGender", &pGender, NULL);
PluginParam pJailbroken(true/false);
_pluginMAT->callFuncWithParam("setJailbroken", &pJailbroken, NULL);
PluginParam pAutoDetectJailbroken(true/false);
_pluginMAT->callFuncWithParam("setShouldAutoDetectJailbroken", &pAutoDetectJailbroken, NULL);
PhoneGap Plugin User Characteristics
mobileAppTracker.setCurrencyCode(successCallback, failureCallback, "ISO_currencyCode");
mobileAppTracker.setExistingUser(successCallback, failureCallback, true/false);
mobileAppTracker.setUserEmail(successCallback, failureCallback, user_Email);
mobileAppTracker.setUserName(successCallback, failureCallback, user_Name);
mobileAppTracker.setPhoneNumber(successCallback, failureCallback, "1234567890");
mobileAppTracker.setAge(successCallback, failureCallback, user_age);
mobileAppTracker.setGender(successCallback, failureCallback, user_gender);
mobileAppTracker.setAltitude(successCallback, failureCallback, user_altitude);
mobileAppTracker.setLatitude(successCallback, failureCallback, user_latitude);
mobileAppTracker.setLongitude(successCallback, failureCallback, user_longitude);
mobileAppTracker.setJailbroken(successCallback, failureCallback, true/false);
mobileAppTracker.setShouldAutodetectJailbroken(successCallback, failureCallback, true/false);
Unity Plugin User Characteristics
Tune.SetCurrencyCode("ISO_currencyCode");
Tune.SetExistingUser(true/false);
Tune.SetUserEmail(user_Email);
Tune.SetUserName(user_Name);
Tune.SetPhoneNumber("1234567890");
Tune.SetAge(user_age);
Tune.SetGender(user_gender);
Tune.SetAltitude(user_altitude);
Tune.SetLatitude(user_latitude);
Tune.SetLongitude(user_longitude);
Tune.SetJailbroken(true/false);
Tune.SetShouldAutodetectJailbroken(true/false);
Xamarin Plugin User Characteristics
Android
MobileAppTracker.Instance.SetCurrencyCode("ISO_currencyCode");
MobileAppTracker.Instance.SetExistingUser(true/false);
MobileAppTracker.Instance.SetUserEmail(user_Email);
MobileAppTracker.Instance.SetUserName(user_Name);
MobileAppTracker.Instance.SetPhoneNumber("1234567890");
MobileAppTracker.Instance.SetAge(user_age);
MobileAppTracker.Instance.SetGender(user_gender);
MobileAppTracker.Instance.SetAltitude(user_altitude);
MobileAppTracker.Instance.SetLatitude(user_latitude);
MobileAppTracker.Instance.SetLongitude(user_longitude);
MobileAppTracker.Instance.SetJailbroken(true/false);
MobileAppTracker.Instance.SetShouldAutodetectJailbroken(true/false);
iOS
Tune.SetCurrencyCode ("GBP");
Tune.SetExistingUser (false);
Tune.SetUserEmail ("[email protected]");
Tune.SetUserName ("tempUserName");
Tune.SetPhoneNumber ("123-456-7890");
Tune.SetAge (99);
Tune.SetGender (0); // 0 for male, 1 for female, 2 for other
TuneLocation sampleLocation = new TuneLocation ();
sampleLocation.SetLatitude (latitude);
sampleLocation.SetLongitude (longitude);
sampleLocation.SetAltitude (altitude);
Tune.SetLocation (sampleLocation);
Tune.SetJailbroken (false);
Tune.SetShouldAutoDetectJailbroken (true);
Settings for User IDs
The following table shows a complete list of all the User ID setter methods that you can call in the TUNE SDK. Find the platform/plugin that your app supports below for the appropriate calls.
ID | Description |
---|---|
User ID | The "User ID" is a globally unique identifier that matches with your internal systems. If you have a user ID of your own that you wish to measure, pass it in as a String with setUserId. This populates the "User ID" field in our reporting, and also as a postback variable {user_id}. Setting the user ID does not fire a call of its own, it has to be passed in before a measureSession or measureAction call. |
Facebook User ID | For Facebook-specific user data, you can pass in the Facebook User ID to AA by calling "setFacebookUserId". |
Google User ID | For Google-specific user data, you can pass in the Google User ID to AA by calling "setGoogleUserId". |
Twitter User ID | For Twitter-specific user data, you can pass in the Twitter User ID to AA by calling "setTwitterUserId". |
TRUSTe TPID | If you are integrating with the TRUSTe SDK, you can set the TRUSTe TPID by calling the "setTRUSTeID" method for the SDK. |
Facebook User ID
If your app uses Facebook for authentication, you may pass the Facebook user ID to AA for reconciliation and reporting. This user ID is app-scoped so it will not be the same across apps.
After your user has authenticated with Facebook, a Facebook access token is available which can be used to retrieve the Facebook user ID.
Google User ID
If your app uses Google for authentication, you may pass the Google user ID to AA for reconciliation and reporting.
After your user has authenticated with Google, the Plus API can be used to retrieve the Google user ID.
Twitter User ID
If your app uses Twitter for authentication, you may pass the Twitter user ID to AA for reconciliation and reporting.
After your user has authenticated with Twitter, a Twitter session is available which can be used to retrieve the Twitter user ID.
Android SDK + Facebook User ID Example
Here is an example of using the Facebook Android SDK 4.0 to retrieve the user info using the access token, getting the "id" field from the returned JSON and passing it to AA as the Facebook user ID:
// Try to get a Facebook access token
AccessToken token = AccessToken.getCurrentAccessToken();
if (token != null) {
// Token is available, create Graph API request for user info
GraphRequest request = GraphRequest.newMeRequest(
token,
// Define a callback that sets the Facebook user ID in AA
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject jsonObject, GraphResponse graphResponse) {
if (jsonObject != null) {
Tune.getInstance().setFacebookUserId(jsonObject.optString("id"));
}
}
}
);
// Execute the API request
request.executeAsync();
}
Android SDK + Google User ID
Here is an example of using the Google Play Services SDK's Google Sign In to retrieve the user ID using the connected GoogleSignInAccount object:
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
String googleUserId = acct.getId();
Tune.getInstance().setGoogleUserId(googleUserId);
}
Android SDK + Twitter User ID
Here is an example of using the Twitter Android SDK to retrieve the user ID using the active session, converting it from a long to String and passing it to AA as the Twitter user ID:
TwitterSession session = Twitter.getSessionManager().getActiveSession();
Tune.getInstance().setTwitterUserId(Long.toString(session.getUserId()));
Android SDK User ID Setters
Tune.getInstance().setUserId("custom_user_id");
Tune.getInstance().setFacebookUserId("fb_app_user_id");
Tune.getInstance().setGoogleUserId("google_user_id");
Tune.getInstance().setTwitterUserId("twitter_user_id");
Tune.getInstance().setTRUSTeId("your_truste_id");
iOS SDK + Facebook User ID
Here is an example of using the Facebook iOS SDK 4.0 to retrieve the userID property from the access token and passing it to AA as the Facebook user ID:
Enable access-token-changed notification generation in AppDelegate:
[FBSDKProfile enableUpdatesOnAccessTokenChange:YES];
Add a listener for access-token-changed notification and handle the access-token-changed notification:
- (void)_accessTokenChanged:(NSNotification *)notification
{
FBSDKAccessToken *token = notification.userInfo[FBSDKAccessTokenChangeNewKey];
[Tune setFacebookUserId:token.userID];
}
Once the user’s Facebook login is successful, the Facebook user ID can be provided to Tune in the access-token-changed notification handler.
iOS SDK + Google User ID
Here is an example of that shows userID retrieval when using GooglePlus.framework and GoogleOpenSource.framework:
Setup GPPSignIn instance
[GPPSignIn sharedInstance].clientID = @"your_google_plus_client_id";
[GPPSignIn sharedInstance].shouldFetchGoogleUserID = YES;
[GPPSignIn sharedInstance].delegate = self;
Handle delegate callback
- (void)finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error {
if (!error) {
NSString *googleUserId = [[GPPSignIn sharedInstance] userID];
[Tune setGoogleUserId:googleUserId];
}
}
When Google Sign In is successful the Google user id can be provided to Tune in the GPPSignInDelegate callback.
iOS SDK + Twitter User ID
Here is an example that shows userID retrieval when using Fabric.framework and TwitterKit.framework:
Setup TwitterKit
In AppDelegate.m:
[Fabric with:@[TwitterKit]];
In ViewController.m:
TWTRLogInButton *logInButton = [TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession *session, NSError *error) {
[Tune setTwitterUserId:session.userID];
}];
logInButton.center = self.view.center;
[self.view addSubview:logInButton];
iOS SDK Setters
[Tune setUserId:@"some_user_id"];
[Tune setFacebookUserId:@"facebook_user_id"];
[Tune setGoogleUserId:@"google_user_id"];
[Tune setTwitterUserId:@"twitter_user_id"];
[Tune setTrusteTPID:@"truste_tpid"];
Javascript SDK Setters
MobileAppTracker.setUserId("custom_user_id");
MobileAppTracker.setFacebookUserId("fb_app_user_id");
MobileAppTracker.setGoogleUserId("google_user_id");
MobileAppTracker.setTwitterUserId("twitter_user_id");
MobileAppTracker.setTrusteTPId("your_truste_id");
Windows SDK Setters
mobileAppTracker.SetUserId("custom_user_id");
mobileAppTracker.SetFacebookUserId("fb_app_user_id");
mobileAppTracker.SetGoogleUserId("google_user_id");
mobileAppTracker.SetTwitterUserId("twitter_user_id");
mobileAppTracker.SetTRUSTeId("your_truste_id");
Adobe Air Plugin Setters
mobileAppTracker.setUserId("custom_user_id");
mobileAppTracker.setFacebookUserId("fb_app_user_id");
mobileAppTracker.setGoogleUserId("google_user_id");
mobileAppTracker.setTwitterUserId("twitter_user_id");
mobileAppTracker.setTRUSTeId("your_truste_id");
Cocos2dx Plugin Setters
PluginParam pUserId("custom_user_id");
_pluginMAT->callFuncWithParam("setUserId", &pUserId, NULL);
PluginParam pFacebookUserId("fb_app_user_id");
_pluginMAT->callFuncWithParam("setFacebookUserId", &pFacebookUserId, NULL);
PluginParam pGoogleUserId("google_user_id");
_pluginMAT->callFuncWithParam("setGoogleUserId", &pGoogleUserId, NULL);
PluginParam pTwitterUserId("twitter_user_id");
_pluginMAT->callFuncWithParam("setTwitterUserId", &pTwitterUserId, NULL);
PluginParam pTrusteId("your_truste_id");
_pluginMAT->callFuncWithParam("setTRUSTeId", &pTrusteId, NULL);
PhoneGap Plugin Setters
mobileAppTracker.setUserId("custom_user_id");
mobileAppTracker.setFacebookUserId("fb_app_user_id");
mobileAppTracker.setGoogleUserId("google_user_id");
mobileAppTracker.setTwitterUserId("twitter_user_id");
mobileAppTracker.setTrusteTPID("your_truste_id");
Unity Plugin Setters
Tune.SetUserId("custom_user_id");
Tune.SetFacebookUserId("fb_app_user_id");
Tune.SetGoogleUserId("google_user_id");
Tune.SetTwitterUserId("twitter_user_id");
Tune.SetTRUSTeId("your_truste_id");
Xamarin Setters
Android
MobileAppTracker.Instance.SetUserId("custom_user_id");
MobileAppTracker.Instance.SetFacebookUserId("fb_app_user_id");
MobileAppTracker.Instance.SetGoogleUserId("google_user_id");
MobileAppTracker.Instance.SetTwitterUserId("twitter_user_id");
MobileAppTracker.Instance.SetTRUSTeId("your_truste_id");
iOS
Tune.SetTRUSTeId("trusteTPID");
Tune.SetUserId ("userId");
Tune.SetFacebookUserId ("facebookId");
Tune.SetGoogleUserId ("googleId");
Tune.SetTwitterUserId ("twitterId");
Updated 8 months ago