MatomoForever class

MatomoForever standardize the way the Matomo tracking is used.

Constructors

MatomoForever()

Properties

apiV String?
apiV The parameter &apiv=1 defines the api version to use (currently always set to 1)
getter/setter pair
bots bool?
bots By default Matomo does not track bots. If you use the Tracking HTTP API directly, you may be interested in tracking bot requests. To enable Bot Tracking in Matomo, set the parameter bots to true (&bots=1) in your requests to matomo.php.
getter/setter pair
bulkSize int
bulkSize Max size the local queue can reach before sending the bulk of requests. If <= 0, no bulk mechanism. requests are sent straight away. Bulk sending requires tokenAuth to be set.
getter/setter pair
client ↔ BaseClient?
client To be used instead of the default one to communicate with the server.
getter/setter pair
debug bool?
debug If Matomo server is configured with debug_on_demand = 1, debug can be set to true (1)
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>?
headers The headers to be sent along with request.
getter/setter pair
id String?
id 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 (formerly Piwik) will still track visits, but the unique visitors metric might be less accurate. Corresponds to _id in https://developer.matomo.org/api-reference/tracking-api
getter/setter pair
idSite int?
idSite The ID of the website we're tracking a visit/action for.
getter/setter pair
method MatomoForeverMethod
method Can be either post or get except for bulk sending which must be sent through post method.
getter/setter pair
persistentParameters Map<String, String>?
persistentParameters Custom parameters sent at each call. Refer to: https://developer.matomo.org/api-reference/tracking-api
getter/setter pair
ping bool?
ping If set to true (ping=1), 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 set to true (&ping=1), you fix the issue where the time spent of the last page visited is reported as 0 seconds.
getter/setter pair
queuedTracking bool?
queuedTracking When set to false (0), 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.
getter/setter pair
rec bool
rec Required for tracking, must be set to true.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sendImage bool?
sendImage If set to false (send_image=0) Matomo will respond with 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
getter/setter pair
sendThroughGetMethod ↔ (Future<bool> Function(String urlWithoutParameters, String urlParameters, {Map<String, String>? headers})?)
sendThroughGetMethod Function used to send the data to the server. There is a fallback in case it is not initialized through the init call. Returns true for success. urlWithoutParameters The matomo.php URL without the parameters. urlParameters The parameters String formatted for a GET request. headers The headers to be sent along with request.
getter/setter pair
sendThroughPostMethod ↔ (Future<bool> Function(String urlWithoutParameters, Object data, {Map<String, String>? headers})?)
sendThroughPostMethod Function used to send the data to the server. There is a fallback in case it is not initialized through the init call. Returns true for success. urlWithoutParameters The matomo.php URL without the parameters. data The parameters to be sent by post. headers The headers to be sent along with request.
getter/setter pair
siteUrl String?
siteUrl The Matomo or piwik URL such as https://matomo.example.com/matomo.php
getter/setter pair
tokenAuth String?
tokenAuth 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).
getter/setter pair

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

isInitialized bool
isInitialized returns whether the global _matomoForever has been initialized.
no setter

Static Methods

init(String siteUrl, int idSite, {String? id, String? apiV, bool rec = true, MatomoForeverMethod method = MatomoForeverMethod.post, int bulkSize = 0, String? tokenAuth, bool? queuedTracking, bool? sendImage, bool? ping, bool? bots, bool? debug, Map<String, String>? headers, Map<String, String>? persistentParameters, Future<bool> sendThroughGetMethod(String urlWithoutParameters, String urlParameters, {Map<String, String>? headers})?, Future<bool> sendThroughPostMethod(String urlWithoutParameters, Object data, {Map<String, String>? headers})?, BaseClient? client}) → void
init Initializes the global _matomoForever object with:
sendDataOrBulk(Map<String, String> addedData) Future<bool>
sendDataOrBulk Sends the given data to be added to the init data addedData Data to be added to the init data
sendQueue() Future<bool>
sendQueue Sends the queue to the Matomo server. Returns true and clears the queue in case of success.
track(String actionName, {String? url, String? rand, String? urlRef, String? cvar, int? idVc, DateTime? viewTs, DateTime? idTs, String? rcn, String? rck, String? res, int? h, int? m, int? s, bool? fla, bool? java, bool? dir, bool? qt, bool? realp, bool? pdf, bool? wma, bool? gears, bool? ag, bool? cookie, String? ua, String? lang, String? uid, String? cid, bool? newVisit, String? dimension0, String? dimension1, String? dimension2, String? dimension3, String? dimension4, String? dimension5, String? dimension6, String? dimension7, String? dimension8, String? dimension9, String? dimension10, String? link, String? download, String? search, String? searchCat, int? searchCount, String? pvId, String? idGoal, String? revenue, int? gtMs, String? cs, bool? ca, int? pfNet, int? pfSrv, int? pfTfr, int? pfDm1, int? pfDm2, int? pfOnl, String? eC, String? eA, String? eN, double? eV, String? cN, String? cP, String? cT, String? cId, String? ecId, String? ecItems, String? ecSt, String? ecTx, String? ecSh, String? ecDt, DateTime? ects, String? cip, DateTime? cdt, String? country, String? region, String? city, String? lat, String? long, String? maId, String? maRe, String? maMt, String? maTi, String? maPn, int? maSt, int? maLe, int? maPs, int? maTtp, int? maW, int? maH, bool? maFs, String? maSe, Map<String, String>? customData}) Future<bool>
track Sends or bulks the tracking of an action to Matomo server.