com.mobileapptracker
public class MobileAppTracker extends Object
Modifier and Type | Field and Description |
---|---|
protected MATEventQueue |
eventQueue |
static int |
GENDER_FEMALE |
static int |
GENDER_MALE |
protected boolean |
isRegistered |
protected MATTestRequest |
matRequest |
protected MATResponse |
matResponse |
protected Context |
mContext |
protected BroadcastReceiver |
networkStateReceiver |
Modifier | Constructor and Description |
---|---|
protected |
MobileAppTracker() |
Modifier and Type | Method and Description |
---|---|
protected void |
addEventToQueue(String link,
String eventItems,
String action,
double revenue,
String currency,
String refId,
String inAppPurchaseData,
String inAppSignature,
String eventAttribute1,
String eventAttribute2,
String eventAttribute3,
String eventAttribute4,
String eventAttribute5,
boolean shouldBuildData,
Date runDate) |
protected void |
dumpQueue() |
String |
getAction()
Gets the action of the event
|
String |
getAdvertiserId()
Gets the MAT advertiser ID.
|
int |
getAge()
Gets the user age set.
|
double |
getAltitude()
Gets the device altitude.
|
String |
getAndroidId()
Gets the ANDROID_ID of the device
|
String |
getAndroidIdMd5()
Gets the MD5 hash of the ANDROID_ID of the device
|
String |
getAndroidIdSha1()
Gets the SHA-1 hash of the ANDROID_ID of the device
|
String |
getAndroidIdSha256()
Gets the SHA-256 hash of the ANDROID_ID of the device
|
String |
getAppName()
Gets the app name
|
int |
getAppVersion()
Gets the app version
|
protected String |
getAttributionId(ContentResolver contentResolver)
Facebook's code for retrieving Facebook cookie value
|
String |
getConnectionType()
Gets the connection type (mobile or WIFI);.
|
String |
getCountryCode()
Gets the ISO 639-1 country code
|
String |
getCurrencyCode()
Gets the ISO 4217 currency code.
|
String |
getDeviceBrand()
Gets the device brand/manufacturer (HTC, Apple, etc)
|
String |
getDeviceCarrier()
Gets the device carrier if any
|
String |
getDeviceId()
Gets the Device ID, also known as IMEI/MEID, if any
|
String |
getDeviceModel()
Gets the device model name
|
String |
getEventAttribute1() |
String |
getEventAttribute2() |
String |
getEventAttribute3() |
String |
getEventAttribute4() |
String |
getEventAttribute5() |
String |
getEventId()
Gets the last event id set.
|
String |
getEventName()
Gets the last event name set.
|
boolean |
getExistingUser()
Gets value previously set of existing user or not.
|
String |
getFacebookUserId()
Gets the Facebook user ID previously set.
|
int |
getGender()
Gets the user gender set.
|
String |
getGoogleAdvertisingId()
Gets the Google Play Services Advertising ID.
|
String |
getGoogleUserId()
Gets the Google user ID previously set.
|
String |
getInstallDate()
Gets the date of app install
|
String |
getInstallLogId()
Gets the MAT install log ID
|
String |
getInstallReferrer()
Gets the Google Play INSTALL_REFERRER
|
static MobileAppTracker |
getInstance()
Get existing MAT singleton object
|
String |
getLanguage()
Gets the language of the device
|
String |
getLastOpenLogId()
Gets the last MAT open log ID
|
double |
getLatitude()
Gets the device latitude.
|
boolean |
getLimitAdTrackingEnabled()
Get whether the user has limit ad tracking enabled or not.
|
double |
getLongitude()
Gets the device longitude.
|
String |
getMacAddress()
Gets the MAC address of device
|
String |
getMatId()
Gets the MAT ID generated on install
|
String |
getMCC()
Gets the mobile country code.
|
String |
getMNC()
Gets the mobile network code.
|
String |
getOpenLogId()
Gets the first MAT open log ID
|
String |
getOsVersion()
Gets the Android OS version
|
String |
getPackageName()
Gets the app package name
|
String |
getPluginName()
Get SDK plugin name used
|
String |
getReferralSource()
Gets the package name of the app that started this Activity, if any
|
String |
getReferralUrl()
Gets the url scheme that started this Activity, if any
|
String |
getRefId()
Gets the advertiser ref ID.
|
Double |
getRevenue()
Gets the revenue amount set
|
String |
getScreenDensity()
Gets the screen density of the device
|
String |
getScreenSize()
Gets the screen size of the device
|
String |
getSDKVersion()
Gets the MAT SDK version
|
String |
getSiteId()
Gets the MAT site ID set
|
String |
getTRUSTeId()
Gets the TRUSTe ID set
|
String |
getTwitterUserID()
Gets the Twitter user ID previously set.
|
String |
getUpdateLogId()
Gets the MAT update log ID
|
String |
getUserAgent()
Gets the device browser user agent
|
String |
getUserEmail()
Gets the custom user email.
|
String |
getUserId()
Gets the custom user ID.
|
String |
getUserName()
Gets the custom user name.
|
static void |
init(Context context,
String advertiserId,
String key)
Instantiates a new MobileAppTracker with device ID/MAC address collection by default.
|
static void |
init(Context context,
String advertiserId,
String key,
boolean collectDeviceId,
boolean collectMacAddress)
Instantiates a new MobileAppTracker singleton.
|
protected void |
initAll(Context context,
String advertiserId,
String key,
boolean collectDeviceId,
boolean collectMacAddress)
Private initialization function for MobileAppTracker.
|
boolean |
isOnline(Context context)
Returns true if an Internet connection is detected.
|
protected void |
makeRequest(String link,
String eventItems,
String action,
double revenue,
String currency,
String refId,
String iapData,
String iapSignature,
String eventAttribute1,
String eventAttribute2,
String eventAttribute3,
String eventAttribute4,
String eventAttribute5,
boolean shouldBuildData) |
void |
setAge(int age)
Sets the user's age.
|
void |
setAllowDuplicates(boolean allow)
Enables acceptance of duplicate installs from this device.
|
void |
setAltitude(double altitude)
Sets the device altitude.
|
void |
setCurrencyCode(String currency_code)
Sets the ISO 4217 currency code.
|
void |
setDebugMode(boolean debug)
Turns debug mode on or off, under tag "MobileAppTracker".
|
void |
setEventAttribute1(String value) |
void |
setEventAttribute2(String value) |
void |
setEventAttribute3(String value) |
void |
setEventAttribute4(String value) |
void |
setEventAttribute5(String value) |
void |
setExistingUser(boolean existing)
Sets whether app was previously installed prior to version with MAT SDK
|
void |
setFacebookUserId(String fb_user_id)
Sets the user ID to associate with Facebook
|
void |
setGender(int gender)
Sets the user gender.
|
void |
setGoogleAdvertisingId(String adId)
Sets the Google Play Services Advertising ID
|
void |
setGoogleUserId(String google_user_id)
Sets the user ID to associate with Google
|
void |
setInstallReferrer(String referrer)
Overrides the Google Play INSTALL_REFERRER received
|
void |
setLatitude(double latitude)
Sets the device latitude.
|
void |
setLimitAdTrackingEnabled(boolean isLATEnabled)
Sets whether the app user has chosen to limit ad tracking.
|
void |
setLongitude(double longitude)
Sets the device longitude.
|
void |
setMATResponse(MATResponse response)
Register a MATResponse interface to receive server response callback
|
void |
setPackageName(String package_name)
Sets the app package name
|
void |
setPluginName(String plugin_name)
Set the name of plugin used, if any
|
void |
setReferralSources(Activity act)
Get referral sources from Activity
|
void |
setSiteId(String site_id)
Sets the MAT site ID to specify which app to attribute to
|
String |
setTracking(String publisherAdvertiserId,
String targetPackageName,
String publisherId,
String campaignId,
boolean doRedirect)
Insert referring app info into target app's content provider.
|
void |
setTRUSTeId(String tpid)
Sets the TRUSTe ID, should generate via their SDK
|
void |
setTwitterUserId(String twitter_user_id)
Sets the user ID to associate with Twitter
|
void |
setUseAndroidIdMd5()
Enable sending ANDROID_ID as MD5 hash in request - removes raw ANDROID_ID
|
void |
setUseAndroidIdSha1()
Enable sending ANDROID_ID as SHA-1 hash in request - removes raw ANDROID_ID
|
void |
setUseAndroidIdSha256()
Enable sending ANDROID_ID as SHA-256 hash in request - removes raw ANDROID_ID
|
void |
setUserEmail(String user_email)
Sets the custom user email.
|
void |
setUserId(String user_id)
Sets the custom user ID.
|
void |
setUserName(String user_name)
Sets the custom user name.
|
int |
trackAction(String event)
Tracking event function, track events by event ID or name.
|
int |
trackAction(String event,
double revenue)
Tracking event function, track events by event ID or name, revenue.
|
int |
trackAction(String event,
double revenue,
String currency)
Tracking event function, track events by event ID or name, revenue and currency.
|
int |
trackAction(String event,
double revenue,
String currency,
String refId)
Tracking event function, track events by event ID or name, revenue, currency, and advertiser ref ID.
|
int |
trackAction(String event,
double revenue,
String currency,
String refId,
String inAppPurchaseData,
String inAppSignature)
Tracking event function, track events by event ID or name, revenue, currency,
advertiser ref ID, and in-app purchase data and signature for purchase verification.
|
int |
trackAction(String event,
List<MATEventItem> list)
Tracking event function, track events by event ID or name, and a list of event items.
|
int |
trackAction(String event,
List<MATEventItem> list,
double revenue,
String currency,
String refId)
Tracking event function, track events by event ID or name, a list of event items,
revenue, currency, and advertiser ref ID.
|
int |
trackAction(String event,
List<MATEventItem> list,
double revenue,
String currency,
String refId,
String inAppPurchaseData,
String inAppSignature)
Tracking event function, track events by event ID or name, a list of event items,
and in-app purchase data and signature for purchase verification.
|
int |
trackAction(String event,
MATEventItem eventItem)
Tracking event function, track events by event ID or name, and event item.
|
int |
trackAction(String event,
MATEventItem eventItem,
double revenue,
String currency,
String refId)
Tracking event function, track events by event ID or name, event item, revenue, currency, and advertiser ref ID.
|
int |
trackAction(String event,
MATEventItem eventItem,
double revenue,
String currency,
String refId,
String inAppPurchaseData,
String inAppSignature)
Tracking event function, track events by event ID or name, event item, and
in-app purchase data and signature for purchase verification.
|
int |
trackPurchase(String event,
int purchaseStatus,
double revenue,
String currency,
String refId,
String inAppPurchaseData,
String inAppSignature)
Tracking event function, track purchase events with a special purchase status parameter.
|
int |
trackSession()
Main tracking session function; this function should be called at every app open.
|
public static final int GENDER_MALE
public static final int GENDER_FEMALE
protected MATResponse matResponse
protected MATTestRequest matRequest
protected boolean isRegistered
protected BroadcastReceiver networkStateReceiver
protected Context mContext
protected MATEventQueue eventQueue
public static MobileAppTracker getInstance()
public static void init(Context context, String advertiserId, String key, boolean collectDeviceId, boolean collectMacAddress)
context
- the application contextadvertiserId
- the MAT advertiser ID for the appkey
- the MAT advertiser key for the appcollectDeviceId
- whether to collect device IDcollectMacAddress
- whether to collect MAC addresspublic static void init(Context context, String advertiserId, String key)
context
- the application contextadvertiserId
- the MAT advertiser ID for the appkey
- the MAT advertiser key for the appprotected void initAll(Context context, String advertiserId, String key, boolean collectDeviceId, boolean collectMacAddress)
context
- the application contextadvertiserId
- the MAT advertiser ID for the appkey
- the MAT advertiser key for the appcollectDeviceId
- whether to collect device IDcollectMacAddress
- whether to collect MAC addresspublic boolean isOnline(Context context)
context
- the app context to check connectivity fromprotected void addEventToQueue(String link, String eventItems, String action, double revenue, String currency, String refId, String inAppPurchaseData, String inAppSignature, String eventAttribute1, String eventAttribute2, String eventAttribute3, String eventAttribute4, String eventAttribute5, boolean shouldBuildData, Date runDate)
protected void dumpQueue()
public String setTracking(String publisherAdvertiserId, String targetPackageName, String publisherId, String campaignId, boolean doRedirect)
publisherAdvertiserId
- the advertiser id of the publishing app (referring app)targetPackageName
- the target package name being referred topublisherId
- (optional) the publisher id for referralcampaignId
- (optional) the campaign id for referraldoRedirect
- whether to automatically redirect user to target app's url or notpublic int trackSession()
public int trackPurchase(String event, int purchaseStatus, double revenue, String currency, String refId, String inAppPurchaseData, String inAppSignature)
event
- event name or event ID in MAT systempurchaseStatus
- the status of the purchase: 0 for success, 1 for fail, 2 for refundrevenue
- revenue amount tied to the actioncurrency
- currency code for the revenue amountrefId
- the advertiser ref ID to associate with the eventinAppPurchaseData
- the receipt data from Google PlayinAppSignature
- the receipt signature from Google Playpublic int trackAction(String event)
event
- event name or event ID in MAT systempublic int trackAction(String event, MATEventItem eventItem)
event
- event name or event ID in MAT systemeventItem
- event item to post to server.public int trackAction(String event, MATEventItem eventItem, double revenue, String currency, String refId)
event
- event name or event ID in MAT systemeventItem
- event item to post to server.revenue
- revenue amount tied to the actioncurrency
- currency code for the revenue amountrefId
- the advertiser ref ID to associate with the eventpublic int trackAction(String event, MATEventItem eventItem, double revenue, String currency, String refId, String inAppPurchaseData, String inAppSignature)
event
- event name or event ID in MAT systemeventItem
- event item to post to server.inAppPurchaseData
- the receipt data from Google PlayinAppSignature
- the receipt signature from Google Playpublic int trackAction(String event, List<MATEventItem> list)
event
- event name or event ID in MAT systemlist
- List of event items to post to server.public int trackAction(String event, List<MATEventItem> list, double revenue, String currency, String refId)
event
- event name or event ID in MAT systemlist
- List of event items to post to server.revenue
- revenue amount tied to the actioncurrency
- currency code for the revenue amountrefId
- the advertiser ref ID to associate with the eventpublic int trackAction(String event, List<MATEventItem> list, double revenue, String currency, String refId, String inAppPurchaseData, String inAppSignature)
event
- event name or event ID in MAT systemlist
- List of event items to post to server.revenue
- revenue amount tied to the actioncurrency
- currency code for the revenue amountrefId
- the advertiser ref ID to associate with the eventinAppPurchaseData
- the receipt data from Google PlayinAppSignature
- the receipt signature from Google Playpublic int trackAction(String event, double revenue)
event
- event name or event ID in MAT systemrevenue
- revenue amount tied to the actionpublic int trackAction(String event, double revenue, String currency)
event
- event name or event ID in MAT systemrevenue
- revenue amount tied to the actioncurrency
- currency code for the revenue amountpublic int trackAction(String event, double revenue, String currency, String refId)
event
- event name or event ID in MAT systemrevenue
- revenue amount tied to the actioncurrency
- currency code for the revenue amountrefId
- the advertiser ref ID to associate with the eventpublic int trackAction(String event, double revenue, String currency, String refId, String inAppPurchaseData, String inAppSignature)
event
- event name or event ID in MAT systemrevenue
- revenue amount tied to the actioncurrency
- currency code for the revenue amountrefId
- the advertiser ref ID to associate with the eventinAppPurchaseData
- the receipt data from Google PlayinAppSignature
- the receipt signature from Google Playprotected void makeRequest(String link, String eventItems, String action, double revenue, String currency, String refId, String iapData, String iapSignature, String eventAttribute1, String eventAttribute2, String eventAttribute3, String eventAttribute4, String eventAttribute5, boolean shouldBuildData)
public String getAction()
public String getAdvertiserId()
public int getAge()
public double getAltitude()
public String getAndroidId()
public String getAndroidIdMd5()
public String getAndroidIdSha1()
public String getAndroidIdSha256()
public String getAppName()
public int getAppVersion()
public String getConnectionType()
public String getCountryCode()
public String getDeviceBrand()
public String getDeviceId()
public String getDeviceModel()
public String getCurrencyCode()
public String getDeviceCarrier()
public String getEventAttribute1()
public String getEventAttribute2()
public String getEventAttribute3()
public String getEventAttribute4()
public String getEventAttribute5()
public String getEventId()
public String getEventName()
public boolean getExistingUser()
public String getFacebookUserId()
public int getGender()
public String getGoogleAdvertisingId()
public String getGoogleUserId()
public String getInstallDate()
public String getInstallLogId()
public String getInstallReferrer()
public String getLanguage()
public String getLastOpenLogId()
public double getLatitude()
public boolean getLimitAdTrackingEnabled()
public double getLongitude()
public String getMacAddress()
public String getMatId()
public String getMCC()
public String getMNC()
public String getOpenLogId()
public String getOsVersion()
public String getPackageName()
public String getPluginName()
public String getReferralSource()
public String getReferralUrl()
public String getRefId()
public Double getRevenue()
public String getScreenDensity()
public String getScreenSize()
public String getSDKVersion()
public String getSiteId()
public String getTRUSTeId()
public String getTwitterUserID()
public String getUpdateLogId()
public String getUserAgent()
public String getUserEmail()
public String getUserId()
public String getUserName()
public void setAge(int age)
age
- User age to track in MATpublic void setAltitude(double altitude)
altitude
- device altitudepublic void setExistingUser(boolean existing)
existing
- true if this user already had the app installed prior to updating to MAT versionpublic void setCurrencyCode(String currency_code)
currency_code
- the currency codepublic void setEventAttribute1(String value)
public void setEventAttribute2(String value)
public void setEventAttribute3(String value)
public void setEventAttribute4(String value)
public void setEventAttribute5(String value)
public void setFacebookUserId(String fb_user_id)
fb_user_id
- public void setGender(int gender)
gender
- use MobileAppTracker.GENDER_MALE, MobileAppTracker.GENDER_FEMALEpublic void setGoogleAdvertisingId(String adId)
adId
- Google Play advertising IDpublic void setGoogleUserId(String google_user_id)
google_user_id
- public void setInstallReferrer(String referrer)
referrer
- Your custom referrer valuepublic void setLatitude(double latitude)
latitude
- the device latitudepublic void setLimitAdTrackingEnabled(boolean isLATEnabled)
isLATEnabled
- true if user has opted out of ad tracking, false if not (default)public void setLongitude(double longitude)
longitude
- the device longitudepublic void setMATResponse(MATResponse response)
response
- a MATResponse object that will be called when server request is completepublic void setPackageName(String package_name)
package_name
- App package namepublic void setReferralSources(Activity act)
act
- Activity to get referring package name and url scheme frompublic void setSiteId(String site_id)
site_id
- MAT site ID to attribute topublic void setTRUSTeId(String tpid)
tpid
- TRUSTe IDpublic void setTwitterUserId(String twitter_user_id)
twitter_user_id
- public void setUserEmail(String user_email)
user_email
- public void setUserId(String user_id)
user_id
- the new user idpublic void setUserName(String user_name)
user_name
- public void setPluginName(String plugin_name)
plugin_name
- public void setUseAndroidIdMd5()
public void setUseAndroidIdSha1()
public void setUseAndroidIdSha256()
public void setAllowDuplicates(boolean allow)
allow
- whether to allow duplicate installs from devicepublic void setDebugMode(boolean debug)
debug
- whether to enable debug outputprotected String getAttributionId(ContentResolver contentResolver)
contentResolver
- app's ContentResolver to access to FB ContentProvider