Class MatomoRequest.MatomoRequestBuilder
- Direct Known Subclasses:
MatomoRequestBuilder
- Enclosing class:
- MatomoRequest
-
Method Summary
Modifier and TypeMethodDescriptionactionName
(String actionName) The title of the action being tracked.The full URL for the current action.additionalParameters
(Map<String, Object> additionalParameters) Allows you to specify additional HTTP request parameters that will be sent to Matomo.apiVersion
(String apiVersion) Defines the API version to use (default: 1).32 character authorization key used to authenticate the API request.build()
campaignKeyword
(String campaignKeyword) The campaign keyword (see Tracking Campaigns).campaignName
(String campaignName) The campaign name.characterSet
(Charset characterSet) The charset of the page being tracked.contentInteraction
(String contentInteraction) The name of the interaction with the content.contentName
(String contentName) The name of the content.contentPiece
(String contentPiece) The actual content piece.contentTarget
(String contentTarget) The target of the content.Appends additional cookies to the request.crashCategory
(String crashCategory) Category of a crash to group crashes by.crashColumn
(Integer crashColumn) The column within the line where the crash occurred.The line number of the crash source, where the crash occurred.crashLocation
(String crashLocation) The originating source of the crash.crashMessage
(String crashMessage) Contains an error message describing the error that occurred during the last tracking request.crashStackTrace
(String crashStackTrace) A stack trace of the exception that occurred during the last tracking request.The type of exception that occurred during the last tracking request.currentHour
(Integer currentHour) The current hour (local time).currentMinute
(Integer currentMinute) The current minute (local time).currentSecond
(Integer currentSecond) The current second (local time).customAction
(Boolean customAction) can be optionally sent along any tracking request that isn't a page view.Meant to hold a random value that is generated before each request.deviceResolution
(DeviceResolution deviceResolution) The resolution of the device the visitor is using.dimensions
(Map<Long, Object> dimensions) Custom Dimension values for specific Custom Dimension IDs.domCompletionTime
(Long domCompletionTime) How long it takes for the browser to load media and execute any Javascript code listening for the DOMContentLoaded event.domProcessingTime
(Long domProcessingTime) How long the browser spends loading the webpage after the response was fully received until the user can start interacting with it.downloadUrl
(String downloadUrl) URL of a file the user has downloaded.ecommerceDiscount
(Double ecommerceDiscount) Discount offered.ecommerceId
(String ecommerceId) The unique string identifier for the ecommerce order (required when tracking an ecommerce order).ecommerceItems
(EcommerceItems ecommerceItems) Items in the Ecommerce order.ecommerceLastOrderTimestamp
(Instant ecommerceLastOrderTimestamp) The UNIX timestamp of this customer's last ecommerce order.ecommerceRevenue
(Double ecommerceRevenue) The grand total for the ecommerce order (required when tracking an ecommerce order).ecommerceShippingCost
(Double ecommerceShippingCost) Shipping cost of the order.ecommerceSubtotal
(Double ecommerceSubtotal) The subtotal of the order; excludes shipping.ecommerceTax
(Double ecommerceTax) Tax amount of the order.eventAction
(String eventAction) An event action like Play, Pause, Duration, Add Playlist, Downloaded, Clicked...eventCategory
(String eventCategory) eg.The event name for example a Movie name, or Song name, or File name...eventValue
(Double eventValue) Some numeric value that represents the event value.If specified, the tracking request will trigger a conversion for the goal of the website being tracked with this ID.headerAcceptLanguage
(AcceptLanguage headerAcceptLanguage) An override value for the Accept-Language HTTP header field.You can set additional HTTP headers for the request sent to Matomo.headerUserAgent
(String headerUserAgent) An override value for the User-Agent HTTP header field.networkTime
(Long networkTime) How long it took to connect to server.will force a new visit to be created for this action.newVisitor
(Boolean newVisitor) Tracks if the visitor is a returning visitor.onloadTime
(Long onloadTime) How long it takes the browser to execute Javascript code waiting for the window.load event.outlinkUrl
(String outlinkUrl) An external URL the user has opened.pageCustomVariables
(CustomVariables pageCustomVariables) Custom variables are custom name-value pairs that you can assign to your visitors (or page views).pageViewId
(UniqueId pageViewId) Accepts a six character unique ID that identifies which actions were performed on a specific page view.If set to true, the request will be a Heartbeat request which will not track any new activity (such as a new visit, new action or new goal).pluginDirector
(Boolean pluginDirector) Does the visitor use Director plugin.pluginFlash
(Boolean pluginFlash) Does the visitor use the Adobe Flash Plugin.pluginGears
(Boolean pluginGears) Does the visitor use a Gears plugin.pluginJava
(Boolean pluginJava) Does the visitor use the Java plugin.Does the visitor use a PDF plugin.pluginQuicktime
(Boolean pluginQuicktime) Does the visitor use Quicktime plugin.pluginRealPlayer
(Boolean pluginRealPlayer) Does the visitor use Realplayer plugin.pluginSilverlight
(Boolean pluginSilverlight) Does the visitor use a Silverlight plugin.pluginWindowsMedia
(Boolean pluginWindowsMedia) Does the visitor use a Windows Media plugin.queuedTracking
(Boolean queuedTracking) When set to false, the queued tracking handler won't be used and instead the tracking request will be executed directly.randomValue
(RandomValue randomValue) Meant to hold a random value that is generated before each request.referrerUrl
(String referrerUrl) The full HTTP Referrer URL.requestTimestamp
(Instant requestTimestamp) Override for the datetime of the request (normally the current time is used).The ID of the website we're tracking a visit/action for.responseAsImage
(Boolean responseAsImage) If set to 0 (send_image=0) Matomo will respond with an HTTP 204 response code instead of a GIF image.searchCategory
(String searchCategory) When search is specified, you can optionally specify a search category with this parameter.searchQuery
(String searchQuery) The Site Search keyword.searchResultsCount
(Long searchResultsCount) When search is specified, we also recommend setting the search_count to the number of search results displayed on the results page.serverTime
(Long serverTime) How long it took the server to generate page.The Matomo session ID sent as a cookieMATOMO_SESSID
.The ID of the website we're tracking a visit/action for.supportsCookies
(Boolean supportsCookies) Does the visitor's client is known to support cookies.toString()
trackBotRequests
(Boolean trackBotRequests) By default, Matomo does not track bots.transferTime
(Long transferTime) How long it takes the browser to download the response from the server.Defines the User ID for this request.visitCustomVariables
(CustomVariables visitCustomVariables) Custom variables are custom name-value pairs that you can assign to your visitors (or page views).visitorCity
(String visitorCity) An override value for the city.visitorCountry
(Country visitorCountry) An override value for the country.visitorCustomId
(VisitorId visitorCustomId) defines the visitor ID for this request.visitorFirstVisitTimestamp
(Instant visitorFirstVisitTimestamp) The UNIX timestamp of this visitor's first visit.The unique visitor ID.Override value for the visitor IP (both IPv4 and IPv6 notations supported).visitorLatitude
(Double visitorLatitude) An override value for the visitor's latitude, eg 22.456.visitorLongitude
(Double visitorLongitude) An override value for the visitor's longitude, eg 22.456.visitorPreviousVisitTimestamp
(Instant visitorPreviousVisitTimestamp) The UNIX timestamp of this visitor's previous visit.visitorRegion
(String visitorRegion) An override value for the region.visitorVisitCount
(Integer visitorVisitCount) The current count of visits for this visitor.
-
Method Details
-
required
The ID of the website we're tracking a visit/action for. Only needed, if no default site id is configured.- Returns:
this
.
-
siteId
The ID of the website we're tracking a visit/action for. Only needed, if no default site id is configured.- Returns:
this
.
-
actionName
The title of the action being tracked. For page tracks this is used as page title. If enabled in your installation you may use the category tree structure in this field. For example, "game / register new user" would then create a group "game" and add the item "register new user" in it.- Returns:
this
.
-
actionUrl
The full URL for the current action.- Returns:
this
.
-
apiVersion
Defines the API version to use (default: 1).- Returns:
this
.
-
visitorId
The unique visitor ID. SeeVisitorId
. Default isVisitorId.random()
Since version 3.0.0 this parameter is of type
VisitorId
and not a String anymore. UseVisitorId.fromHex(String)
to create a VisitorId from a hex string,VisitorId.fromUUID(UUID)
to create it from a UUID orVisitorId.fromHash(long)
to create it from a long value.- Returns:
this
.
-
newVisitor
Tracks if the visitor is a returning visitor.This is done by storing a visitor ID in a 1st party cookie.
- Returns:
this
.
-
referrerUrl
The full HTTP Referrer URL. This value is used to determine how someone got to your website (ie, through a website, search engine or campaign)- Returns:
this
.
-
visitCustomVariables
public MatomoRequest.MatomoRequestBuilder visitCustomVariables(CustomVariables visitCustomVariables) Custom variables are custom name-value pairs that you can assign to your visitors (or page views).- Returns:
this
.
-
visitorVisitCount
The current count of visits for this visitor. To set this value correctly, it would be required to store the value for each visitor in your application (using sessions or persisting in a database). Then you would manually increment the counts by one on each new visit or "session", depending on how you choose to define a visit.- Returns:
this
.
-
visitorPreviousVisitTimestamp
public MatomoRequest.MatomoRequestBuilder visitorPreviousVisitTimestamp(Instant visitorPreviousVisitTimestamp) The UNIX timestamp of this visitor's previous visit. This parameter is used to populate the report Visitors > Engagement > Visits by days since last visit.- Returns:
this
.
-
visitorFirstVisitTimestamp
public MatomoRequest.MatomoRequestBuilder visitorFirstVisitTimestamp(Instant visitorFirstVisitTimestamp) The UNIX timestamp of this visitor's first visit. This could be set to the date where the user first started using your software/app, or when he/she created an account.- Returns:
this
.
-
campaignName
The campaign name. This parameter will only be used for the first pageview of a visit.- Returns:
this
.
-
campaignKeyword
The campaign keyword (see Tracking Campaigns). Used to populate the Referrers > Campaigns report (clicking on a campaign loads all keywords for this campaign). This parameter will only be used for the first pageview of a visit.- Returns:
this
.
-
deviceResolution
The resolution of the device the visitor is using.- Returns:
this
.
-
currentHour
The current hour (local time).- Returns:
this
.
-
currentMinute
The current minute (local time).- Returns:
this
.
-
currentSecond
The current second (local time).- Returns:
this
.
-
pluginFlash
Does the visitor use the Adobe Flash Plugin.- Returns:
this
.
-
pluginJava
Does the visitor use the Java plugin.- Returns:
this
.
-
pluginDirector
Does the visitor use Director plugin.- Returns:
this
.
-
pluginQuicktime
Does the visitor use Quicktime plugin.- Returns:
this
.
-
pluginRealPlayer
Does the visitor use Realplayer plugin.- Returns:
this
.
-
pluginPDF
Does the visitor use a PDF plugin.- Returns:
this
.
-
pluginWindowsMedia
Does the visitor use a Windows Media plugin.- Returns:
this
.
-
pluginGears
Does the visitor use a Gears plugin.- Returns:
this
.
-
pluginSilverlight
Does the visitor use a Silverlight plugin.- Returns:
this
.
-
supportsCookies
Does the visitor's client is known to support cookies.- Returns:
this
.
-
headerUserAgent
An override value for the User-Agent HTTP header field.- Returns:
this
.
-
headerAcceptLanguage
An override value for the Accept-Language HTTP header field. This value is used to detect the visitor's country if GeoIP is not enabled.- Returns:
this
.
-
userId
Defines the User ID for this request. User ID is any non-empty unique string identifying the user (such as an email address or a username). When specified, the User ID will be "enforced". This means that if there is no recent visit with this User ID, a new one will be created. If a visit is found in the last 30 minutes with your specified User ID, then the new action will be recorded to this existing visit.- Returns:
this
.
-
visitorCustomId
defines the visitor ID for this request.- Returns:
this
.
-
newVisit
will force a new visit to be created for this action.- Returns:
this
.
-
pageCustomVariables
Custom variables are custom name-value pairs that you can assign to your visitors (or page views).- Returns:
this
.
-
outlinkUrl
An external URL the user has opened. Used for tracking outlink clicks. We recommend to also set the url parameter to this same value.- Returns:
this
.
-
downloadUrl
URL of a file the user has downloaded. Used for tracking downloads. We recommend to also set the url parameter to this same value.- Returns:
this
.
-
searchQuery
The Site Search keyword. When specified, the request will not be tracked as a normal pageview but will instead be tracked as a Site Search request- Returns:
this
.
-
searchCategory
When search is specified, you can optionally specify a search category with this parameter.- Returns:
this
.
-
searchResultsCount
When search is specified, we also recommend setting the search_count to the number of search results displayed on the results page. When keywords are tracked with &search_count=0 they will appear in the "No Result Search Keyword" report.- Returns:
this
.
-
pageViewId
Accepts a six character unique ID that identifies which actions were performed on a specific page view. When a page was viewed, all following tracking requests (such as events) during that page view should use the same pageview ID. Once another page was viewed a new unique ID should be generated. Use [0-9a-Z] as possible characters for the unique ID.- Returns:
this
.
-
goalId
If specified, the tracking request will trigger a conversion for the goal of the website being tracked with this ID. The value 0 tracks an ecommerce interaction.- Returns:
this
.
-
ecommerceRevenue
The grand total for the ecommerce order (required when tracking an ecommerce order).- Returns:
this
.
-
characterSet
The charset of the page being tracked. Specify the charset if the data you send to Matomo is encoded in a different character set than the default utf-8- Returns:
this
.
-
customAction
can be optionally sent along any tracking request that isn't a page view. For example, it can be sent together with an event tracking request. The advantage being that should you ever disable the event plugin, then the event tracking requests will be ignored vs if the parameter is not set, a page view would be tracked even though it isn't a page view.- Returns:
this
.
-
networkTime
How long it took to connect to server.- Returns:
this
.
-
serverTime
How long it took the server to generate page.- Returns:
this
.
-
transferTime
How long it takes the browser to download the response from the server.- Returns:
this
.
-
domProcessingTime
How long the browser spends loading the webpage after the response was fully received until the user can start interacting with it.- Returns:
this
.
-
domCompletionTime
How long it takes for the browser to load media and execute any Javascript code listening for the DOMContentLoaded event.- Returns:
this
.
-
onloadTime
How long it takes the browser to execute Javascript code waiting for the window.load event.- Returns:
this
.
-
eventCategory
eg. Videos, Music, Games...- Returns:
this
.
-
eventAction
An event action like Play, Pause, Duration, Add Playlist, Downloaded, Clicked...- Returns:
this
.
-
eventName
The event name for example a Movie name, or Song name, or File name...- Returns:
this
.
-
eventValue
Some numeric value that represents the event value.- Returns:
this
.
-
contentName
The name of the content. For instance 'Ad Foo Bar'- Returns:
this
.
-
contentPiece
The actual content piece. For instance the path to an image, video, audio, any text- Returns:
this
.
-
contentTarget
The target of the content. For instance the URL of a landing page- Returns:
this
.
-
contentInteraction
The name of the interaction with the content. For instance a 'click'- Returns:
this
.
-
ecommerceId
The unique string identifier for the ecommerce order (required when tracking an ecommerce order).- Returns:
this
.
-
ecommerceItems
Items in the Ecommerce order.- Returns:
this
.
-
ecommerceSubtotal
The subtotal of the order; excludes shipping.- Returns:
this
.
-
ecommerceTax
Tax amount of the order.- Returns:
this
.
-
ecommerceShippingCost
Shipping cost of the order.- Returns:
this
.
-
ecommerceDiscount
Discount offered.- Returns:
this
.
-
ecommerceLastOrderTimestamp
public MatomoRequest.MatomoRequestBuilder ecommerceLastOrderTimestamp(Instant ecommerceLastOrderTimestamp) The UNIX timestamp of this customer's last ecommerce order. This value is used to process the "Days since last order" report.- Returns:
this
.
-
authToken
32 character authorization key used to authenticate the API request. We recommend to create a user specifically for accessing the Tracking API, and give the user only write permission on the website(s).- Returns:
this
.
-
visitorIp
Override value for the visitor IP (both IPv4 and IPv6 notations supported).- Returns:
this
.
-
requestTimestamp
Override for the datetime of the request (normally the current time is used). This can be used to record visits and page views in the past.- Returns:
this
.
-
visitorCountry
An override value for the country. Must be a two-letter ISO 3166 Alpha-2 country code.- Returns:
this
.
-
visitorRegion
An override value for the region. Should be set to a ISO 3166-2 region code, which are used by MaxMind's and DB-IP's GeoIP2 databases. See here for a list of them for every country.- Returns:
this
.
-
visitorCity
An override value for the city. The name of the city the visitor is located in, eg, Tokyo.- Returns:
this
.
-
visitorLatitude
An override value for the visitor's latitude, eg 22.456.- Returns:
this
.
-
visitorLongitude
An override value for the visitor's longitude, eg 22.456.- Returns:
this
.
-
queuedTracking
When set to false, the queued tracking handler won't be used and instead the tracking request will be executed directly. This can be useful when you need to debug a tracking problem or want to test that the tracking works in general.- Returns:
this
.
-
responseAsImage
If set to 0 (send_image=0) Matomo will respond with an HTTP 204 response code instead of a GIF image. This improves performance and can fix errors if images are not allowed to be obtained directly (like Chrome Apps). Available since Matomo 2.10.0Default is
false
- Returns:
this
.
-
ping
If set to true, the request will be a Heartbeat request which will not track any new activity (such as a new visit, new action or new goal). The heartbeat request will only update the visit's total time to provide accurate "Visit duration" metric when this parameter is set. It won't record any other data. This means by sending an additional tracking request when the user leaves your site or app with &ping=1, you fix the issue where the time spent of the last page visited is reported as 0 seconds.- Returns:
this
.
-
trackBotRequests
By default, Matomo does not track bots. If you use the Tracking HTTP API directly, you may be interested in tracking bot requests.- Returns:
this
.
-
randomValue
Meant to hold a random value that is generated before each request. Using it helps avoid the tracking request being cached by the browser or a proxy.- Returns:
this
.
-
debug
Meant to hold a random value that is generated before each request. Using it helps avoid the tracking request being cached by the browser or a proxy.- Returns:
this
.
-
crashMessage
Contains an error message describing the error that occurred during the last tracking request.Custom action must be enabled for this.
Required for crash analytics
- Returns:
this
.
-
crashType
The type of exception that occurred during the last tracking request.Custom action must be enabled for this.
Typically a fully qualified class name of the exception, e.g.
java.lang.NullPointerException
.Optional for crash analytics
- Returns:
this
.
-
crashCategory
Category of a crash to group crashes by.Custom action must be enabled for this.
Optional for crash analytics
- Returns:
this
.
-
crashStackTrace
A stack trace of the exception that occurred during the last tracking request.Custom action must be enabled for this.
Optional for crash analytics
- Returns:
this
.
-
crashLocation
The originating source of the crash.Could be a source file URI or something similar
Custom action must be enabled for this.
Optional for crash analytics
- Returns:
this
.
-
crashLine
The line number of the crash source, where the crash occurred.Custom action must be enabled for this.
Optional for crash analytics
- Returns:
this
.
-
crashColumn
The column within the line where the crash occurred.Optional for crash analytics
- Returns:
this
.
-
sessionId
The Matomo session ID sent as a cookieMATOMO_SESSID
.If not null a cookie with the name
MATOMO_SESSID
will be sent with the value of this parameter.- Returns:
this
.
-
dimensions
Custom Dimension values for specific Custom Dimension IDs.Custom Dimensions plugin must be installed. See the Custom Dimensions guide. Requires Matomo at least 2.15.1
- Returns:
this
.
-
additionalParameters
public MatomoRequest.MatomoRequestBuilder additionalParameters(Map<String, Object> additionalParameters) Allows you to specify additional HTTP request parameters that will be sent to Matomo.For example, you can use this to set the Accept-Language header, or to set the Content-Type.
- Returns:
this
.
-
headers
You can set additional HTTP headers for the request sent to Matomo.For example, you can use this to set the Accept-Language header, or to set the Content-Type.
- Returns:
this
.
-
cookies
Appends additional cookies to the request.This allows you to add Matomo specific cookies, like
_pk_id
or_pk_sess
coming from Matomo responses to the request.- Returns:
this
.
-
build
-
toString
-