public class MobileAppTracker extends Object
Modifier and Type | Field and Description |
---|---|
protected MATEventQueue |
eventQueue |
static int |
GENDER_FEMALE |
static int |
GENDER_MALE |
protected boolean |
initialized |
protected boolean |
isRegistered |
protected MATTestRequest |
matRequest |
protected MATResponse |
matResponse |
protected Context |
mContext |
protected BroadcastReceiver |
networkStateReceiver |
protected Parameters |
params |
protected ExecutorService |
pubQueue |
Modifier | Constructor and Description |
---|---|
protected |
MobileAppTracker() |
Modifier and Type | Method and Description |
---|---|
protected void |
addEventToQueue(String link,
String data,
JSONObject postBody,
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.
|
boolean |
getAppAdTrackingEnabled()
Get whether the user has app-level ad tracking enabled or not.
|
String |
getAppName()
Gets the app name
|
int |
getAppVersion()
Gets the app version
|
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 |
getDeviceModel()
Gets the device model name
|
String |
getEventAttribute1()
Get the first event attribute for the current action.
|
String |
getEventAttribute2()
Get the second event attribute for the current action.
|
String |
getEventAttribute3()
Get the third event attribute for the current action.
|
String |
getEventAttribute4()
Get the fourth event attribute for the current action.
|
String |
getEventAttribute5()
Get the fifth event attribute for the current action.
|
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.
|
boolean |
getGoogleAdTrackingLimited()
Gets whether use of the Google Play Services Advertising ID is limited by user request.
|
String |
getGoogleAdvertisingId()
Gets the Google Play Services Advertising ID.
|
String |
getGoogleUserId()
Gets the Google user ID previously set.
|
long |
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
|
boolean |
getIsPayingUser()
Gets whether the user is revenue-generating or not
|
String |
getLanguage()
Gets the language of the device
|
String |
getLastOpenLogId()
Gets the last MAT open log ID
|
double |
getLatitude()
Gets the device latitude.
|
double |
getLongitude()
Gets the device longitude.
|
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 |
getScreenHeight()
Gets the screen height of the device in pixels
|
String |
getScreenWidth()
Gets the screen width of the device in pixels
|
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 conversionKey)
Initializes a MobileAppTracker.
|
protected void |
initAll(String advertiserId,
String conversionKey)
Private initialization function for MobileAppTracker.
|
static boolean |
isOnline(Context context)
Returns true if an Internet connection is detected.
|
protected boolean |
makeRequest(String link,
String data,
JSONObject postBody)
Helper function for making single request and displaying response
|
void |
measureAction(int eventId)
Event measurement function, by event ID.
|
void |
measureAction(int eventId,
double revenue,
String currency)
Event measurement function, by event ID, revenue and currency.
|
void |
measureAction(int eventId,
double revenue,
String currency,
String refId)
Event measurement function, by event ID, revenue, currency, and advertiser ref ID.
|
void |
measureAction(int eventId,
List<MATEventItem> eventItems,
double revenue,
String currency,
String refId)
Event measurement function, by event ID, event items,
revenue, currency, and advertiser ref ID.
|
void |
measureAction(int eventId,
List<MATEventItem> eventItems,
double revenue,
String currency,
String refId,
String purchaseData,
String purchaseSignature)
Event measurement function
|
void |
measureAction(String eventName)
Event measurement function, by event name.
|
void |
measureAction(String eventName,
double revenue,
String currency)
Event measurement function, by event name, revenue and currency.
|
void |
measureAction(String eventName,
double revenue,
String currency,
String refId)
Event measurement function, by event name, revenue, currency, and advertiser ref ID.
|
void |
measureAction(String eventName,
List<MATEventItem> eventItems,
double revenue,
String currency,
String refId)
Event measurement function, by event name, event items,
revenue, currency, and advertiser ref ID.
|
void |
measureAction(String eventName,
List<MATEventItem> eventItems,
double revenue,
String currency,
String refId,
String purchaseData,
String purchaseSignature)
Event measurement function
|
void |
measureSession()
Main session measurement function; this function should be called at every app open.
|
void |
setAdvertiserSubAd(String subAd)
Sets the preloaded app's advertiser sub ad
|
void |
setAdvertiserSubAdgroup(String subAdgroup)
Sets the preloaded app's advertiser sub adgroup
|
void |
setAdvertiserSubCampaign(String subCampaign)
Sets the preloaded app's advertiser sub campaign
|
void |
setAdvertiserSubKeyword(String subKeyword)
Sets the preloaded app's advertiser sub keyword
|
void |
setAdvertiserSubPublisher(String subPublisher)
Sets the preloaded app's advertiser sub publisher
|
void |
setAdvertiserSubSite(String subSite)
Sets the preloaded app's advertiser sub site
|
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 |
setAndroidId(String androidId)
Sets the ANDROID ID
|
void |
setAppAdTrackingEnabled(boolean adTrackingEnabled)
Sets whether app-level ad tracking is enabled.
|
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 |
setDeviceId(String deviceId)
Sets the device IMEI/MEID
|
void |
setEventAttribute1(String value)
Sets the first attribute associated with an app event.
|
void |
setEventAttribute2(String value)
Sets the second attribute associated with an app event.
|
void |
setEventAttribute3(String value)
Sets the third attribute associated with an app event.
|
void |
setEventAttribute4(String value)
Sets the fourth attribute associated with an app event.
|
void |
setEventAttribute5(String value)
Sets the fifth attribute associated with an app event.
|
void |
setEventContentId(String contentId)
Sets the content ID associated with an app event.
|
void |
setEventContentType(String contentType)
Sets the content type associated with an app event.
|
void |
setEventDate1(Date date)
Sets the first date associated with an app event.
|
void |
setEventDate2(Date date)
Sets the second date associated with an app event.
|
void |
setEventLevel(int level)
Sets the level associated with an app event.
|
void |
setEventQuantity(int quantity)
Sets the quantity associated with an app event.
|
void |
setEventRating(float rating)
Sets the rating associated with an app event.
|
void |
setEventSearchString(String searchString)
Sets the search string associated with an app event.
|
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,
boolean isLATEnabled)
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 |
setIsPayingUser(boolean isPayingUser)
Sets whether the user is revenue-generating or not
|
void |
setLatitude(double latitude)
Sets the device latitude.
|
void |
setLocation(Location location)
Sets the device location.
|
void |
setLongitude(double longitude)
Sets the device longitude.
|
void |
setMacAddress(String macAddress)
Sets the device MAC address.
|
void |
setMATResponse(MATResponse response)
Register a MATResponse interface to receive server response callback
|
void |
setOfferId(String offerId)
Sets the preloaded app's offer ID
|
void |
setPackageName(String package_name)
Sets the app package name
|
void |
setPluginName(String plugin_name)
Set the name of plugin used, if any
|
void |
setPublisherId(String publisherId)
Sets the preloaded app's publisher ID
|
void |
setPublisherReferenceId(String publisherRefId)
Sets the preloaded app's publisher reference ID
|
void |
setPublisherSub1(String sub1)
Sets the preloaded app's publisher sub1
|
void |
setPublisherSub2(String sub2)
Sets the preloaded app's publisher sub2
|
void |
setPublisherSub3(String sub3)
Sets the preloaded app's publisher sub3
|
void |
setPublisherSub4(String sub4)
Sets the preloaded app's publisher sub4
|
void |
setPublisherSub5(String sub5)
Sets the preloaded app's publisher sub5
|
void |
setPublisherSubAd(String subAd)
Sets the preloaded app's publisher sub ad
|
void |
setPublisherSubAdgroup(String subAdgroup)
Sets the preloaded app's publisher sub adgroup
|
void |
setPublisherSubCampaign(String subCampaign)
Sets the preloaded app's publisher sub campaign
|
void |
setPublisherSubKeyword(String subKeyword)
Sets the preloaded app's publisher sub keyword
|
void |
setPublisherSubPublisher(String subPublisher)
Sets the preloaded app's publisher sub publisher
|
void |
setPublisherSubSite(String subSite)
Sets the preloaded app's publisher sub site
|
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
|
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 |
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.
|
public static final int GENDER_MALE
public static final int GENDER_FEMALE
protected MATResponse matResponse
protected MATTestRequest matRequest
protected boolean isRegistered
protected boolean initialized
protected BroadcastReceiver networkStateReceiver
protected Parameters params
protected Context mContext
protected ExecutorService pubQueue
protected MATEventQueue eventQueue
public static MobileAppTracker getInstance()
public static void init(Context context, String advertiserId, String conversionKey)
context
- the application contextadvertiserId
- the MAT advertiser ID for the appconversionKey
- the MAT advertiser key for the appprotected void initAll(String advertiserId, String conversionKey)
advertiserId
- the MAT advertiser ID for the appconversionKey
- the MAT conversion key for the apppublic static boolean isOnline(Context context)
context
- the app context to check connectivity fromprotected void addEventToQueue(String link, String data, JSONObject postBody, Date runDate)
protected void dumpQueue()
public void measureSession()
public void measureAction(String eventName)
eventName
- event name in MAT systempublic void measureAction(String eventName, double revenue, String currency)
eventName
- event name in MAT systemrevenue
- revenue amount tied to the eventcurrency
- currency code for the revenue amountpublic void measureAction(String eventName, double revenue, String currency, String refId)
eventName
- event name in MAT systemrevenue
- revenue amount tied to the eventcurrency
- currency code for the revenue amountrefId
- the advertiser ref ID to associate with the eventpublic void measureAction(String eventName, List<MATEventItem> eventItems, double revenue, String currency, String refId)
eventName
- event name in MAT systemeventItems
- List of event items to associate with eventrevenue
- revenue amount tied to the eventcurrency
- currency code for the revenue amountrefId
- the advertiser ref ID to associate with the eventpublic void measureAction(String eventName, List<MATEventItem> eventItems, double revenue, String currency, String refId, String purchaseData, String purchaseSignature)
eventName
- event name in MAT systemeventItems
- List of event items to associate with eventrevenue
- revenue amount tied to the eventcurrency
- currency code for the revenue amountrefId
- the advertiser ref ID to associate with the eventpurchaseData
- the receipt data from Google PlaypurchaseSignature
- the receipt signature from Google Playpublic void measureAction(int eventId)
eventId
- event ID in MAT systempublic void measureAction(int eventId, double revenue, String currency)
eventId
- event ID in MAT systemrevenue
- revenue amount tied to the eventcurrency
- currency code for the revenue amountpublic void measureAction(int eventId, double revenue, String currency, String refId)
eventId
- event ID in MAT systemrevenue
- revenue amount tied to the eventcurrency
- currency code for the revenue amountrefId
- the advertiser ref ID to associate with the eventpublic void measureAction(int eventId, List<MATEventItem> eventItems, double revenue, String currency, String refId)
eventId
- event ID in MAT systemeventItems
- List of event items to associate with eventrevenue
- revenue amount tied to the eventcurrency
- currency code for the revenue amountrefId
- the advertiser ref ID to associate with the eventpublic void measureAction(int eventId, List<MATEventItem> eventItems, double revenue, String currency, String refId, String purchaseData, String purchaseSignature)
eventId
- event ID in MAT systemeventItems
- List of event items to associate with eventrevenue
- revenue amount tied to the eventcurrency
- currency code for the revenue amountrefId
- the advertiser ref ID to associate with the eventpurchaseData
- the receipt data from Google PlaypurchaseSignature
- the receipt signature from Google Playprotected boolean makeRequest(String link, String data, JSONObject postBody)
public String getAction()
public String getAdvertiserId()
public int getAge()
public double getAltitude()
public boolean getAppAdTrackingEnabled()
public String getAppName()
public int getAppVersion()
public String getConnectionType()
public String getCountryCode()
public String getCurrencyCode()
public String getDeviceBrand()
public String getDeviceModel()
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 boolean getGoogleAdTrackingLimited()
public String getGoogleUserId()
public long getInstallDate()
public String getInstallLogId()
public String getInstallReferrer()
public boolean getIsPayingUser()
public String getLanguage()
public String getLastOpenLogId()
public double getLatitude()
public double getLongitude()
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 getScreenHeight()
public String getScreenWidth()
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 setAdvertiserSubAd(String subAd)
subAd
- Preloaded advertiser sub adpublic void setAdvertiserSubAdgroup(String subAdgroup)
subAdgroup
- Preloaded advertiser sub adgrouppublic void setAdvertiserSubCampaign(String subCampaign)
subCampaign
- Preloaded advertiser sub campaignpublic void setAdvertiserSubKeyword(String subKeyword)
subKeyword
- Preloaded advertiser sub keywordpublic void setAdvertiserSubPublisher(String subPublisher)
subPublisher
- Preloaded advertiser sub publisherpublic void setAdvertiserSubSite(String subSite)
subSite
- Preloaded advertiser sub sitepublic void setAge(int age)
age
- User age to track in MATpublic void setAltitude(double altitude)
altitude
- device altitudepublic void setAndroidId(String androidId)
androidId
- ANDROID_IDpublic void setAppAdTrackingEnabled(boolean adTrackingEnabled)
adTrackingEnabled
- true if user has opted out of ad tracking at the app-level, false if notpublic void setCurrencyCode(String currency_code)
currency_code
- the currency codepublic void setDeviceId(String deviceId)
deviceId
- device IMEI/MEIDpublic void setEventContentType(String contentType)
contentType
- the content typepublic void setEventContentId(String contentId)
contentId
- the content IDpublic void setEventLevel(int level)
level
- the levelpublic void setEventQuantity(int quantity)
quantity
- the quantitypublic void setEventSearchString(String searchString)
searchString
- the search stringpublic void setEventRating(float rating)
rating
- the ratingpublic void setEventDate1(Date date)
date
- the datepublic void setEventDate2(Date date)
date
- the datepublic void setEventAttribute1(String value)
value
- the attributepublic void setEventAttribute2(String value)
value
- the attributepublic void setEventAttribute3(String value)
value
- the attributepublic void setEventAttribute4(String value)
value
- the attributepublic void setEventAttribute5(String value)
value
- the attributepublic void setExistingUser(boolean existing)
existing
- true if this user already had the app installed prior to updating to MAT versionpublic 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, boolean isLATEnabled)
adId
- Google Play advertising IDisLATEnabled
- whether user has requested to limit use of the Google ad IDpublic void setGoogleUserId(String google_user_id)
google_user_id
- public void setInstallReferrer(String referrer)
referrer
- Your custom referrer valuepublic void setIsPayingUser(boolean isPayingUser)
isPayingUser
- true if the user has produced revenue, false if notpublic void setLatitude(double latitude)
latitude
- the device latitudepublic void setLocation(Location location)
location
- the device locationpublic void setLongitude(double longitude)
longitude
- the device longitudepublic void setMacAddress(String macAddress)
macAddress
- device MAC addresspublic void setMATResponse(MATResponse response)
response
- a MATResponse object that will be called when server request is completepublic void setOfferId(String offerId)
offerId
- Preloaded offer IDpublic void setPackageName(String package_name)
package_name
- App package namepublic void setPublisherId(String publisherId)
publisherId
- Preloaded publisher IDpublic void setPublisherReferenceId(String publisherRefId)
publisherRefId
- Preloaded publisher reference IDpublic void setPublisherSubAd(String subAd)
subAd
- Preloaded publisher sub adpublic void setPublisherSubAdgroup(String subAdgroup)
subAdgroup
- Preloaded publisher sub adgrouppublic void setPublisherSubCampaign(String subCampaign)
subCampaign
- Preloaded publisher sub campaignpublic void setPublisherSubKeyword(String subKeyword)
subKeyword
- Preloaded publisher sub keywordpublic void setPublisherSubPublisher(String subPublisher)
subPublisher
- Preloaded publisher sub publisherpublic void setPublisherSubSite(String subSite)
subSite
- Preloaded publisher sub sitepublic void setPublisherSub1(String sub1)
sub1
- Preloaded publisher sub1 valuepublic void setPublisherSub2(String sub2)
sub2
- Preloaded publisher sub2 valuepublic void setPublisherSub3(String sub3)
sub3
- Preloaded publisher sub3 valuepublic void setPublisherSub4(String sub4)
sub4
- Preloaded publisher sub4 valuepublic void setPublisherSub5(String sub5)
sub5
- Preloaded publisher sub5 valuepublic 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 setAllowDuplicates(boolean allow)
allow
- whether to allow duplicate installs from devicepublic void setDebugMode(boolean debug)
debug
- whether to enable debug output