public class GoogleAnalyticsRequest<T>
extends java.lang.Object
It also provides type safe getter/setters for all parameters that are applicable
for all hit types. Hit specific setters/getters are available in corresponding
Hit specific request objects (like EventHit
or PageViewHit
etc)
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,java.lang.String> |
customDimentions |
protected java.util.Map<java.lang.String,java.lang.String> |
customMetrics |
protected java.util.Map<GoogleAnalyticsParameter,java.lang.String> |
parms |
Constructor and Description |
---|
GoogleAnalyticsRequest() |
GoogleAnalyticsRequest(java.lang.String hitType) |
GoogleAnalyticsRequest(java.lang.String hitType,
java.lang.String trackingId,
java.lang.String appName,
java.lang.String appVersion) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
adwordsId() |
T |
adwordsId(java.lang.String value)
|
java.lang.Boolean |
anonymizeIp() |
T |
anonymizeIp(java.lang.Boolean value)
|
java.lang.String |
applicationID() |
T |
applicationID(java.lang.String value)
|
java.lang.String |
applicationInstallerID() |
T |
applicationInstallerID(java.lang.String value)
|
java.lang.String |
applicationName() |
T |
applicationName(java.lang.String value)
|
java.lang.String |
applicationVersion() |
T |
applicationVersion(java.lang.String value)
|
java.lang.String |
cacheBuster() |
T |
cacheBuster(java.lang.String value)
|
java.lang.String |
campaignContent() |
T |
campaignContent(java.lang.String value)
|
java.lang.String |
campaignId() |
T |
campaignId(java.lang.String value)
|
java.lang.String |
campaignKeyword() |
T |
campaignKeyword(java.lang.String value)
|
java.lang.String |
campaignMedium() |
T |
campaignMedium(java.lang.String value)
|
java.lang.String |
campaignName() |
T |
campaignName(java.lang.String value)
|
java.lang.String |
campaignSource() |
T |
campaignSource(java.lang.String value)
|
java.lang.String |
clientId() |
T |
clientId(java.lang.String value)
|
java.lang.String |
contentDescription() |
T |
contentDescription(java.lang.String value)
|
java.lang.String |
customDimension(int index) |
T |
customDimension(int index,
java.lang.String value)
|
java.util.Map<java.lang.String,java.lang.String> |
customDimentions() |
java.lang.String |
customMetric(int index) |
T |
customMetric(int index,
java.lang.String value)
|
java.util.Map<java.lang.String,java.lang.String> |
custommMetrics() |
java.lang.String |
displayadId() |
T |
displayadId(java.lang.String value)
|
java.lang.String |
documentEncoding() |
T |
documentEncoding(java.lang.String value)
|
java.lang.String |
documentHostName() |
T |
documentHostName(java.lang.String value)
|
java.lang.String |
documentPath() |
T |
documentPath(java.lang.String value)
|
java.lang.String |
documentReferrer() |
T |
documentReferrer(java.lang.String value)
|
java.lang.String |
documentTitle() |
T |
documentTitle(java.lang.String value)
|
java.lang.String |
documentUrl() |
T |
documentUrl(java.lang.String value)
|
java.lang.String |
expirementId() |
T |
expirementId(java.lang.String value)
|
java.lang.String |
expirementVariant() |
T |
expirementVariant(java.lang.String value)
|
java.lang.String |
flashVersion() |
T |
flashVersion(java.lang.String value)
|
protected java.lang.String |
fromBoolean(java.lang.Boolean booleanString) |
protected java.lang.String |
fromDouble(java.lang.Double doubleValue) |
protected java.lang.String |
fromInteger(java.lang.Integer intValue) |
protected java.lang.Boolean |
getBoolean(GoogleAnalyticsParameter parameter) |
protected java.lang.Double |
getDouble(GoogleAnalyticsParameter parameter) |
protected java.lang.Integer |
getInteger(GoogleAnalyticsParameter parameter) |
java.util.Map<GoogleAnalyticsParameter,java.lang.String> |
getParameters() |
protected java.lang.String |
getString(GoogleAnalyticsParameter parameter) |
java.lang.String |
hitType() |
T |
hitType(java.lang.String value)
|
protected boolean |
isEmpty(java.lang.String string) |
java.lang.Boolean |
javaEnabled() |
T |
javaEnabled(java.lang.Boolean value)
|
java.lang.String |
nonInteractionHit() |
T |
nonInteractionHit(java.lang.String value)
|
protected java.lang.String |
parameter(GoogleAnalyticsParameter parameter) |
protected T |
parameter(GoogleAnalyticsParameter parameter,
java.lang.String value) |
java.lang.String |
protocolVersion() |
T |
protocolVersion(java.lang.String value)
|
java.lang.Integer |
queueTime() |
T |
queueTime(java.lang.Integer value)
|
java.lang.String |
screenColors() |
T |
screenColors(java.lang.String value)
|
java.lang.String |
screenResolution() |
T |
screenResolution(java.lang.String value)
|
java.lang.String |
sessionControl() |
T |
sessionControl(java.lang.String value)
|
protected T |
setBoolean(GoogleAnalyticsParameter parameter,
java.lang.Boolean value) |
protected T |
setDouble(GoogleAnalyticsParameter parameter,
java.lang.Double value) |
protected T |
setInteger(GoogleAnalyticsParameter parameter,
java.lang.Integer value) |
protected T |
setString(GoogleAnalyticsParameter parameter,
java.lang.String value)
Sets the String value for specified parameter.
|
protected java.lang.Boolean |
toBoolean(java.lang.String booleanString) |
protected java.lang.Double |
toDouble(java.lang.String doubleString) |
protected java.lang.Integer |
toInteger(java.lang.String intString) |
java.lang.String |
toString() |
java.lang.String |
trackingId() |
T |
trackingId(java.lang.String value)
|
java.lang.String |
userAgent() |
T |
userAgent(java.lang.String value)
User Agent Override
parameter: &ua
Should be a User Agent reported by the browser.
|
java.lang.String |
userId() |
T |
userId(java.lang.String value)
Optional.
|
java.lang.String |
userIp() |
T |
userIp(java.lang.String value)
IP Override
parameter: uip
Should be a valid IP address.
|
java.lang.String |
userLanguage() |
T |
userLanguage(java.lang.String value)
|
java.lang.String |
viewportSize() |
T |
viewportSize(java.lang.String value)
|
protected java.util.Map<GoogleAnalyticsParameter,java.lang.String> parms
protected java.util.Map<java.lang.String,java.lang.String> customDimentions
protected java.util.Map<java.lang.String,java.lang.String> customMetrics
public GoogleAnalyticsRequest()
public GoogleAnalyticsRequest(java.lang.String hitType)
public GoogleAnalyticsRequest(java.lang.String hitType, java.lang.String trackingId, java.lang.String appName, java.lang.String appVersion)
protected T setString(GoogleAnalyticsParameter parameter, java.lang.String value)
parameter
- value
- protected java.lang.String getString(GoogleAnalyticsParameter parameter)
protected T setInteger(GoogleAnalyticsParameter parameter, java.lang.Integer value)
protected java.lang.Double getDouble(GoogleAnalyticsParameter parameter)
protected T setDouble(GoogleAnalyticsParameter parameter, java.lang.Double value)
protected java.lang.Boolean getBoolean(GoogleAnalyticsParameter parameter)
protected T setBoolean(GoogleAnalyticsParameter parameter, java.lang.Boolean value)
protected java.lang.Integer getInteger(GoogleAnalyticsParameter parameter)
protected java.lang.String fromBoolean(java.lang.Boolean booleanString)
protected java.lang.Boolean toBoolean(java.lang.String booleanString)
protected java.lang.String fromInteger(java.lang.Integer intValue)
protected java.lang.Integer toInteger(java.lang.String intString)
protected java.lang.String fromDouble(java.lang.Double doubleValue)
protected java.lang.Double toDouble(java.lang.String doubleString)
protected T parameter(GoogleAnalyticsParameter parameter, java.lang.String value)
protected java.lang.String parameter(GoogleAnalyticsParameter parameter)
public java.util.Map<GoogleAnalyticsParameter,java.lang.String> getParameters()
public java.lang.String customDimension(int index)
public T customDimension(int index, java.lang.String value)
Optional.
Each custom dimension has an associated index. There is a maximum of 20 custom dimensions (200 for Premium accounts). The name suffix must be a positive integer between 1 and 200, inclusive.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
cd[1-9][0-9]* |
text | None | 150 Bytes | all |
Sports
cd[1-9][0-9]*=Sports
public T customMetric(int index, java.lang.String value)
Optional.
Each custom metric has an associated index. There is a maximum of 20 custom metrics (200 for Premium accounts). The name suffix must be a positive integer between 1 and 200, inclusive.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
cm[1-9][0-9]* |
integer | None | None | all |
47
cm[1-9][0-9]*=47
public java.lang.String customMetric(int index)
public java.util.Map<java.lang.String,java.lang.String> customDimentions()
public java.util.Map<java.lang.String,java.lang.String> custommMetrics()
public java.lang.String toString()
toString
in class java.lang.Object
public T protocolVersion(java.lang.String value)
Required for all hit types.
The Protocol version. The current value is '1'. This will only change when there are changes made that are not backwards compatible.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
v |
text | None | None | all |
1
v=1
public java.lang.String protocolVersion()
public T trackingId(java.lang.String value)
Required for all hit types.
The tracking ID / web property ID. The format is UA-XXXX-Y. All collected data is associated by this ID.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
tid |
text | None | None | all |
UA-XXXX-Y
tid=UA-XXXX-Y
public java.lang.String trackingId()
public T anonymizeIp(java.lang.Boolean value)
Optional.
When present, the IP address of the sender will be anonymized. For example, the IP will be anonymized if any of the following parameters are present in the payload: &aip=, &aip=0, or &aip=1
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
aip |
boolean | None | None | all |
1
aip=1
public java.lang.Boolean anonymizeIp()
public T queueTime(java.lang.Integer value)
Optional.
Used to collect offline / latent hits. The value represents the time delta (in milliseconds) between when the hit being reported occurred and the time the hit was sent. The value must be greater than or equal to 0. Values greater than four hours may lead to hits not being processed.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
qt |
integer | None | None | all |
560
qt=560
public java.lang.Integer queueTime()
public T cacheBuster(java.lang.String value)
Optional.
Used to send a random number in GET requests to ensure browsers and proxies don't cache hits. It should be sent as the final parameter of the request since we've seen some 3rd party internet filtering software add additional parameters to HTTP requests incorrectly. This value is not used in reporting.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
z |
text | None | None | all |
289372387623
z=289372387623
public java.lang.String cacheBuster()
public T clientId(java.lang.String value)
Required for all hit types.
This anonymously identifies a particular user, device, or browser instance. For the web, this is generally stored as a first-party cookie with a two-year expiration. For mobile apps, this is randomly generated for each particular instance of an application install. The value of this field should be a random UUID (version 4) as described in http://www.ietf.org/rfc/rfc4122.txt
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
cid |
text | None | None | all |
35009a79-1a05-49d7-b876-2b884d0f825b
cid=35009a79-1a05-49d7-b876-2b884d0f825b
public java.lang.String clientId()
public T userId(java.lang.String value)
This is intended to be a known identifier for a user provided by the site owner/tracking library user. It may not itself be PII. The value should never be persisted in GA cookies or other Analytics provided storage.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
uid |
text | None | None | all |
as8eknlll
uid=as8eknlll
value
- public java.lang.String userId()
public T sessionControl(java.lang.String value)
Optional.
Used to control the session duration. A value of 'start' forces a new session to start with this hit and 'end' forces the current session to end with this hit. All other values are ignored.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
sc |
text | None | None | all |
start
sc=start
end
sc=end
public java.lang.String sessionControl()
public T documentReferrer(java.lang.String value)
Optional.
Specifies which referral source brought traffic to a website. This value is also used to compute the traffic source. The format of this value is a URL.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
dr |
text | None | 2048 Bytes | all |
http://example.com
dr=http%3A%2F%2Fexample.com
public java.lang.String documentReferrer()
public T campaignName(java.lang.String value)
Optional.
Specifies the campaign name.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
cn |
text | None | 100 Bytes | all |
(direct)
cn=%28direct%29
public java.lang.String campaignName()
public T campaignSource(java.lang.String value)
Optional.
Specifies the campaign source.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
cs |
text | None | 100 Bytes | all |
(direct)
cs=%28direct%29
public java.lang.String campaignSource()
public T campaignMedium(java.lang.String value)
Optional.
Specifies the campaign medium.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
cm |
text | None | 50 Bytes | all |
organic
cm=organic
public java.lang.String campaignMedium()
public T campaignKeyword(java.lang.String value)
Optional.
Specifies the campaign keyword.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
ck |
text | None | 500 Bytes | all |
Blue Shoes
ck=Blue%20Shoes
public java.lang.String campaignKeyword()
public T campaignContent(java.lang.String value)
Optional.
Specifies the campaign content.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
cc |
text | None | 500 Bytes | all |
content
cc=content
public java.lang.String campaignContent()
public T campaignId(java.lang.String value)
Optional.
Specifies the campaign ID.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
ci |
text | None | 100 Bytes | all |
ID
ci=ID
public java.lang.String campaignId()
public T adwordsId(java.lang.String value)
Optional.
Specifies the Google AdWords Id.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
gclid |
text | None | None | all |
CL6Q-OXyqKUCFcgK2goddQuoHg
gclid=CL6Q-OXyqKUCFcgK2goddQuoHg
public java.lang.String adwordsId()
public T displayadId(java.lang.String value)
Optional.
Specifies the Google Display Ads Id.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
dclid |
text | None | None | all |
d_click_id
dclid=d_click_id
public java.lang.String displayadId()
public T screenResolution(java.lang.String value)
Optional.
Specifies the screen resolution.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
sr |
text | None | 20 Bytes | all |
800x600
sr=800x600
public java.lang.String screenResolution()
public T viewportSize(java.lang.String value)
Optional.
Specifies the viewable area of the browser / device.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
vp |
text | None | 20 Bytes | all |
123x456
vp=123x456
public java.lang.String viewportSize()
public T documentEncoding(java.lang.String value)
Optional.
Specifies the character set used to encode the page / document.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
de |
text | UTF-8
|
20 Bytes | all |
UTF-8
de=UTF-8
public java.lang.String documentEncoding()
public T screenColors(java.lang.String value)
Optional.
Specifies the screen color depth.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
sd |
text | None | 20 Bytes | all |
24-bits
sd=24-bits
public java.lang.String screenColors()
public T userLanguage(java.lang.String value)
Optional.
Specifies the language.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
ul |
text | None | 20 Bytes | all |
en-us
ul=en-us
public java.lang.String userLanguage()
public T javaEnabled(java.lang.Boolean value)
Optional.
Specifies whether Java was enabled.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
je |
boolean | None | None | all |
1
je=1
public java.lang.Boolean javaEnabled()
public T flashVersion(java.lang.String value)
Optional.
Specifies the flash version.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
fl |
text | None | 20 Bytes | all |
10 1 r103
fl=10%201%20r103
public java.lang.String flashVersion()
public T hitType(java.lang.String value)
Required for all hit types.
The type of hit. Must be one of 'pageview', 'appview', 'event', 'transaction', 'item', 'social', 'exception', 'timing'.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
t |
text | None | None | all |
pageview
t=pageview
public java.lang.String hitType()
public T nonInteractionHit(java.lang.String value)
Optional.
Specifies that a hit be considered non-interactive.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
ni |
boolean | None | None | all |
1
ni=1
public java.lang.String nonInteractionHit()
public T documentUrl(java.lang.String value)
Optional.
Use this parameter to send the full URL (document location) of the page on which content resides. You can use the &dh and &dp parameters to override the hostname and path + query portions of the document location, accordingly. The JavaScript clients determine this parameter using the concatenation of the document.location.origin + document.location.pathname + document.location.search browser parameters. Be sure to remove any user authentication or other private information from the URL if present.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
dl |
text | None | 2048 Bytes | all |
http://foo.com/home?a=b
dl=http%3A%2F%2Ffoo.com%2Fhome%3Fa%3Db
public java.lang.String documentUrl()
public T documentHostName(java.lang.String value)
Optional.
Specifies the hostname from which content was hosted.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
dh |
text | None | 100 Bytes | all |
foo.com
dh=foo.com
public java.lang.String documentHostName()
public T documentPath(java.lang.String value)
Optional.
The path portion of the page URL. Should begin with '/'.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
dp |
text | None | 2048 Bytes | all |
/foo
dp=%2Ffoo
public java.lang.String documentPath()
public T documentTitle(java.lang.String value)
Optional.
The title of the page / document.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
dt |
text | None | 1500 Bytes | all |
Settings
dt=Settings
public java.lang.String documentTitle()
public T contentDescription(java.lang.String value)
Optional.
If not specified, this will default to the unique URL of the page by either using the &dl parameter as-is or assembling it from &dh and &dp. App tracking makes use of this for the 'Screen Name' of the appview hit.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
cd |
text | None | 2048 Bytes | all |
High Scores
cd=High%20Scores
public java.lang.String contentDescription()
public T applicationName(java.lang.String value)
Optional.
Specifies the application name. Only visible in app views (profiles).
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
an |
text | None | 100 Bytes | all |
My App
an=My%20App
public java.lang.String applicationName()
public T applicationVersion(java.lang.String value)
Optional.
Specifies the application version. Only visible in app views (profiles).
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
av |
text | None | 100 Bytes | all |
1.2
av=1.2
public java.lang.String applicationVersion()
public T applicationID(java.lang.String value)
Optional.
Specifies the application ID. Only visible in app views (profiles).
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
aid |
text | None | 150 Bytes | all |
1.2
aid=1.2
public java.lang.String applicationID()
public T applicationInstallerID(java.lang.String value)
Optional.
Specifies the application installer ID. Only visible in app views (profiles).
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
aiid |
text | None | 150 Bytes | all |
1.2
aiid=1.2
public java.lang.String applicationInstallerID()
public T expirementId(java.lang.String value)
Optional.
This parameter specifies that this visitor has been exposed to an experiment with the given ID. It should be sent in conjunction with the Experiment Variant parameter.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
xid |
text | None | 40 Bytes | all |
Qp0gahJ3RAO3DJ18b0XoUQ
xid=Qp0gahJ3RAO3DJ18b0XoUQ
public java.lang.String expirementId()
public T expirementVariant(java.lang.String value)
Optional.
This parameter specifies that this visitor has been exposed to a particular variation of an experiment. It should be sent in conjunction with the Experiment ID parameter.
Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
---|---|---|---|---|
xvar |
text | None | None | all |
1
xvar=1
public java.lang.String expirementVariant()
public T userIp(java.lang.String value)
public java.lang.String userIp()
public T userAgent(java.lang.String value)
public java.lang.String userAgent()
protected boolean isEmpty(java.lang.String string)