Package org.matomo.java.tracking
Class MatomoRequest
java.lang.Object
org.matomo.java.tracking.MatomoRequest
- Direct Known Subclasses:
PiwikRequest
A class that implements the
Matomo Tracking HTTP API. These requests can be sent using
MatomoTracker.- Author:
- brettcsorba
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMatomoRequest(int siteId, String actionUrl) Create a new request from the id of the site being tracked and the full url for the current action. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCustomTrackingParameter(@NonNull String key, @NonNull Object value) Add a custom tracking parameter to the specified key.voidaddEcommerceItem(@NonNull EcommerceItem item) Add anEcommerceItemto this order.voidaddParameter(@NonNull String key, @NonNull Object value) Add more values to the given parameterstatic MatomoRequestBuilderbuilder()voidRemoves all custom tracking parametersvoidClears allEcommerceItemfrom this order.voidSets idgoal=0 in the request to track an ecommerce interaction: cart update or an ecommerce order.Get the title of the action being trackedGet the amount of time it took the server to generate this action, in milliseconds.Deprecated.Deprecated.Get the api versionGet the authorization key.Get the campaign keywordGet the campaign nameGet the charset of the page being trackedGet the name of the interaction with the contentGet the name of the contentGet the content piece.Get the content targetGet the content targetGet the current hour.Get the current minute.Get the current secondGet the custom actiongetCustomTrackingParameter(@NonNull String key) Gets the list of objects currently stored at the specified custom tracking parameter.Get the resolution of the deviceGet the url of a file the user had downloadedGet the url of a file the user had downloadedGet the discount offered.Get the id of this order.getEcommerceItem(int index) Get theEcommerceItemat the specified indexGet the timestamp of the customer's last ecommerce orderGet the grand total of the ecommerce order.Get the shipping cost of the ecommerce order.Get the subtotal of the ecommerce order; excludes shipping.Get the tax amount of the ecommerce order.Get the event action.Get the event category.Get the event name.Get the event value.Get the goal idGet the goal revenue.Get the Accept-Language HTTP headerGet the User-Agent HTTP headerGet if this request will force a new visit.Get the outlink urlGet the outlink urlgetPageCustomVariable(int index) Get the page custom variable at the specified index.Deprecated.Use thegetPageCustomVariable(int)method instead.Check if the visitor has the Director plugin.Check if the visitor has the Flash plugin.Check if the visitor has the Gears plugin.Check if the visitor has the Java plugin.Check if the visitor has the PDF plugin.Check if the visitor has the Quicktime plugin.Check if the visitor has the RealPlayer plugin.Check if the visitor has the Silverlight plugin.Check if the visitor has the Windows Media plugin.Deprecated.static StringgetRandomHexString(int length) Get a random hexadecimal string of a specified length.Get the random value for this requestGet the referrer urlGet the referrer urlGet the datetime of the requestGet if this request will be tracked.Get if the response will be an image.Get the search categoryGet the search query.Get the search results count.Get the id of the website we're tracking.Set if bot requests should be trackedDeprecated.Deprecated.Use thegetVisitCustomVariable(int)method instead.Get the user id for this request.getVisitCustomVariable(int index) Get the visit custom variable at the specified index.Get the visitor's city.Get the visitor's country.Get the visitor's custom id.Get the timestamp of the visitor's first visit.Get the visitor's id.Get the visitor's ip.Get the visitor's latitude.Get the visitor's longitude.Get the timestamp of the visitor's previous visit.Get the visitor's region.Get the count of visits for this visitor.voidsetActionName(String actionName) Set the title of the action being tracked.voidsetActionTime(Long actionTime) Set the amount of time it took the server to generate this action, in milliseconds.voidsetActionUrl(@NonNull URL actionUrl) Deprecated.Please usesetActionUrl(String)voidsetActionUrl(String actionUrl) Set the full URL for the current action.voidsetActionUrlWithString(String actionUrl) Deprecated.Please usesetActionUrl(String)voidsetApiVersion(String apiVersion) Set the api version to use (currently always set to 1)voidsetAuthToken(String authToken) Set the 32 character authorization key used to authenticate the API request.voidsetCampaignKeyword(String campaignKeyword) Set the Campaign Keyword (see Tracking Campaigns).voidsetCampaignName(String campaignName) Set the Campaign Name (see Tracking Campaigns).voidsetCharacterSet(Charset characterSet) The charset of the page being tracked.voidsetContentInteraction(String contentInteraction) Set the name of the interaction with the content.voidsetContentName(String contentName) Set the name of the content.voidsetContentPiece(String contentPiece) Set the actual content piece.voidsetContentTarget(@NonNull URL contentTarget) Deprecated.Please usesetContentTarget(String)voidsetContentTarget(String contentTarget) Set the target of the content.voidsetContentTargetWithString(String contentTarget) Deprecated.Please usesetContentTarget(String)voidsetCurrentHour(Integer currentHour) Set the current hour (local time).voidsetCurrentMinute(Integer currentMinute) Set the current minute (local time).voidsetCurrentSecond(Integer currentSecond) Set the current second (local time).voidsetCustomAction(Boolean customAction) Set the custom action<T> voidsetCustomTrackingParameter(@NonNull String key, T value) Set a custom tracking parameter whose toString() value will be sent to the Matomo server.voidsetDeviceResolution(String deviceResolution) Set the resolution of the device the visitor is using, eg 1280x1024.voidsetDownloadUrl(@NonNull URL downloadUrl) Deprecated.Please usesetDownloadUrl(String)voidsetDownloadUrl(String downloadUrl) Set the url of a file the user has downloaded.voidsetDownloadUrlWithString(String downloadUrl) Deprecated.Please usesetDownloadUrl(String)voidsetEcommerceDiscount(Double discount) Set the discount offered.voidsetEcommerceId(String id) Set the unique string identifier for the ecommerce order (required when tracking an ecommerce order).voidsetEcommerceLastOrderTimestamp(Long timestamp) Set the UNUX timestamp of this customer's last ecommerce order.voidsetEcommerceRevenue(Double revenue) Set the grand total of the ecommerce order (required when tracking an ecommerce order).voidsetEcommerceShippingCost(Double shippingCost) Set the shipping cost of the ecommerce order.voidsetEcommerceSubtotal(Double subtotal) Set the subtotal of the ecommerce order; excludes shipping.voidsetEcommerceTax(Double tax) Set the tax amount of the ecommerce order.voidsetEventAction(String eventAction) Set the event action.voidsetEventCategory(String eventCategory) Set the event category.voidsetEventName(String eventName) Set the event name.voidsetEventValue(Number eventValue) Set the event value.voidSet the goal id.voidsetGoalRevenue(Double goalRevenue) Set a monetary value that was generated as revenue by this goal conversion.voidsetHeaderAcceptLanguage(String acceptLangage) Set an override value for the Accept-Language HTTP header field.voidsetHeaderUserAgent(String userAgent) Set an override value for the User-Agent HTTP header field.voidsetNewVisit(Boolean newVisit) If set to true, will force a new visit to be created for this action.voidsetOutlinkUrl(@NonNull URL outlinkUrl) Deprecated.Please usesetOutlinkUrl(String)voidsetOutlinkUrl(String outlinkUrl) Set an external URL the user has opened.voidsetOutlinkUrlWithString(String outlinkUrl) Deprecated.Please usesetOutlinkUrl(String)voidsetPageCustomVariable(String key, String value) Deprecated.Use thesetPageCustomVariable(CustomVariable, int)method instead.voidsetPageCustomVariable(CustomVariable customVariable, int index) Set a page custom variable at the specified index.voidsetParameter(@NonNull String key, Object value) Set a stored parameter.voidsetPluginDirector(Boolean director) Set if the visitor has the Director plugin.voidsetPluginFlash(Boolean flash) Set if the visitor has the Flash plugin.voidsetPluginGears(Boolean gears) Set if the visitor has the Gears plugin.voidsetPluginJava(Boolean java) Set if the visitor has the Java plugin.voidsetPluginPDF(Boolean pdf) Set if the visitor has the PDF plugin.voidsetPluginQuicktime(Boolean quicktime) Set if the visitor has the Quicktime plugin.voidsetPluginRealPlayer(Boolean realPlayer) Set if the visitor has the RealPlayer plugin.voidsetPluginSilverlight(Boolean silverlight) Set if the visitor has the Silverlight plugin.voidsetPluginWindowsMedia(Boolean windowsMedia) Set if the visitor has the Windows Media plugin.voidsetRandomValue(String randomValue) Set a random value that is generated before each request.voidsetReferrerUrl(@NonNull URL referrerUrl) Deprecated.Please usesetReferrerUrl(String)voidsetReferrerUrl(String referrerUrl) Set the full HTTP Referrer URL.voidsetReferrerUrlWithString(String referrerUrl) Deprecated.Please usesetReferrerUrl(String)voidsetRequestDatetime(MatomoDate datetime) Set the datetime of the request (normally the current time is used).voidsetRequired(Boolean required) Set if this request will be tracked by the Matomo server.voidsetResponseAsImage(Boolean responseAsImage) Set if the response will be an image.voidsetSearchCategory(String searchCategory) Specify a search category with this parameter.voidsetSearchQuery(String searchQuery) Set the search query.voidsetSearchResultsCount(Long searchResultsCount) We recommend to set the search count to the number of search results displayed on the results page.voidSet the ID of the website we're tracking a visit/action for.voidsetTrackBotRequests(Boolean trackBotRequests) By default Matomo does not track bots.voidsetUserCustomVariable(String key, String value) Deprecated.Use thesetVisitCustomVariable(CustomVariable, int)method instead.voidSet the user id for this request.voidsetVisitCustomVariable(CustomVariable customVariable, int index) Set a user custom variable at the specified key.voidsetVisitorCity(String city) Set an override value for the city.voidsetVisitorCountry(MatomoLocale country) Set an override value for the country.voidsetVisitorCustomId(String visitorCustomId) Set a custom visitor ID for this request.voidsetVisitorFirstVisitTimestamp(Long timestamp) Set the UNIX timestamp of this visitor's first visit.voidsetVisitorId(String visitorId) Set the unique visitor ID, must be a 16 characters hexadecimal string.voidsetVisitorIp(String visitorIp) Set the override value for the visitor IP (both IPv4 and IPv6 notations supported).voidsetVisitorLatitude(Double latitude) Set an override value for the visitor's latitude, eg 22.456.voidsetVisitorLongitude(Double longitude) Set an override value for the visitor's longitude, eg 22.456.voidsetVisitorPreviousVisitTimestamp(Long timestamp) Set the UNIX timestamp of this visitor's previous visit.voidsetVisitorRegion(String region) Set an override value for the region.voidsetVisitorVisitCount(Integer visitorVisitCount) Set the current count of visits for this visitor.voidVerifies that AuthToken has been set for this request.voidVerifies that Ecommerce has been enabled for the request.voidVerifies that Ecommerce has been enabled and that Ecommerce Id and Ecommerce Revenue have been set for the request.
-
Field Details
-
ID_LENGTH
public static final int ID_LENGTH- See Also:
-
AUTH_TOKEN_LENGTH
public static final int AUTH_TOKEN_LENGTH- See Also:
-
-
Constructor Details
-
MatomoRequest
Create a new request from the id of the site being tracked and the full url for the current action. This constructor also sets:
Overwrite these values yourself as desired.Required = true Visior Id = random 16 character hex string Random Value = random 20 character hex string API version = 1 Response as Image = false- Parameters:
siteId- the id of the website we're tracking a visit/action foractionUrl- the full URL for the current action
-
-
Method Details
-
builder
-
getActionName
Get the title of the action being tracked- Returns:
- the title of the action being tracked
-
setActionName
Set the title of the action being tracked. It is possible to use slashes / to set one or several categories for this action. For example, Help / Feedback will create the Action Feedback in the category Help.- Parameters:
actionName- the title of the action to set. A null value will remove this parameter
-
getActionTime
Get the amount of time it took the server to generate this action, in milliseconds.- Returns:
- the amount of time
-
setActionTime
Set the amount of time it took the server to generate this action, in milliseconds. This value is used to process the Page speed report Avg. generation time column in the Page URL and Page Title reports, as well as a site wide running average of the speed of your server.- Parameters:
actionTime- the amount of time to set. A null value will remove this parameter
-
getActionUrl
Deprecated.Please usegetActionUrlAsString()Get the full URL for the current action.- Returns:
- the full URL
-
getActionUrlAsString
Deprecated.Get the full URL for the current action.- Returns:
- the full URL
-
setActionUrl
Deprecated.Please usesetActionUrl(String)Set the full URL for the current action.- Parameters:
actionUrl- the full URL to set. A null value will remove this parameter
-
setActionUrl
Set the full URL for the current action.- Parameters:
actionUrl- the full URL to set. A null value will remove this parameter
-
setActionUrlWithString
Deprecated.Please usesetActionUrl(String)Set the full URL for the current action.- Parameters:
actionUrl- the full URL to set. A null value will remove this parameter
-
getApiVersion
Get the api version- Returns:
- the api version
-
setApiVersion
Set the api version to use (currently always set to 1)- Parameters:
apiVersion- the api version to set. A null value will remove this parameter
-
getAuthToken
Get the authorization key.- Returns:
- the authorization key
-
setAuthToken
Set the 32 character authorization key used to authenticate the API request.- Parameters:
authToken- the authorization key to set. A null value will remove this parameter
-
verifyAuthTokenSet
public void verifyAuthTokenSet()Verifies that AuthToken has been set for this request. Will throw anIllegalStateExceptionif not. -
getCampaignKeyword
Get the campaign keyword- Returns:
- the campaign keyword
-
setCampaignKeyword
Set the Campaign Keyword (see Tracking Campaigns). Used to populate the Referrers > Campaigns report (clicking on a campaign loads all keywords for this campaign). Note: this parameter will only be used for the first pageview of a visit.- Parameters:
campaignKeyword- the campaign keyword to set. A null value will remove this parameter
-
getCampaignName
Get the campaign name- Returns:
- the campaign name
-
setCampaignName
Set the Campaign Name (see Tracking Campaigns). Used to populate the Referrers > Campaigns report. Note: this parameter will only be used for the first pageview of a visit.- Parameters:
campaignName- the campaign name to set. A null value will remove this parameter
-
getCharacterSet
Get the charset of the page being tracked- Returns:
- the charset
-
setCharacterSet
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.- Parameters:
characterSet- the charset to set. A null value will remove this parameter
-
getContentInteraction
Get the name of the interaction with the content- Returns:
- the name of the interaction
-
setContentInteraction
Set the name of the interaction with the content. For instance a 'click'.- Parameters:
contentInteraction- the name of the interaction to set. A null value will remove this parameter
-
getContentName
Get the name of the content- Returns:
- the name
-
setContentName
Set the name of the content. For instance 'Ad Foo Bar'.- Parameters:
contentName- the name to set. A null value will remove this parameter
-
getContentPiece
Get the content piece.- Returns:
- the content piece.
-
setContentPiece
Set the actual content piece. For instance the path to an image, video, audio, any text.- Parameters:
contentPiece- the content piece to set. A null value will remove this parameter
-
getContentTarget
Get the content target- Returns:
- the target
-
getContentTargetAsString
Get the content target- Returns:
- the target
-
setContentTarget
Deprecated.Please usesetContentTarget(String)Set the target of the content. For instance the URL of a landing page.- Parameters:
contentTarget- the target to set. A null value will remove this parameter
-
setContentTarget
Set the target of the content. For instance the URL of a landing page.- Parameters:
contentTarget- the target to set. A null value will remove this parameter
-
setContentTargetWithString
Deprecated.Please usesetContentTarget(String)Set the target of the content. For instance the URL of a landing page.- Parameters:
contentTarget- the target to set. A null value will remove this parameter
-
getCurrentHour
Get the current hour.- Returns:
- the current hour
-
setCurrentHour
Set the current hour (local time).- Parameters:
currentHour- the hour to set. A null value will remove this parameter
-
getCurrentMinute
Get the current minute.- Returns:
- the current minute
-
setCurrentMinute
Set the current minute (local time).- Parameters:
currentMinute- the minute to set. A null value will remove this parameter
-
getCurrentSecond
Get the current second- Returns:
- the current second
-
setCurrentSecond
Set the current second (local time).- Parameters:
currentSecond- the second to set. A null value will remove this parameter
-
getCustomAction
Get the custom action- Returns:
- the custom action
-
setCustomAction
Set the custom action- Parameters:
customAction- the second to set. A null value will remove this parameter
-
getCustomTrackingParameter
Gets the list of objects currently stored at the specified custom tracking parameter. An empty list will be returned if there are no objects set at that key.- Parameters:
key- the key of the parameter whose list of objects to get. Cannot be null- Returns:
- the list of objects currently stored at the specified key
-
setCustomTrackingParameter
Set a custom tracking parameter whose toString() value will be sent to the Matomo server. These parameters are stored separately from named Matomo parameters, meaning it is not possible to overwrite or clear named Matomo parameters with this method. A custom parameter that has the same name as a named Matomo parameter will be sent in addition to that named parameter.- Parameters:
key- the parameter's key. Cannot be nullvalue- the parameter's value. Removes the parameter if null
-
addCustomTrackingParameter
public void addCustomTrackingParameter(@NonNull @NonNull String key, @NonNull @NonNull Object value) Add a custom tracking parameter to the specified key. This allows users to have multiple parameters with the same name and different values, commonly used during situations where list parameters are needed- Parameters:
key- the parameter's key. Cannot be nullvalue- the parameter's value. Cannot be null
-
clearCustomTrackingParameter
public void clearCustomTrackingParameter()Removes all custom tracking parameters -
getDeviceResolution
Get the resolution of the device- Returns:
- the resolution
-
setDeviceResolution
Set the resolution of the device the visitor is using, eg 1280x1024.- Parameters:
deviceResolution- the resolution to set. A null value will remove this parameter
-
getDownloadUrl
Get the url of a file the user had downloaded- Returns:
- the url
-
getDownloadUrlAsString
Get the url of a file the user had downloaded- Returns:
- the url
-
setDownloadUrl
Deprecated.Please usesetDownloadUrl(String)Set the url of a file the user has downloaded. Used for tracking downloads. We recommend to also set the url parameter to this same value.- Parameters:
downloadUrl- the url to set. A null value will remove this parameter
-
setDownloadUrl
Set the url of a file the user has downloaded. Used for tracking downloads. We recommend to also set the url parameter to this same value.- Parameters:
downloadUrl- the url to set. A null value will remove this parameter
-
setDownloadUrlWithString
Deprecated.Please usesetDownloadUrl(String)Set the url of a file the user has downloaded. Used for tracking downloads. We recommend to also set the url parameter to this same value.- Parameters:
downloadUrl- the url to set. A null value will remove this parameter
-
enableEcommerce
public void enableEcommerce()Sets idgoal=0 in the request to track an ecommerce interaction: cart update or an ecommerce order. -
verifyEcommerceEnabled
public void verifyEcommerceEnabled()Verifies that Ecommerce has been enabled for the request. Will throw anIllegalStateExceptionif not. -
verifyEcommerceState
public void verifyEcommerceState()Verifies that Ecommerce has been enabled and that Ecommerce Id and Ecommerce Revenue have been set for the request. Will throw anIllegalStateExceptionif not. -
getEcommerceDiscount
Get the discount offered.- Returns:
- the discount
-
setEcommerceDiscount
Set the discount offered. Ecommerce must be enabled, and EcommerceId and EcommerceRevenue must first be set.- Parameters:
discount- the discount to set. A null value will remove this parameter
-
getEcommerceId
Get the id of this order.- Returns:
- the id
-
setEcommerceId
Set the unique string identifier for the ecommerce order (required when tracking an ecommerce order). Ecommerce must be enabled.- Parameters:
id- the id to set. A null value will remove this parameter
-
getEcommerceItem
Get theEcommerceItemat the specified index- Parameters:
index- the index of theEcommerceItemto return- Returns:
- the
EcommerceItemat the specified index
-
addEcommerceItem
Add anEcommerceItemto this order. Ecommerce must be enabled, and EcommerceId and EcommerceRevenue must first be set.- Parameters:
item- theEcommerceItemto add. Cannot be null
-
clearEcommerceItems
public void clearEcommerceItems()Clears allEcommerceItemfrom this order. -
getEcommerceLastOrderTimestamp
Get the timestamp of the customer's last ecommerce order- Returns:
- the timestamp
-
setEcommerceLastOrderTimestamp
Set the UNUX timestamp of this customer's last ecommerce order. This value is used to process the "Days since last order" report. Ecommerce must be enabled, and EcommerceId and EcommerceRevenue must first be set.- Parameters:
timestamp- the timestamp to set. A null value will remove this parameter
-
getEcommerceRevenue
Get the grand total of the ecommerce order.- Returns:
- the grand total
-
setEcommerceRevenue
Set the grand total of the ecommerce order (required when tracking an ecommerce order). Ecommerce must be enabled.- Parameters:
revenue- the grand total to set. A null value will remove this parameter
-
getEcommerceShippingCost
Get the shipping cost of the ecommerce order.- Returns:
- the shipping cost
-
setEcommerceShippingCost
Set the shipping cost of the ecommerce order. Ecommerce must be enabled, and EcommerceId and EcommerceRevenue must first be set.- Parameters:
shippingCost- the shipping cost to set. A null value will remove this parameter
-
getEcommerceSubtotal
Get the subtotal of the ecommerce order; excludes shipping.- Returns:
- the subtotal
-
setEcommerceSubtotal
Set the subtotal of the ecommerce order; excludes shipping. Ecommerce must be enabled and EcommerceId and EcommerceRevenue must first be set.- Parameters:
subtotal- the subtotal to set. A null value will remove this parameter
-
getEcommerceTax
Get the tax amount of the ecommerce order.- Returns:
- the tax amount
-
setEcommerceTax
Set the tax amount of the ecommerce order. Ecommerce must be enabled, and EcommerceId and EcommerceRevenue must first be set.- Parameters:
tax- the tax amount to set. A null value will remove this parameter
-
getEventAction
Get the event action.- Returns:
- the event action
-
setEventAction
Set the event action. Must not be empty. (eg. Play, Pause, Duration, Add Playlist, Downloaded, Clicked...).- Parameters:
eventAction- the event action to set. A null value will remove this parameter
-
getEventCategory
Get the event category.- Returns:
- the event category
-
setEventCategory
Set the event category. Must not be empty. (eg. Videos, Music, Games...).- Parameters:
eventCategory- the event category to set. A null value will remove this parameter
-
getEventName
Get the event name.- Returns:
- the event name
-
setEventName
Set the event name. (eg. a Movie name, or Song name, or File name...).- Parameters:
eventName- the event name to set. A null value will remove this parameter
-
getEventValue
Get the event value.- Returns:
- the event value
-
setEventValue
Set the event value. Must be a float or integer value (numeric), not a string.- Parameters:
eventValue- the event value to set. A null value will remove this parameter
-
getGoalId
Get the goal id- Returns:
- the goal id
-
setGoalId
Set the goal id. If specified, the tracking request will trigger a conversion for the goal of the website being tracked with this id.- Parameters:
goalId- the goal id to set. A null value will remove this parameter
-
getGoalRevenue
Get the goal revenue.- Returns:
- the goal revenue
-
setGoalRevenue
Set a monetary value that was generated as revenue by this goal conversion. Only used if idgoal is specified in the request.- Parameters:
goalRevenue- the goal revenue to set. A null value will remove this parameter
-
getHeaderAcceptLanguage
Get the Accept-Language HTTP header- Returns:
- the Accept-Language HTTP header
-
setHeaderAcceptLanguage
Set 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.- Parameters:
acceptLangage- the Accept-Language HTTP header to set. A null value will remove this parameter
-
getHeaderUserAgent
Get the User-Agent HTTP header- Returns:
- the User-Agent HTTP header
-
setHeaderUserAgent
Set an override value for the User-Agent HTTP header field. The user agent is used to detect the operating system and browser used.- Parameters:
userAgent- the User-Agent HTTP header tos et
-
getNewVisit
Get if this request will force a new visit.- Returns:
- true if this request will force a new visit
-
setNewVisit
If set to true, will force a new visit to be created for this action.- Parameters:
newVisit- if this request will force a new visit
-
getOutlinkUrl
Get the outlink url- Returns:
- the outlink url
-
getOutlinkUrlAsString
Get the outlink url- Returns:
- the outlink url
-
setOutlinkUrl
Deprecated.Please usesetOutlinkUrl(String)Set an external URL the user has opened. Used for tracking outlink clicks. We recommend to also set the url parameter to this same value.- Parameters:
outlinkUrl- the outlink url to set. A null value will remove this parameter
-
setOutlinkUrl
Set an external URL the user has opened. Used for tracking outlink clicks. We recommend to also set the url parameter to this same value.- Parameters:
outlinkUrl- the outlink url to set. A null value will remove this parameter
-
setOutlinkUrlWithString
Deprecated.Please usesetOutlinkUrl(String)Set an external URL the user has opened. Used for tracking outlink clicks. We recommend to also set the url parameter to this same value.- Parameters:
outlinkUrl- the outlink url to set. A null value will remove this parameter
-
getPageCustomVariable
Deprecated.Use thegetPageCustomVariable(int)method instead.Get the page custom variable at the specified key.- Parameters:
key- the key of the variable to get- Returns:
- the variable at the specified key, null if key is not present
-
getPageCustomVariable
Get the page custom variable at the specified index.- Parameters:
index- the index of the variable to get. Must be greater than 0- Returns:
- the variable at the specified key, null if nothing at this index
-
setPageCustomVariable
Deprecated.Use thesetPageCustomVariable(CustomVariable, int)method instead.Set a page custom variable with the specified key and value at the first available index. All page custom variables with this key will be overwritten or deleted- Parameters:
key- the key of the variable to setvalue- the value of the variable to set at the specified key. A null value will remove this custom variable
-
setPageCustomVariable
Set a page custom variable at the specified index.- Parameters:
customVariable- the CustomVariable to set. A null value will remove the CustomVariable at the specified indexindex- the index of he CustomVariable to set
-
getPluginDirector
Check if the visitor has the Director plugin.- Returns:
- true if visitor has the Director plugin
-
setPluginDirector
Set if the visitor has the Director plugin.- Parameters:
director- true if the visitor has the Director plugin
-
getPluginFlash
Check if the visitor has the Flash plugin.- Returns:
- true if the visitor has the Flash plugin
-
setPluginFlash
Set if the visitor has the Flash plugin.- Parameters:
flash- true if the visitor has the Flash plugin
-
getPluginGears
Check if the visitor has the Gears plugin.- Returns:
- true if the visitor has the Gears plugin
-
setPluginGears
Set if the visitor has the Gears plugin.- Parameters:
gears- true if the visitor has the Gears plugin
-
getPluginJava
Check if the visitor has the Java plugin.- Returns:
- true if the visitor has the Java plugin
-
setPluginJava
Set if the visitor has the Java plugin.- Parameters:
java- true if the visitor has the Java plugin
-
getPluginPDF
Check if the visitor has the PDF plugin.- Returns:
- true if the visitor has the PDF plugin
-
setPluginPDF
Set if the visitor has the PDF plugin.- Parameters:
pdf- true if the visitor has the PDF plugin
-
getPluginQuicktime
Check if the visitor has the Quicktime plugin.- Returns:
- true if the visitor has the Quicktime plugin
-
setPluginQuicktime
Set if the visitor has the Quicktime plugin.- Parameters:
quicktime- true if the visitor has the Quicktime plugin
-
getPluginRealPlayer
Check if the visitor has the RealPlayer plugin.- Returns:
- true if the visitor has the RealPlayer plugin
-
setPluginRealPlayer
Set if the visitor has the RealPlayer plugin.- Parameters:
realPlayer- true if the visitor has the RealPlayer plugin
-
getPluginSilverlight
Check if the visitor has the Silverlight plugin.- Returns:
- true if the visitor has the Silverlight plugin
-
setPluginSilverlight
Set if the visitor has the Silverlight plugin.- Parameters:
silverlight- true if the visitor has the Silverlight plugin
-
getPluginWindowsMedia
Check if the visitor has the Windows Media plugin.- Returns:
- true if the visitor has the Windows Media plugin
-
setPluginWindowsMedia
Set if the visitor has the Windows Media plugin.- Parameters:
windowsMedia- true if the visitor has the Windows Media plugin
-
getRandomValue
Get the random value for this request- Returns:
- the random value
-
setRandomValue
Set a random value that is generated before each request. Using it helps avoid the tracking request being cached by the browser or a proxy.- Parameters:
randomValue- the random value to set. A null value will remove this parameter
-
getReferrerUrl
Get the referrer url- Returns:
- the referrer url
-
getReferrerUrlAsString
Get the referrer url- Returns:
- the referrer url
-
setReferrerUrl
Deprecated.Please usesetReferrerUrl(String)Set 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).- Parameters:
referrerUrl- the referrer url to set. A null value will remove this parameter
-
setReferrerUrl
Set 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).- Parameters:
referrerUrl- the referrer url to set. A null value will remove this parameter
-
setReferrerUrlWithString
Deprecated.Please usesetReferrerUrl(String)Set 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).- Parameters:
referrerUrl- the referrer url to set. A null value will remove this parameter
-
getRequestDatetime
Get the datetime of the request- Returns:
- the datetime of the request
-
setRequestDatetime
Set the datetime of the request (normally the current time is used). This can be used to record visits and page views in the past. The datetime must be sent in UTC timezone. Note: if you record data in the past, you will need to force Matomo to re-process reports for the past dates. If you set the Request Datetime to a datetime older than four hours then Auth Token must be set. If you set Request Datetime with a datetime in the last four hours then you don't need to pass Auth Token.- Parameters:
datetime- the datetime of the request to set. A null value will remove this parameter
-
getRequired
Get if this request will be tracked.- Returns:
- true if request will be tracked
-
setRequired
Set if this request will be tracked by the Matomo server.- Parameters:
required- true if request will be tracked
-
getResponseAsImage
Get if the response will be an image.- Returns:
- true if the response will be an an image
-
setResponseAsImage
Set if the response will be an image. If set to false, Matomo will respond with a 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 (eg Chrome Apps). Available since Matomo 2.10.0.- Parameters:
responseAsImage- true if the response will be an image
-
getSearchCategory
Get the search category- Returns:
- the search category
-
setSearchCategory
Specify a search category with this parameter. SearchQuery must first be set.- Parameters:
searchCategory- the search category to set. A null value will remove this parameter
-
getSearchQuery
Get the search query.- Returns:
- the search query
-
setSearchQuery
Set the search query. When specified, the request will not be tracked as a normal pageview but will instead be tracked as a Site Search request.- Parameters:
searchQuery- the search query to set. A null value will remove this parameter
-
getSearchResultsCount
Get the search results count.- Returns:
- the search results count
-
setSearchResultsCount
We recommend to set the search count to the number of search results displayed on the results page. When keywords are tracked withSearch Results Count=0they will appear in the "No Result Search Keyword" report. SearchQuery must first be set.- Parameters:
searchResultsCount- the search results count to set. A null value will remove this parameter
-
getSiteId
Get the id of the website we're tracking.- Returns:
- the id of the website
-
setSiteId
Set the ID of the website we're tracking a visit/action for.- Parameters:
siteId- the id of the website to set. A null value will remove this parameter
-
getTrackBotRequests
Set if bot requests should be tracked- Returns:
- true if bot requests should be tracked
-
setTrackBotRequests
By default Matomo does not track bots. If you use the Tracking Java API, you may be interested in tracking bot requests. To enable Bot Tracking in Matomo, set Track Bot Requests to true.- Parameters:
trackBotRequests- true if bot requests should be tracked
-
getUserCustomVariable
Deprecated.Use thegetVisitCustomVariable(int)method instead.Get the visit custom variable at the specified key.- Parameters:
key- the key of the variable to get- Returns:
- the variable at the specified key, null if key is not present
-
getVisitCustomVariable
Get the visit custom variable at the specified index.- Parameters:
index- the index of the variable to get- Returns:
- the variable at the specified index, null if nothing at this index
-
setUserCustomVariable
Deprecated.Use thesetVisitCustomVariable(CustomVariable, int)method instead.Set a visit custom variable with the specified key and value at the first available index. All visit custom variables with this key will be overwritten or deleted- Parameters:
key- the key of the variable to setvalue- the value of the variable to set at the specified key. A null value will remove this parameter
-
setVisitCustomVariable
Set a user custom variable at the specified key.- Parameters:
customVariable- the CustomVariable to set. A null value will remove the custom variable at the specified indexindex- the index to set the customVariable at.
-
getUserId
Get the user id for this request.- Returns:
- the user id
-
setUserId
Set 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). To access this value, users must be logged-in in your system so you can fetch this user id from your system, and pass it to Matomo. The user id appears in the visitor log, the Visitor profile, and you can Segment reports for one or several user ids. 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.- Parameters:
userId- the user id to set. A null value will remove this parameter
-
getVisitorCity
Get the visitor's city.- Returns:
- the visitor's city
-
setVisitorCity
Set an override value for the city. The name of the city the visitor is located in, eg, Tokyo. AuthToken must first be set.- Parameters:
city- the visitor's city to set. A null value will remove this parameter
-
getVisitorCountry
Get the visitor's country.- Returns:
- the visitor's country
-
setVisitorCountry
Set an override value for the country. AuthToken must first be set.- Parameters:
country- the visitor's country to set. A null value will remove this parameter
-
getVisitorCustomId
Get the visitor's custom id.- Returns:
- the visitor's custom id
-
setVisitorCustomId
Set a custom visitor ID for this request. You must set this value to exactly a 16 character hexadecimal string (containing only characters 01234567890abcdefABCDEF). We recommended to set the UserId rather than the VisitorCustomId.- Parameters:
visitorCustomId- the visitor's custom id to set. A null value will remove this parameter
-
getVisitorFirstVisitTimestamp
Get the timestamp of the visitor's first visit.- Returns:
- the timestamp of the visitor's first visit
-
setVisitorFirstVisitTimestamp
Set 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. This parameter is used to populate the Goals > Days to Conversion report.- Parameters:
timestamp- the timestamp of the visitor's first visit to set. A null value will remove this parameter
-
getVisitorId
Get the visitor's id.- Returns:
- the visitor's id
-
setVisitorId
Set the unique visitor ID, must be a 16 characters hexadecimal string. Every unique visitor must be assigned a different ID and this ID must not change after it is assigned. If this value is not set Matomo will still track visits, but the unique visitors metric might be less accurate.- Parameters:
visitorId- the visitor id to set. A null value will remove this parameter
-
getVisitorIp
Get the visitor's ip.- Returns:
- the visitor's ip
-
setVisitorIp
Set the override value for the visitor IP (both IPv4 and IPv6 notations supported). AuthToken must first be set.- Parameters:
visitorIp- the visitor's ip to set. A null value will remove this parameter
-
getVisitorLatitude
Get the visitor's latitude.- Returns:
- the visitor's latitude
-
setVisitorLatitude
Set an override value for the visitor's latitude, eg 22.456. AuthToken must first be set.- Parameters:
latitude- the visitor's latitude to set. A null value will remove this parameter
-
getVisitorLongitude
Get the visitor's longitude.- Returns:
- the visitor's longitude
-
setVisitorLongitude
Set an override value for the visitor's longitude, eg 22.456. AuthToken must first be set.- Parameters:
longitude- the visitor's longitude to set. A null value will remove this parameter
-
getVisitorPreviousVisitTimestamp
Get the timestamp of the visitor's previous visit.- Returns:
- the timestamp of the visitor's previous visit
-
setVisitorPreviousVisitTimestamp
Set 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.- Parameters:
timestamp- the timestamp of the visitor's previous visit to set. A null value will remove this parameter
-
getVisitorRegion
Get the visitor's region.- Returns:
- the visitor's region
-
setVisitorRegion
Set an override value for the region. Should be set to the two letter region code as defined by MaxMind's GeoIP databases. See here for a list of them for every country (the region codes are located in the second column, to the left of the region name and to the right of the country code).- Parameters:
region- the visitor's region to set. A null value will remove this parameter
-
getVisitorVisitCount
Get the count of visits for this visitor.- Returns:
- the count of visits for this visitor
-
setVisitorVisitCount
Set 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. This value is used to populate the report Visitors > Engagement > Visits by visit number.- Parameters:
visitorVisitCount- the count of visits for this visitor to set. A null value will remove this parameter
-
getParameters
-
getQueryString
Deprecated.Get the query string represented by this object.- Returns:
- the query string represented by this object
-
getUrlEncodedQueryString
Deprecated.Get the url encoded query string represented by this object.- Returns:
- the url encoded query string represented by this object
-
getRandomHexString
Get a random hexadecimal string of a specified length.- Parameters:
length- length of the string to produce- Returns:
- a random string consisting only of hexadecimal characters
-
setParameter
Set a stored parameter.- Parameters:
key- the parameter's keyvalue- the parameter's value. Removes the parameter if null
-
addParameter
Add more values to the given parameter- Parameters:
key- the parameter's key. Must not be nullvalue- the parameter's value. Must not be null
-
getActionUrlAsString()