public class TrackerConfiguration extends Object
EnableGoogleAnalytics
annotation on the
application's outermost router layout class. The layout class can also
implement TrackerConfigurator
to declaratively update the
configuration.Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_COOKIE_DOMAIN
The default cookie domain value.
|
Modifier and Type | Method and Description |
---|---|
static TrackerConfiguration |
create(EnableGoogleAnalytics.LogLevel logLevel,
boolean sendHits)
Creates a tracker configuration with default settings based on a log
level and whether to actually enable sending commands to Google
Analytics.
|
static TrackerConfiguration |
fromAnnotation(EnableGoogleAnalytics annotation,
boolean productionMode)
Creates a tracker configuration based on annotation values.
|
String |
getCookieDomain()
Gets the cookie domain setting.
|
Map<String,Serializable> |
getCreateFields()
Gets all the custom fields to pass when creating the client-side tracker.
|
Map<String,Serializable> |
getGaDebug()
Gets the
ga_debug values to use when creating a clients-side
tracker. |
Map<String,Serializable> |
getInitialValues()
Gets the initial value to set after creating a client-side tracker.
|
String |
getPageViewPrefix()
Gets the current page view prefix.
|
String |
getScriptUrl()
Gets the URL from which to load the Google Analytics script.
|
String |
getTrackingId()
Gets the Google Analytics tracking ID to use.
|
TrackerConfiguration |
removeCreateField(String name)
Removes a create field value.
|
TrackerConfiguration |
removeGaDebug(String name)
Removes a debug parameter value.
|
TrackerConfiguration |
removeInitialValue(String name)
Removes an initial value.
|
TrackerConfiguration |
setCookieDomain(String cookieDomain)
Sets the cookie domain value to use.
|
TrackerConfiguration |
setCreateField(String name,
Serializable value)
Sets a custom field value to use when creating the client-side tracker.
|
TrackerConfiguration |
setGaDebug(String name,
Serializable value)
Adds an entry that should be assigned to the
ga_debug
variable when the client-side tracker is initialized. |
TrackerConfiguration |
setInitialValue(String name,
Serializable value)
Sets a value that will be included in an initial
set
command. |
TrackerConfiguration |
setPageViewPrefix(String pageViewPrefix)
Sets a prefix that will be added to the location of all tracked page
views.
|
TrackerConfiguration |
setScriptUrl(String scriptUrl)
Sets the URL from which to load the Google Analytics script.
|
TrackerConfiguration |
setTrackingId(String trackingId)
Sets the Google Analytics tracking ID to use.
|
public static final String DEFAULT_COOKIE_DOMAIN
public String getTrackingId()
null
public TrackerConfiguration setTrackingId(String trackingId)
trackingId
- the tracking id to use, not null
and not an empty
stringpublic String getCookieDomain()
null
public TrackerConfiguration setCookieDomain(String cookieDomain)
cookieDomain
- the cookie domain value to set, or null
to
restore the default value.public TrackerConfiguration setPageViewPrefix(String pageViewPrefix)
pageViewPrefix
- a page view prefix to use, not null
public String getPageViewPrefix()
null
public TrackerConfiguration setScriptUrl(String scriptUrl)
scriptUrl
- the script URL to use, not null
public String getScriptUrl()
public TrackerConfiguration setCreateField(String name, Serializable value)
name
- the name of the field to set, not null
value
- the field valuepublic TrackerConfiguration removeCreateField(String name)
name
- the name of the field, not null
setCreateField(String, Serializable)
public TrackerConfiguration setInitialValue(String name, Serializable value)
set
command.name
- the name of the value, not null
value
- the value to setpublic TrackerConfiguration removeInitialValue(String name)
name
- the name of the value, not null
setInitialValue(String, Serializable)
public TrackerConfiguration setGaDebug(String name, Serializable value)
ga_debug
variable when the client-side tracker is initialized.name
- the parameter name, not null
value
- the valuepublic TrackerConfiguration removeGaDebug(String name)
name
- the parameter name, not null
setGaDebug(String, Serializable)
public Map<String,Serializable> getCreateFields()
null
setCreateField(String, Serializable)
public Map<String,Serializable> getInitialValues()
null
setInitialValue(String, Serializable)
public Map<String,Serializable> getGaDebug()
ga_debug
values to use when creating a clients-side
tracker.null
setGaDebug(String, Serializable)
public static TrackerConfiguration create(EnableGoogleAnalytics.LogLevel logLevel, boolean sendHits)
logLevel
- the log level to use, not null
sendHits
- whether to send commands to Google Analyticsnull
public static TrackerConfiguration fromAnnotation(EnableGoogleAnalytics annotation, boolean productionMode)
annotation
- the configuration annotation to useproductionMode
- whether to configure for production modenull
Copyright © 2023 Sami Ekblad. All rights reserved.