|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.analytics.tracking.android.GoogleTracker
public class GoogleTracker
Implementation of the Tracker
interface. This class interacts with
a GoogleAnalytics
object for sending hits and tracking active Trackers.
Method Summary | |
---|---|
boolean |
anonymizeIpEnabled()
Returns whether or not anonymize IP mode is on. |
void |
close()
Closes the session. |
java.util.Map<java.lang.String,java.lang.String> |
constructEvent(java.lang.String category,
java.lang.String action,
java.lang.String label,
java.lang.Long value)
Creates model fields for an event. |
java.util.Map<java.lang.String,java.lang.String> |
constructException(java.lang.String exceptionDescription,
boolean fatal)
Creates model fields for an exception. |
java.util.Map<java.lang.String,java.lang.String> |
constructRawException(java.lang.String threadName,
java.lang.Throwable exception,
boolean fatal)
Creates model fields for an exception. |
java.util.Map<java.lang.String,java.lang.String> |
constructSocial(java.lang.String network,
java.lang.String action,
java.lang.String target)
Creates model fields for social. |
java.util.Map<java.lang.String,java.lang.String> |
constructTiming(java.lang.String category,
long intervalInMilliseconds,
java.lang.String name,
java.lang.String label)
Creates model fields for timing. |
java.util.Map<java.lang.String,java.lang.String> |
constructTransaction(Transaction trans)
Creates model fields for a transaction. |
java.lang.String |
get(java.lang.String key)
Gets the model value for the given key. |
java.lang.String |
getAppId()
|
java.lang.String |
getAppInstallerId()
|
ExceptionParser |
getExceptionParser()
|
double |
getSampleRate()
Returns the sample rate. |
java.lang.String |
getTrackingId()
|
boolean |
getUseSecure()
Returns the current setting for useSecure. |
void |
send(java.lang.String hitType,
java.util.Map<java.lang.String,java.lang.String> params)
Tracks the given hit. |
void |
set(java.lang.String key,
java.lang.String value)
Sets the model value for the given key. |
void |
setAnonymizeIp(boolean anonymizeIp)
Turns on or off anonymize IP mode. |
void |
setAppId(java.lang.String appId)
Set the appId . |
void |
setAppInstallerId(java.lang.String appInstallerId)
Set the id of the app that installed this app. |
void |
setAppName(java.lang.String appName)
An input of null or an empty String will be ignored. |
void |
setAppScreen(java.lang.String appScreen)
Stores the place to be sent with subsequent track calls. |
void |
setAppVersion(java.lang.String appVersion)
Null is allowed as is an empty String. |
void |
setCampaign(java.lang.String campaign)
Set the campaign. |
void |
setCustomDimension(int slot,
java.lang.String value)
Sets the value for a custom dimension. |
void |
setCustomDimensionsAndMetrics(java.util.Map<java.lang.Integer,java.lang.String> dimensions,
java.util.Map<java.lang.Integer,java.lang.Long> metrics)
Sets the values for several custom dimensions and metrics at once. |
void |
setCustomMetric(int slot,
java.lang.Long value)
Sets the value for a custom metric. |
void |
setExceptionParser(ExceptionParser exceptionParser)
Sets the ExceptionParser to be used by this Tracker. |
void |
setReferrer(java.lang.String referrer)
Set the referrer. |
void |
setSampleRate(double sampleRate)
Sets the sample rate. |
void |
setStartSession(boolean startSession)
Specifies whether a new session should be started. |
void |
setUseSecure(boolean useSecure)
Determines whether hits are sent securely. |
void |
trackEvent(java.lang.String category,
java.lang.String action,
java.lang.String label,
java.lang.Long value)
Tracks an event. |
void |
trackException(java.lang.String description,
boolean fatal)
Tracks that an exception occurred. |
void |
trackException(java.lang.String threadName,
java.lang.Throwable exception,
boolean fatal)
Tracks that an exception occurred. |
void |
trackSocial(java.lang.String network,
java.lang.String action,
java.lang.String target)
Tracks a social hit. |
void |
trackTiming(java.lang.String category,
long intervalInMilliseconds,
java.lang.String name,
java.lang.String label)
Tracks a user timing hit. |
void |
trackTransaction(Transaction transaction)
Tracks an eCommerce transaction. |
void |
trackView()
Tracks entering a view with the current app screen name. |
void |
trackView(java.lang.String appScreen)
Tracks entering a view with a new app screen name. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void send(java.lang.String hitType, java.util.Map<java.lang.String,java.lang.String> params)
Tracker
ModelFields
in order for that value to appear in the hit.
send
in interface Tracker
hitType
- the type of the hitparams
- map of hit data to values which are appended to the existing
values which are already set (using Tracker.set(java.lang.String, java.lang.String)
)public void setStartSession(boolean startSession)
Tracker
If you don't explicitly mark session starts by calling setStartSession with a value of true, sessions will be created automatically on the backend.
By default, trackers are created with startSession set to true.
setStartSession
in interface Tracker
startSession
- true if a new session should be started with the next
hitpublic void setAppScreen(java.lang.String appScreen)
Tracker
setAppScreen
in interface Tracker
appScreen
- the new app screen name (null or empty string clears any existing app screen
name)public void trackView()
Tracker
trackView
in interface Tracker
public void trackView(java.lang.String appScreen)
Tracker
trackView
in interface Tracker
appScreen
- the new app screen namepublic void trackEvent(java.lang.String category, java.lang.String action, java.lang.String label, java.lang.Long value)
Tracker
trackEvent
in interface Tracker
category
- the event categoryaction
- the event actionlabel
- the event labelvalue
- the event value. Pass null if no value is to be set.public void trackTransaction(Transaction transaction)
Tracker
trackTransaction
in interface Tracker
public void trackException(java.lang.String description, boolean fatal)
Tracker
trackException
in interface Tracker
description
- the type of exceptionfatal
- true if the exception is fatalpublic void trackException(java.lang.String threadName, java.lang.Throwable exception, boolean fatal)
Tracker
ExceptionParser
class set for this tracker. See
Tracker.setExceptionParser(com.google.analytics.tracking.android.ExceptionParser)
and StandardExceptionParser
.
trackException
in interface Tracker
threadName
- the name of the @{link Thread} that got the exception, or nullexception
- the Throwable
to reportfatal
- true if the exception is fatalpublic void trackTiming(java.lang.String category, long intervalInMilliseconds, java.lang.String name, java.lang.String label)
Tracker
trackTiming
in interface Tracker
category
- the category of the timingintervalInMilliseconds
- the timing interval, in millisecondsname
- the optional name of the timinglabel
- the optional labelpublic void trackSocial(java.lang.String network, java.lang.String action, java.lang.String target)
Tracker
trackSocial
in interface Tracker
network
- the social networkaction
- the social actiontarget
- the social targetpublic java.util.Map<java.lang.String,java.lang.String> constructEvent(java.lang.String category, java.lang.String action, java.lang.String label, java.lang.Long value)
Tracker
Tracker.send(java.lang.String, java.util.Map)
.
constructEvent
in interface Tracker
public java.util.Map<java.lang.String,java.lang.String> constructTransaction(Transaction trans)
Tracker
Tracker.send(java.lang.String, java.util.Map)
.
constructTransaction
in interface Tracker
public java.util.Map<java.lang.String,java.lang.String> constructException(java.lang.String exceptionDescription, boolean fatal)
Tracker
Tracker.send(java.lang.String, java.util.Map)
.
constructException
in interface Tracker
public java.util.Map<java.lang.String,java.lang.String> constructRawException(java.lang.String threadName, java.lang.Throwable exception, boolean fatal) throws java.io.IOException
Tracker
Tracker.send(java.lang.String, java.util.Map)
.
constructRawException
in interface Tracker
java.io.IOException
public java.util.Map<java.lang.String,java.lang.String> constructTiming(java.lang.String category, long intervalInMilliseconds, java.lang.String name, java.lang.String label)
Tracker
Tracker.send(java.lang.String, java.util.Map)
.
constructTiming
in interface Tracker
public java.util.Map<java.lang.String,java.lang.String> constructSocial(java.lang.String network, java.lang.String action, java.lang.String target)
Tracker
Tracker.send(java.lang.String, java.util.Map)
.
constructSocial
in interface Tracker
public void close()
Tracker
Tracker
.
close
in interface Tracker
public java.lang.String getTrackingId()
getTrackingId
in interface Tracker
trackingId
used by this Tracker
public void setAnonymizeIp(boolean anonymizeIp)
Tracker
In the case of IPv4 addresses, the last octet is set to zero. For IPv6 addresses, the last 10 octets are set to zero, although this is subject to change in the future.
setAnonymizeIp
in interface Tracker
anonymizeIp
- if true, turns on anonymize IP modepublic void setSampleRate(double sampleRate)
Tracker
When a visitor is not sampled, no data is submitted to Google Analytics about that visitor's activity. If your application is subject to heavy traffic spikes, you may wish to adjust the sample rate to ensure uninterrupted report tracking. Sampling in Google Analytics occurs consistently across unique visitors, ensuring integrity in trending and reporting even when sampling is enabled, because unique visitors remain included or excluded from the sample, as set from the initiation of sampling.
Note that sampleRate can be set down to hundredths of a percent.
setSampleRate
in interface Tracker
sampleRate
- a value between 0.0 and 100.0public boolean anonymizeIpEnabled()
Tracker
anonymizeIpEnabled
in interface Tracker
public double getSampleRate()
Tracker
getSampleRate
in interface Tracker
public void setReferrer(java.lang.String referrer)
Tracker
setReferrer
in interface Tracker
referrer
- the new referrer informationpublic void setCampaign(java.lang.String campaign)
Tracker
Implementations should handle input of the form http://my.site.com/index.html?utm_campaign=wow&utm_source=source as well as input of the form utm_campaign=wow&utm_source=source.
For more information on auto-tagging, see http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55590
For more information on manual tagging, see http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55518
setCampaign
in interface Tracker
campaign
- the campaign information, as a sequence of URL parameters
separated by &public java.lang.String get(java.lang.String key)
Tracker
get
in interface Tracker
public void set(java.lang.String key, java.lang.String value)
Tracker
set
in interface Tracker
public void setAppName(java.lang.String appName)
setAppName
in interface Tracker
public void setAppVersion(java.lang.String appVersion)
setAppVersion
in interface Tracker
public void setAppId(java.lang.String appId)
Tracker
appId
. By default, the appId
will be set to the
packageName of the application. This works for Google Play, but other
stores will have different appIds
. This method allows changing the
appId
for other stores.
setAppId
in interface Tracker
appId
- the new appId
or nullpublic java.lang.String getAppId()
getAppId
in interface Tracker
public void setAppInstallerId(java.lang.String appInstallerId)
Tracker
PackageManager#getInstallerPackageName
method.
setAppInstallerId
in interface Tracker
appInstallerId
- the new appInstallerId
or nullpublic java.lang.String getAppInstallerId()
getAppInstallerId
in interface Tracker
public void setExceptionParser(ExceptionParser exceptionParser)
Tracker
ExceptionParser
to be used by this Tracker.
setExceptionParser
in interface Tracker
public ExceptionParser getExceptionParser()
getExceptionParser
in interface Tracker
ExceptionParser
currently in use for this Tracker.public void setUseSecure(boolean useSecure)
Tracker
setUseSecure
in interface Tracker
useSecure
- if true, use Https to send hits, otherwise use Httppublic boolean getUseSecure()
Tracker
getUseSecure
in interface Tracker
public void setCustomDimension(int slot, java.lang.String value)
Tracker
setCustomDimension
in interface Tracker
slot
- the dimension slotvalue
- the dimension value, or null to clear a previously set valuepublic void setCustomMetric(int slot, java.lang.Long value)
Tracker
setCustomMetric
in interface Tracker
slot
- the metric slotvalue
- the metric value, or null to clear a previously set valuepublic void setCustomDimensionsAndMetrics(java.util.Map<java.lang.Integer,java.lang.String> dimensions, java.util.Map<java.lang.Integer,java.lang.Long> metrics)
Tracker
setCustomDimensionsAndMetrics
in interface Tracker
dimensions
- a Map of the custom dimension slots to custom dimension
valuesmetrics
- a Map of the custom metric slots to custom metric values
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |