public class GoogleAnalyticsRequest<T> extends 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 Map<String,String> |
customDimensions |
protected Map<String,String> |
customMetrics |
protected GoogleAnalyticsExecutor |
delegateExecutor |
protected Map<GoogleAnalyticsParameter,String> |
parms |
| Constructor and Description |
|---|
GoogleAnalyticsRequest() |
GoogleAnalyticsRequest(String hitType) |
GoogleAnalyticsRequest(String hitType,
String trackingId,
String appName,
String appVersion) |
protected Map<GoogleAnalyticsParameter,String> parms
protected GoogleAnalyticsExecutor delegateExecutor
public GoogleAnalyticsRequest()
public GoogleAnalyticsRequest(String hitType)
protected T setString(GoogleAnalyticsParameter parameter, String value)
parameter - value - protected String getString(GoogleAnalyticsParameter parameter)
protected T setInteger(GoogleAnalyticsParameter parameter, Integer value)
protected Double getDouble(GoogleAnalyticsParameter parameter)
protected T setDouble(GoogleAnalyticsParameter parameter, Double value)
protected Boolean getBoolean(GoogleAnalyticsParameter parameter)
protected T setBoolean(GoogleAnalyticsParameter parameter, Boolean value)
protected Integer getInteger(GoogleAnalyticsParameter parameter)
protected T parameter(GoogleAnalyticsParameter parameter, String value)
protected String parameter(GoogleAnalyticsParameter parameter)
public Map<GoogleAnalyticsParameter,String> getParameters()
public String customDimension(int index)
public T customDimension(int index, 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 |
Sportscd[1-9][0-9]*=Sports public T customMetric(int index, 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 |
47cm[1-9][0-9]*=47 public String customMetric(int index)
public T protocolVersion(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 |
1v=1 public String protocolVersion()
public T trackingId(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-Ytid=UA-XXXX-Y public String trackingId()
public T anonymizeIp(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 |
1aip=1 public Boolean anonymizeIp()
public T dataSource(String value)
Optional.
Indicates the data source of the hit. Hits sent from analytics.js will have data source set to 'web'; hits sent from one of the mobile SDKs will have data source set to 'app'.
| Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
|---|---|---|---|---|
ds |
text | None | None | all |
webds=web
Example value: appds=app
Example value: call centerds=call%20center
Example value: crmds=crm public String dataSource()
public T queueTime(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 |
560qt=560 public Integer queueTime()
public T cacheBuster(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 |
289372387623z=289372387623 public String cacheBuster()
public T clientId(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-2b884d0f825bcid=35009a79-1a05-49d7-b876-2b884d0f825b public String clientId()
public T userId(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 |
as8eknllluid=as8eknlll value - public String userId()
public T sessionControl(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 |
startsc=start endsc=end public String sessionControl()
public T documentReferrer(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.comdr=http%3A%2F%2Fexample.com public String documentReferrer()
public T campaignName(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 String campaignName()
public T campaignSource(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 String campaignSource()
public T campaignMedium(String value)
Optional.
Specifies the campaign medium.
| Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
|---|---|---|---|---|
cm |
text | None | 50 Bytes | all |
organiccm=organic public String campaignMedium()
public T campaignKeyword(String value)
Optional.
Specifies the campaign keyword.
| Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
|---|---|---|---|---|
ck |
text | None | 500 Bytes | all |
Blue Shoesck=Blue%20Shoes public String campaignKeyword()
public T campaignContent(String value)
Optional.
Specifies the campaign content.
| Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
|---|---|---|---|---|
cc |
text | None | 500 Bytes | all |
contentcc=content public String campaignContent()
public T campaignId(String value)
Optional.
Specifies the campaign ID.
| Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
|---|---|---|---|---|
ci |
text | None | 100 Bytes | all |
IDci=ID public String campaignId()
public T adwordsId(String value)
Optional.
Specifies the Google AdWords Id.
| Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
|---|---|---|---|---|
gclid |
text | None | None | all |
CL6Q-OXyqKUCFcgK2goddQuoHggclid=CL6Q-OXyqKUCFcgK2goddQuoHg public String adwordsId()
public T displayadId(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_iddclid=d_click_id public String displayadId()
public T screenResolution(String value)
Optional.
Specifies the screen resolution.
| Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
|---|---|---|---|---|
sr |
text | None | 20 Bytes | all |
800x600sr=800x600 public String screenResolution()
public T viewportSize(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 |
123x456vp=123x456 public String viewportSize()
public T documentEncoding(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-8de=UTF-8 public String documentEncoding()
public T screenColors(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-bitssd=24-bits public String screenColors()
public T userLanguage(String value)
Optional.
Specifies the language.
| Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
|---|---|---|---|---|
ul |
text | None | 20 Bytes | all |
en-usul=en-us public String userLanguage()
public T javaEnabled(Boolean value)
Optional.
Specifies whether Java was enabled.
| Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
|---|---|---|---|---|
je |
boolean | None | None | all |
1je=1 public Boolean javaEnabled()
public T flashVersion(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 r103fl=10%201%20r103 public String flashVersion()
public T hitType(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 |
pageviewt=pageview public String hitType()
public T nonInteractionHit(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 |
1ni=1 public String nonInteractionHit()
public T documentUrl(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=bdl=http%3A%2F%2Ffoo.com%2Fhome%3Fa%3Db public String documentUrl()
public T documentHostName(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.comdh=foo.com public String documentHostName()
public T documentPath(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 |
/foodp=%2Ffoo public String documentPath()
public T documentTitle(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 |
Settingsdt=Settings public String documentTitle()
public T contentDescription(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 Scorescd=High%20Scores public String contentDescription()
public T applicationName(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 Appan=My%20App public String applicationName()
public T applicationInstallerId(String value)
Optional.
Specifies the application installer identifier Only visible in app views (profiles).
| Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
|---|---|---|---|---|
aiid |
text | None | 150 Bytes | all |
com.platform.vendingaiid=com.platform.vending public String applicationInstallerId()
public T applicationVersion(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.2av=1.2 public String applicationVersion()
public T applicationId(String value)
Optional.
Specifies the application identifier. Only visible in app views (profiles).
| Parameter | Value Type | Default Value | Max Length | Supported Hit Types |
|---|---|---|---|---|
aid |
text | None | 150 Bytes | all |
com.company.appaid=com.company.app public String applicationId()
public T experimentId(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 |
Qp0gahJ3RAO3DJ18b0XoUQxid=Qp0gahJ3RAO3DJ18b0XoUQ public String experimentId()
public T experimentVariant(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 |
1xvar=1 public String experimentVariant()
public T userIp(String value)
public String userIp()
public T userAgent(String value)
public String userAgent()
public T geoid(String value)
public String geoid()
public GoogleAnalyticsResponse send()
public Future<GoogleAnalyticsResponse> sendAsync()
public GoogleAnalyticsRequest<T> setExecutor(GoogleAnalyticsExecutor delegateExecutor)
Copyright © Sep 2013–2018 Mike Hardy. All rights reserved.