@cronapp/framework-analytics-matomo 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cronapp.framework.analytics.matomo.js +1 -0
- package/cronapp.json +29 -0
- package/cronapp.nls.json +5 -0
- package/icon.svg +27 -0
- package/package-lock.json +138 -0
- package/package.json +16 -0
- package/src/main/browser/analyticsPlugin.ts +102 -0
- package/src/main/browser/index.angularJs.ts +1 -0
- package/src/main/browser/matomo.d.ts +1547 -0
- package/target/browser/cronapp.framework.analytics.matomo.js +1 -0
- package/tsconfig.json +13 -0
- package/webpack.config.js +9 -0
|
@@ -0,0 +1,1547 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
const Matomo: Matomo.Client
|
|
3
|
+
|
|
4
|
+
interface Window {
|
|
5
|
+
/**
|
|
6
|
+
* JavaScript Tracking Client
|
|
7
|
+
*/
|
|
8
|
+
Matomo: Matomo.Client
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* JavaScript Tracking Client initialization method.
|
|
12
|
+
*/
|
|
13
|
+
matomoAsyncInit(): void
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Global array for Matomo configuration and tracking calls.
|
|
17
|
+
*/
|
|
18
|
+
_paq: Matomo.TrackerProxy
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated since 4.0.0 use `matomoAsyncInit()` instead
|
|
22
|
+
*/
|
|
23
|
+
piwikAsyncInit(): void
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated since 4.0.0 use `window.Matomo` instead.
|
|
27
|
+
*/
|
|
28
|
+
Piwik: Matomo.Client
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export namespace Matomo {
|
|
33
|
+
type SiteID = number | string
|
|
34
|
+
|
|
35
|
+
interface TrackingAPIMethodMap {
|
|
36
|
+
'hasConsent': string
|
|
37
|
+
'getVisitorId': string
|
|
38
|
+
'getVisitorInfo': string
|
|
39
|
+
'getAttributionInfo': string
|
|
40
|
+
'getAttributionCampaignName': string
|
|
41
|
+
'getAttributionCampaignKeyword': string
|
|
42
|
+
'getAttributionReferrerTimestamp': string
|
|
43
|
+
'getAttributionReferrerUrl': string
|
|
44
|
+
'setTrackerUrl': string
|
|
45
|
+
'getTrackerUrl': string
|
|
46
|
+
'getMatomoUrl': string
|
|
47
|
+
'getPiwikUrl': string
|
|
48
|
+
'addTracker': string
|
|
49
|
+
'getSiteId': string
|
|
50
|
+
'setSiteId': string
|
|
51
|
+
'resetUserId': string
|
|
52
|
+
'setUserId': string
|
|
53
|
+
'setVisitorId': string
|
|
54
|
+
'getUserId': string
|
|
55
|
+
'setCustomData': string
|
|
56
|
+
'getCustomData': string
|
|
57
|
+
'setCustomRequestProcessing': string
|
|
58
|
+
'appendToTrackingUrl': string
|
|
59
|
+
'getRequest': string
|
|
60
|
+
'addPlugin': string
|
|
61
|
+
'setCustomDimension': string
|
|
62
|
+
'getCustomDimension': string
|
|
63
|
+
'deleteCustomDimension': string
|
|
64
|
+
'setCustomVariable': string
|
|
65
|
+
'getCustomVariable': string
|
|
66
|
+
'deleteCustomVariable': string
|
|
67
|
+
'deleteCustomVariables': string
|
|
68
|
+
'storeCustomVariablesInCookie': string
|
|
69
|
+
'setLinkTrackingTimer': string
|
|
70
|
+
'getLinkTrackingTimer': string
|
|
71
|
+
'setDownloadExtensions': string
|
|
72
|
+
'addDownloadExtensions': string
|
|
73
|
+
'removeDownloadExtensions': string
|
|
74
|
+
'setDomains': string
|
|
75
|
+
'enableCrossDomainLinking': string
|
|
76
|
+
'disableCrossDomainLinking': string
|
|
77
|
+
'isCrossDomainLinkingEnabled': string
|
|
78
|
+
'setCrossDomainLinkingTimeout': string
|
|
79
|
+
'getCrossDomainLinkingUrlParameter': string
|
|
80
|
+
'setIgnoreClasses': string
|
|
81
|
+
'setRequestMethod': string
|
|
82
|
+
'setRequestContentType': string
|
|
83
|
+
'setGenerationTimeMs': string
|
|
84
|
+
'setReferrerUrl': string
|
|
85
|
+
'setCustomUrl': string
|
|
86
|
+
'getCurrentUrl': string
|
|
87
|
+
'setDocumentTitle': string
|
|
88
|
+
'setPageViewId': string
|
|
89
|
+
'setAPIUrl': string
|
|
90
|
+
'setDownloadClasses': string
|
|
91
|
+
'setLinkClasses': string
|
|
92
|
+
'setCampaignNameKey': string
|
|
93
|
+
'setCampaignKeywordKey': string
|
|
94
|
+
'discardHashTag': string
|
|
95
|
+
'setCookieNamePrefix': string
|
|
96
|
+
'setCookieDomain': string
|
|
97
|
+
'getCookieDomain': string
|
|
98
|
+
'hasCookies': string
|
|
99
|
+
'setSessionCookie': string
|
|
100
|
+
'getCookie': string
|
|
101
|
+
'setCookiePath': string
|
|
102
|
+
'getCookiePath': string
|
|
103
|
+
'setVisitorCookieTimeout': string
|
|
104
|
+
'setSessionCookieTimeout': string
|
|
105
|
+
'getSessionCookieTimeout': string
|
|
106
|
+
'setReferralCookieTimeout': string
|
|
107
|
+
'setSecureCookie': string
|
|
108
|
+
'setCookieSameSite': string
|
|
109
|
+
'disableCookies': string
|
|
110
|
+
'areCookiesEnabled': string
|
|
111
|
+
'setCookieConsentGiven': string
|
|
112
|
+
'requireCookieConsent': string
|
|
113
|
+
'getRememberedCookieConsent': string
|
|
114
|
+
'forgetCookieConsentGiven': string
|
|
115
|
+
'rememberCookieConsentGiven': string
|
|
116
|
+
'deleteCookies': string
|
|
117
|
+
'setDoNotTrack': string
|
|
118
|
+
'alwaysUseSendBeacon': string
|
|
119
|
+
'disableAlwaysUseSendBeacon': string
|
|
120
|
+
'addListener': string
|
|
121
|
+
'enableLinkTracking': string
|
|
122
|
+
'enableJSErrorTracking': string
|
|
123
|
+
'disablePerformanceTracking': string
|
|
124
|
+
'enableHeartBeatTimer': string
|
|
125
|
+
'disableHeartBeatTimer': string
|
|
126
|
+
'killFrame': string
|
|
127
|
+
'redirectFile': string
|
|
128
|
+
'setCountPreRendered': string
|
|
129
|
+
'trackGoal': string
|
|
130
|
+
'trackLink': string
|
|
131
|
+
'getNumTrackedPageViews': string
|
|
132
|
+
'trackPageView': string
|
|
133
|
+
'trackAllContentImpressions': string
|
|
134
|
+
'trackVisibleContentImpressions': string
|
|
135
|
+
'trackContentImpression': string
|
|
136
|
+
'trackContentImpressionsWithinNode': string
|
|
137
|
+
'trackContentInteraction': string
|
|
138
|
+
'trackContentInteractionNode': string
|
|
139
|
+
'logAllContentBlocksOnPage': string
|
|
140
|
+
'trackEvent': string
|
|
141
|
+
'trackSiteSearch': string
|
|
142
|
+
'setEcommerceView': string
|
|
143
|
+
'getEcommerceItems': string
|
|
144
|
+
'addEcommerceItem': string
|
|
145
|
+
'removeEcommerceItem': string
|
|
146
|
+
'clearEcommerceCart': string
|
|
147
|
+
'trackEcommerceOrder': string
|
|
148
|
+
'trackEcommerceCartUpdate': string
|
|
149
|
+
'trackRequest': string
|
|
150
|
+
'ping': string
|
|
151
|
+
'disableQueueRequest': string
|
|
152
|
+
'queueRequest': string
|
|
153
|
+
'isConsentRequired': string
|
|
154
|
+
'getRememberedConsent': string
|
|
155
|
+
'hasRememberedConsent': string
|
|
156
|
+
'requireConsent': string
|
|
157
|
+
'setConsentGiven': string
|
|
158
|
+
'rememberConsentGiven': string
|
|
159
|
+
'forgetConsentGiven': string
|
|
160
|
+
'isUserOptedOut': string
|
|
161
|
+
'optUserOut': string
|
|
162
|
+
'forgetUserOptOut': string
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
interface TrackingAPIMethodArguments {
|
|
166
|
+
'hasConsent': []
|
|
167
|
+
'getVisitorId': []
|
|
168
|
+
'getVisitorInfo': []
|
|
169
|
+
'getAttributionInfo': []
|
|
170
|
+
'getAttributionCampaignName': []
|
|
171
|
+
'getAttributionCampaignKeyword': []
|
|
172
|
+
'getAttributionReferrerTimestamp': []
|
|
173
|
+
'getAttributionReferrerUrl': []
|
|
174
|
+
'setTrackerUrl': [string]
|
|
175
|
+
'getTrackerUrl': []
|
|
176
|
+
'getMatomoUrl': []
|
|
177
|
+
'getPiwikUrl': []
|
|
178
|
+
'addTracker': [string, SiteID]
|
|
179
|
+
'getSiteId': []
|
|
180
|
+
'setSiteId': [SiteID]
|
|
181
|
+
'resetUserId': []
|
|
182
|
+
'setUserId': [string]
|
|
183
|
+
'setVisitorId': [string]
|
|
184
|
+
'getUserId': []
|
|
185
|
+
'setCustomData': [any, any]
|
|
186
|
+
'getCustomData': []
|
|
187
|
+
'setCustomRequestProcessing': [any]
|
|
188
|
+
'appendToTrackingUrl': [string]
|
|
189
|
+
'getRequest': [any]
|
|
190
|
+
'addPlugin': [any, any]
|
|
191
|
+
'setCustomDimension': [any, any]
|
|
192
|
+
'getCustomDimension': [any]
|
|
193
|
+
'deleteCustomDimension': [any]
|
|
194
|
+
'setCustomVariable': [any, any, any, any]
|
|
195
|
+
'getCustomVariable': [any, any]
|
|
196
|
+
'deleteCustomVariable': [any, any]
|
|
197
|
+
'deleteCustomVariables': [string]
|
|
198
|
+
'storeCustomVariablesInCookie': []
|
|
199
|
+
'setLinkTrackingTimer': [number]
|
|
200
|
+
'getLinkTrackingTimer': []
|
|
201
|
+
'setDownloadExtensions': [string | string[]]
|
|
202
|
+
'addDownloadExtensions': [string | string[]]
|
|
203
|
+
'removeDownloadExtensions': [string | string[]]
|
|
204
|
+
'setDomains': [string | string[]]
|
|
205
|
+
'enableCrossDomainLinking': []
|
|
206
|
+
'disableCrossDomainLinking': []
|
|
207
|
+
'isCrossDomainLinkingEnabled': []
|
|
208
|
+
'setCrossDomainLinkingTimeout': [number]
|
|
209
|
+
'getCrossDomainLinkingUrlParameter': []
|
|
210
|
+
'setIgnoreClasses': [string | string[]]
|
|
211
|
+
'setRequestMethod': [any]
|
|
212
|
+
'setRequestContentType': [any]
|
|
213
|
+
'setGenerationTimeMs': [any]
|
|
214
|
+
'setReferrerUrl': [any]
|
|
215
|
+
'setCustomUrl': [any]
|
|
216
|
+
'getCurrentUrl': []
|
|
217
|
+
'setDocumentTitle': [any]
|
|
218
|
+
'setPageViewId': [any]
|
|
219
|
+
'setAPIUrl': [any]
|
|
220
|
+
'setDownloadClasses': [any]
|
|
221
|
+
'setLinkClasses': [any]
|
|
222
|
+
'setCampaignNameKey': [string | string[]]
|
|
223
|
+
'setCampaignKeywordKey': [string | string[]]
|
|
224
|
+
'discardHashTag': [boolean]
|
|
225
|
+
'setCookieNamePrefix': [string]
|
|
226
|
+
'setCookieDomain': [string]
|
|
227
|
+
'getCookieDomain': []
|
|
228
|
+
'hasCookies': []
|
|
229
|
+
'setSessionCookie': [any, any, any]
|
|
230
|
+
'getCookie': [any]
|
|
231
|
+
'setCookiePath': [any]
|
|
232
|
+
'getCookiePath': [any]
|
|
233
|
+
'setVisitorCookieTimeout': [any]
|
|
234
|
+
'setSessionCookieTimeout': [any]
|
|
235
|
+
'getSessionCookieTimeout': []
|
|
236
|
+
'setReferralCookieTimeout': [any]
|
|
237
|
+
'setSecureCookie': [boolean]
|
|
238
|
+
'setCookieSameSite': [any]
|
|
239
|
+
'disableCookies': []
|
|
240
|
+
'areCookiesEnabled': []
|
|
241
|
+
'setCookieConsentGiven': []
|
|
242
|
+
'requireCookieConsent': []
|
|
243
|
+
'getRememberedCookieConsent': []
|
|
244
|
+
'forgetCookieConsentGiven': []
|
|
245
|
+
'rememberCookieConsentGiven': [number]
|
|
246
|
+
'deleteCookies': []
|
|
247
|
+
'setDoNotTrack': [boolean]
|
|
248
|
+
'alwaysUseSendBeacon': []
|
|
249
|
+
'disableAlwaysUseSendBeacon': []
|
|
250
|
+
'addListener': [Element, boolean]
|
|
251
|
+
'enableLinkTracking': [boolean?]
|
|
252
|
+
'enableJSErrorTracking': []
|
|
253
|
+
'disablePerformanceTracking': []
|
|
254
|
+
'enableHeartBeatTimer': [number]
|
|
255
|
+
'disableHeartBeatTimer': []
|
|
256
|
+
'killFrame': []
|
|
257
|
+
'redirectFile': [string]
|
|
258
|
+
'setCountPreRendered': [boolean]
|
|
259
|
+
'trackGoal': [number | string, number, any, Function]
|
|
260
|
+
'trackLink': [string, string, any, Function]
|
|
261
|
+
'getNumTrackedPageViews': []
|
|
262
|
+
'trackPageView': [string, any, Function]
|
|
263
|
+
'trackAllContentImpressions': []
|
|
264
|
+
'trackVisibleContentImpressions': [boolean, number]
|
|
265
|
+
'trackContentImpression': [string, string, string]
|
|
266
|
+
'trackContentImpressionsWithinNode': [Element]
|
|
267
|
+
'trackContentInteraction': [string, string, string, string]
|
|
268
|
+
'trackContentInteractionNode': [Element, string]
|
|
269
|
+
'logAllContentBlocksOnPage': []
|
|
270
|
+
'trackEvent': [any, any, any, any, any, any]
|
|
271
|
+
'trackSiteSearch': [any, any, any, any]
|
|
272
|
+
'setEcommerceView': [any, any, any, any]
|
|
273
|
+
'getEcommerceItems': []
|
|
274
|
+
'addEcommerceItem': [any, any, any, any, any]
|
|
275
|
+
'removeEcommerceItem': [any]
|
|
276
|
+
'clearEcommerceCart': []
|
|
277
|
+
'trackEcommerceOrder': [string | number, number, number, number, number, number]
|
|
278
|
+
'trackEcommerceCartUpdate': [number]
|
|
279
|
+
'trackRequest': [string, any, Function, any]
|
|
280
|
+
'ping': []
|
|
281
|
+
'disableQueueRequest': []
|
|
282
|
+
'queueRequest': [string]
|
|
283
|
+
'isConsentRequired': []
|
|
284
|
+
'getRememberedConsent': []
|
|
285
|
+
'hasRememberedConsent': []
|
|
286
|
+
'requireConsent': []
|
|
287
|
+
'setConsentGiven': [boolean]
|
|
288
|
+
'rememberConsentGiven': [number]
|
|
289
|
+
'forgetConsentGiven': []
|
|
290
|
+
'isUserOptedOut': []
|
|
291
|
+
'optUserOut': []
|
|
292
|
+
'forgetUserOptOut': []
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface Client {
|
|
296
|
+
initialized: boolean
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* To support IE7 and older, load a polyfill to `window.JSON`
|
|
300
|
+
*/
|
|
301
|
+
JSON: JSON
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* DOM Document related methods
|
|
305
|
+
*/
|
|
306
|
+
DOM: {
|
|
307
|
+
/**
|
|
308
|
+
* Adds an event listener to the given element.
|
|
309
|
+
* @param element
|
|
310
|
+
* @param eventType
|
|
311
|
+
* @param eventHandler
|
|
312
|
+
* @param useCapture Optional
|
|
313
|
+
*/
|
|
314
|
+
addEventListener(element: HTMLElement, eventType: string, eventHandler: string, useCapture?: boolean): void
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Specify a function to execute when the DOM is fully loaded.
|
|
318
|
+
*
|
|
319
|
+
* If the DOM is already loaded, the function will be executed immediately.
|
|
320
|
+
*
|
|
321
|
+
* @param function callback
|
|
322
|
+
*/
|
|
323
|
+
onLoad: (callback: Function) => void
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Specify a function to execute when the DOM is ready.
|
|
327
|
+
*
|
|
328
|
+
* If the DOM is already ready, the function will be executed immediately.
|
|
329
|
+
*
|
|
330
|
+
* @param function callback
|
|
331
|
+
*/
|
|
332
|
+
onReady: (callback: Function) => void
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Detect whether a node is visible right now.
|
|
336
|
+
*/
|
|
337
|
+
isNodeVisible: (node: Node) => boolean
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Detect whether a node has been visible at some point
|
|
341
|
+
*/
|
|
342
|
+
isOrWasNodeVisible: (node: Node) => boolean
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Listen to an event and invoke the handler when a the event is triggered.
|
|
347
|
+
*
|
|
348
|
+
* @param string event
|
|
349
|
+
* @param function handler
|
|
350
|
+
*/
|
|
351
|
+
on(event: string, handler: Function): void
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Remove a handler to no longer listen to the event. Must pass the same handler that was used when
|
|
355
|
+
* attaching the event via ".on".
|
|
356
|
+
* @param string event
|
|
357
|
+
* @param function handler
|
|
358
|
+
*/
|
|
359
|
+
off(event: string, handler: Function): void
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Triggers the given event and passes the parameters to all handlers.
|
|
363
|
+
*
|
|
364
|
+
* @param string event
|
|
365
|
+
* @param Array extraParameters
|
|
366
|
+
* @param Object context If given the handler will be executed in this context
|
|
367
|
+
*/
|
|
368
|
+
trigger(event: string, extraParameters: Record<string, unknown>, context: any): void
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Add plugin
|
|
372
|
+
*
|
|
373
|
+
* @param string pluginName
|
|
374
|
+
* @param Object pluginObj
|
|
375
|
+
*/
|
|
376
|
+
addPlugin(pluginName: string, pluginObj: any): void
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Get Tracker (factory method)
|
|
380
|
+
*
|
|
381
|
+
* @param string matomoUrl
|
|
382
|
+
* @param int|string siteId
|
|
383
|
+
* @return Tracker
|
|
384
|
+
*/
|
|
385
|
+
getTracker(matomoUrl: string, siteId: SiteID): Matomo.Tracker
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Get all created async trackers
|
|
389
|
+
*
|
|
390
|
+
* @return Tracker[]
|
|
391
|
+
*/
|
|
392
|
+
getAsyncTrackers(): Matomo.Tracker[]
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Adds a new tracker. All sent requests will be also sent to the given siteId and matomoUrl.
|
|
396
|
+
* If matomoUrl is not set, current url will be used.
|
|
397
|
+
*
|
|
398
|
+
* @param null|string matomoUrl If null, will reuse the same tracker URL of the current tracker instance
|
|
399
|
+
* @param int|string siteId
|
|
400
|
+
* @return Tracker
|
|
401
|
+
*/
|
|
402
|
+
addTracker(matomoUrl: null | string, siteId: SiteID): Tracker
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Get internal asynchronous tracker object.
|
|
406
|
+
*
|
|
407
|
+
* If no parameters are given, it returns the internal asynchronous tracker object. If a matomoUrl and idSite
|
|
408
|
+
* is given, it will try to find an optional
|
|
409
|
+
*/
|
|
410
|
+
getAsyncTracker(matomoUrl?: string, siteId?: SiteID): Tracker
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* When calling plugin methods via `_paq.push(['...'])` and the plugin is loaded separately because
|
|
414
|
+
* matomo.js is not writable then there is a chance that first matomo.js is loaded and later the plugin.
|
|
415
|
+
* In this case we would have already executed all `_paq.push` methods and they would not have succeeded
|
|
416
|
+
* because the plugin will be loaded only later. In this case, once a plugin is loaded, it should call
|
|
417
|
+
* `Matomo.retryMissedPluginCalls()` so they will be executed after all.
|
|
418
|
+
*/
|
|
419
|
+
retryMissedPluginCalls(): void
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export interface TrackerProxy {
|
|
423
|
+
push<K extends keyof TrackingAPIMethodMap>(parameterArray: [ K, ...TrackingAPIMethodArguments[K] ] | [ Function, ...any ]): void
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export interface Tracker {
|
|
427
|
+
hasConsent: () => boolean
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* @return Visitor ID (from first party cookie) in hexits (or empty string, if not yet known)
|
|
431
|
+
*/
|
|
432
|
+
getVisitorId: () => string
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* @return visitor information (from first party cookie)
|
|
436
|
+
*/
|
|
437
|
+
getVisitorInfo: () => Array<unknown>
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Get the Attribution information, which is an array that contains
|
|
441
|
+
* the Referrer used to reach the site as well as the campaign name and keyword
|
|
442
|
+
* It is useful only when used in conjunction with Tracker API function `setAttributionInfo()`
|
|
443
|
+
* To access specific data point, you should use the other functions `getAttributionReferrer*` and `getAttributionCampaign*`
|
|
444
|
+
*
|
|
445
|
+
* @return Attribution array, Example use:
|
|
446
|
+
* 1) Call `windowAlias.JSON.stringify(matomoTracker.getAttributionInfo())`
|
|
447
|
+
* 2) Pass this json encoded string to the Tracking API (php or java client): `setAttributionInfo()`
|
|
448
|
+
*/
|
|
449
|
+
getAttributionInfo: () => Array<unknown>
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* @return Get the Campaign name that was parsed from the landing page URL when the visitor
|
|
453
|
+
* landed on the site originally
|
|
454
|
+
*/
|
|
455
|
+
getAttributionCampaignName: () => string
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* @return Get the Campaign keyword that was parsed from the landing page URL when the visitor
|
|
459
|
+
* landed on the site originally
|
|
460
|
+
*/
|
|
461
|
+
getAttributionCampaignKeyword: () => string
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Get the time at which the referrer (used for Goal Attribution) was detected
|
|
465
|
+
*
|
|
466
|
+
* @return Timestamp or 0 if no referrer currently set
|
|
467
|
+
*/
|
|
468
|
+
getAttributionReferrerTimestamp: () => number
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Get the full referrer URL that will be used for Goal Attribution
|
|
472
|
+
*
|
|
473
|
+
* @return Raw URL, or empty string '' if no referrer currently set
|
|
474
|
+
*/
|
|
475
|
+
getAttributionReferrerUrl: () => string
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Specify the Matomo tracking URL
|
|
479
|
+
*/
|
|
480
|
+
setTrackerUrl: (trackerUrl: string) => void
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* @returns Matomo tracking URL
|
|
484
|
+
*/
|
|
485
|
+
getTrackerUrl: () => string
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* @returns Matomo server URL
|
|
489
|
+
*/
|
|
490
|
+
getMatomoUrl: () => string
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* @deprecated since 4.0.0 use `getMatomoUrl()` instead.
|
|
494
|
+
*/
|
|
495
|
+
getPiwikUrl: () => string
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Adds a new tracker. All sent requests will be also sent to the given siteId and matomoUrl.
|
|
499
|
+
*
|
|
500
|
+
* @param matomoUrl The tracker URL of the current tracker instance
|
|
501
|
+
* @param siteId
|
|
502
|
+
*/
|
|
503
|
+
addTracker: (matomoUrl: string, siteId: SiteID) => Tracker
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* @returns site ID
|
|
507
|
+
*/
|
|
508
|
+
getSiteId: () => number
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Specify the site ID
|
|
512
|
+
*/
|
|
513
|
+
setSiteId: (siteId: SiteID) => unknown
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Clears the User ID
|
|
517
|
+
*/
|
|
518
|
+
resetUserId: () => void
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Sets a User ID to this user (such as an email address or a username)
|
|
522
|
+
*/
|
|
523
|
+
setUserId: (userId: string) => void
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Sets a Visitor ID to this visitor. Should be a 16 digit hex string.
|
|
527
|
+
* The visitorId won't be persisted in a cookie or something similar and needs to be set every time.
|
|
528
|
+
*/
|
|
529
|
+
setVisitorId: (visitorId: string) => void
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* @returns User ID if set.
|
|
533
|
+
*/
|
|
534
|
+
getUserId: () => string
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Pass custom data to the server
|
|
538
|
+
*
|
|
539
|
+
* Examples:
|
|
540
|
+
* tracker.setCustomData(object);
|
|
541
|
+
* tracker.setCustomData(key, value);
|
|
542
|
+
*
|
|
543
|
+
* @param {any} key_or_obj
|
|
544
|
+
* @param {any} opt_value
|
|
545
|
+
*/
|
|
546
|
+
setCustomData: (key_or_obj: any, opt_value: any) => unknown
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Get custom data
|
|
550
|
+
*
|
|
551
|
+
* @return mixed
|
|
552
|
+
*/
|
|
553
|
+
getCustomData: () => unknown
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Configure function with custom request content processing logic.
|
|
557
|
+
* It gets called after request content in form of query parameters string has been prepared and before request content gets sent.
|
|
558
|
+
*
|
|
559
|
+
* Examples:
|
|
560
|
+
* tracker.setCustomRequestProcessing(function(request){
|
|
561
|
+
* var pairs = request.split('&');
|
|
562
|
+
* var result = {};
|
|
563
|
+
* pairs.forEach(function(pair) => unknown * pair = pair.split('=');
|
|
564
|
+
* result[pair[0]] = decodeURIComponent(pair[1] || '');
|
|
565
|
+
* });
|
|
566
|
+
* return JSON.stringify(result);
|
|
567
|
+
* });
|
|
568
|
+
*
|
|
569
|
+
* @param {Function} customRequestContentProcessingLogic
|
|
570
|
+
*/
|
|
571
|
+
setCustomRequestProcessing: (customRequestContentProcessingLogic: any) => unknown
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Appends the specified query string to the matomo.php?... Tracking API URL
|
|
575
|
+
*
|
|
576
|
+
* @param queryString eg. 'lat=140&long=100'
|
|
577
|
+
*/
|
|
578
|
+
appendToTrackingUrl: (queryString: string) => unknown
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Returns the query string for the current HTTP Tracking API request.
|
|
582
|
+
* Matomo would prepend the hostname and path to Matomo: http://example.org/matomo/matomo.php?
|
|
583
|
+
* prior to sending the request.
|
|
584
|
+
*
|
|
585
|
+
* @param request eg. "param=value¶m2=value2"
|
|
586
|
+
*/
|
|
587
|
+
getRequest: (request: any) => unknown
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Add plugin defined by a name and a callback function.
|
|
591
|
+
* The callback function will be called whenever a tracking request is sent.
|
|
592
|
+
* This can be used to append data to the tracking request, or execute other custom logic.
|
|
593
|
+
*
|
|
594
|
+
* @param {string} pluginName
|
|
595
|
+
* @param Object pluginObj
|
|
596
|
+
*/
|
|
597
|
+
addPlugin: (pluginName: any, pluginObj: any) => unknown
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Set Custom Dimensions. Set Custom Dimensions will not be cleared after a tracked pageview and will
|
|
601
|
+
* be sent along all following tracking requests. It is possible to remove/clear a value via `deleteCustomDimension`.
|
|
602
|
+
*
|
|
603
|
+
* @param {number} index A Custom Dimension index
|
|
604
|
+
* @param {string} value
|
|
605
|
+
*/
|
|
606
|
+
setCustomDimension: (customDimensionId: any, value: any) => unknown
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Get a stored value for a specific Custom Dimension index.
|
|
610
|
+
*
|
|
611
|
+
* @param {number} index A Custom Dimension index
|
|
612
|
+
*/
|
|
613
|
+
getCustomDimension: (customDimensionId: any) => unknown
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Delete a custom dimension.
|
|
617
|
+
*
|
|
618
|
+
* @param {number} index Custom dimension Id
|
|
619
|
+
*/
|
|
620
|
+
deleteCustomDimension: (customDimensionId: any) => unknown
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Set custom variable within this visit
|
|
624
|
+
*
|
|
625
|
+
* @param {number} index Custom variable slot ID from 1-5
|
|
626
|
+
* @param {string} name
|
|
627
|
+
* @param {string} value
|
|
628
|
+
* @param {string} scope Scope of Custom Variable:
|
|
629
|
+
* - "visit" will store the name/value in the visit and will persist it in the cookie for the duration of the visit,
|
|
630
|
+
* - "page" will store the name/value in the next page view tracked.
|
|
631
|
+
* - "event" will store the name/value in the next event tracked.
|
|
632
|
+
*/
|
|
633
|
+
setCustomVariable: (index: any, name: any, value: any, scope: any) => unknown
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Get custom variable
|
|
637
|
+
*
|
|
638
|
+
* @param {number} index Custom variable slot ID from 1-5
|
|
639
|
+
* @param {string} scope Scope of Custom Variable: "visit" or "page" or "event"
|
|
640
|
+
*/
|
|
641
|
+
getCustomVariable: (index: any, scope: any) => unknown
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Delete custom variable
|
|
645
|
+
*
|
|
646
|
+
* @param {number} index Custom variable slot ID from 1-5
|
|
647
|
+
* @param {string} scope
|
|
648
|
+
*/
|
|
649
|
+
deleteCustomVariable: (index: any, scope: any) => unknown
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Deletes all custom variables for a certain scope.
|
|
653
|
+
*
|
|
654
|
+
*/
|
|
655
|
+
deleteCustomVariables: (scope: string) => unknown
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* When called then the Custom Variables of scope "visit" will be stored (persisted) in a first party cookie
|
|
659
|
+
* for the duration of the visit. This is useful if you want to call getCustomVariable later in the visit.
|
|
660
|
+
*
|
|
661
|
+
* By default, Custom Variables of scope "visit" are not stored on the visitor's computer.
|
|
662
|
+
*/
|
|
663
|
+
storeCustomVariablesInCookie: () => void
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Set delay for link tracking (in milliseconds)
|
|
667
|
+
*/
|
|
668
|
+
setLinkTrackingTimer: (delay: number) => void
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Get delay for link tracking (in milliseconds)
|
|
672
|
+
*/
|
|
673
|
+
getLinkTrackingTimer: () => number
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Set list of file extensions to be recognized as downloads
|
|
677
|
+
*
|
|
678
|
+
* @param extensions
|
|
679
|
+
*/
|
|
680
|
+
setDownloadExtensions: (extensions: string | string[]) => unknown
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Specify additional file extensions to be recognized as downloads
|
|
684
|
+
*
|
|
685
|
+
* @param extensions for example `'custom'` or `['custom1', 'custom2', 'custom3']`
|
|
686
|
+
*/
|
|
687
|
+
addDownloadExtensions: (extensions: string | string[]) => unknown
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Removes specified file extensions from the list of recognized downloads
|
|
691
|
+
*
|
|
692
|
+
* @param extensions for example 'custom' or ['custom1','custom2','custom3']
|
|
693
|
+
*/
|
|
694
|
+
removeDownloadExtensions: (extensions: string | string[]) => unknown
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* Set array of domains to be treated as local. Also supports path, eg '.matomo.org/subsite1'. In this
|
|
698
|
+
* case all links that don't go to '*.matomo.org/subsite1/ *' would be treated as outlinks.
|
|
699
|
+
* For example a link to 'matomo.org/' or 'matomo.org/subsite2' both would be treated as outlinks.
|
|
700
|
+
*
|
|
701
|
+
* Also supports page wildcard, eg 'matomo.org/index*'. In this case all links
|
|
702
|
+
* that don't go to matomo.org/index* would be treated as outlinks.
|
|
703
|
+
*
|
|
704
|
+
* The current domain will be added automatically if no given host alias contains a path and if no host
|
|
705
|
+
* alias is already given for the current host alias. Say you are on "example.org" and set
|
|
706
|
+
* "hostAlias = ['example.com', 'example.org/test']" then the current "example.org" domain will not be
|
|
707
|
+
* added as there is already a more restrictive hostAlias 'example.org/test' given. We also do not add
|
|
708
|
+
* it automatically if there was any other host specifying any path like
|
|
709
|
+
* "['example.com', 'example2.com/test']". In this case we would also not add the current
|
|
710
|
+
* domain "example.org" automatically as the "path" feature is used. As soon as someone uses the path
|
|
711
|
+
* feature, for Matomo JS Tracker to work correctly in all cases, one needs to specify all hosts
|
|
712
|
+
* manually.
|
|
713
|
+
*
|
|
714
|
+
* @param hostsAlias
|
|
715
|
+
*/
|
|
716
|
+
setDomains: (hostsAlias: string | string[]) => unknown
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Enables cross domain linking. By default, the visitor ID that identifies a unique visitor is stored in
|
|
720
|
+
* the browser's first party cookies. This means the cookie can only be accessed by pages on the same domain.
|
|
721
|
+
* If you own multiple domains and would like to track all the actions and pageviews of a specific visitor
|
|
722
|
+
* into the same visit, you may enable cross domain linking. Whenever a user clicks on a link it will append
|
|
723
|
+
* a URL parameter pk_vid to the clicked URL which consists of these parts: 16 char visitorId, a 10 character
|
|
724
|
+
* current timestamp and the last 6 characters are an id based on the userAgent to identify the users device).
|
|
725
|
+
* This way the current visitorId is forwarded to the page of the different domain.
|
|
726
|
+
*
|
|
727
|
+
* On the different domain, the Matomo tracker will recognize the set visitorId from the URL parameter and
|
|
728
|
+
* reuse this parameter if the page was loaded within 45 seconds. If cross domain linking was not enabled,
|
|
729
|
+
* it would create a new visit on that page because we wouldn't be able to access the previously created
|
|
730
|
+
* cookie. By enabling cross domain linking you can track several different domains into one website and
|
|
731
|
+
* won't lose for example the original referrer.
|
|
732
|
+
*
|
|
733
|
+
* To make cross domain linking work you need to set which domains should be considered as your domains by
|
|
734
|
+
* calling the method "setDomains()" first. We will add the URL parameter to links that go to a
|
|
735
|
+
* different domain but only if the domain was previously set with "setDomains()" to make sure not to append
|
|
736
|
+
* the URL parameters when a link actually goes to a third-party URL.
|
|
737
|
+
*/
|
|
738
|
+
enableCrossDomainLinking: () => void
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Disable cross domain linking if it was previously enabled. See enableCrossDomainLinking();
|
|
742
|
+
*/
|
|
743
|
+
disableCrossDomainLinking: () => void
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Detect whether cross domain linking is enabled or not. See enableCrossDomainLinking();
|
|
747
|
+
*/
|
|
748
|
+
isCrossDomainLinkingEnabled: () => boolean
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* By default, the two visits across domains will be linked together
|
|
752
|
+
* when the link is click and the page is loaded within 180 seconds.
|
|
753
|
+
* @param timeout in seconds
|
|
754
|
+
*/
|
|
755
|
+
setCrossDomainLinkingTimeout: (timeout: number) => void
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Returns the query parameter appended to link URLs so cross domain visits
|
|
759
|
+
* can be detected.
|
|
760
|
+
*
|
|
761
|
+
* If your application creates links dynamically, then you'll have to add this
|
|
762
|
+
* query parameter manually to those links (since the JavaScript tracker cannot
|
|
763
|
+
* detect when those links are added).
|
|
764
|
+
*
|
|
765
|
+
* Eg:
|
|
766
|
+
*
|
|
767
|
+
* var url = 'http://myotherdomain.com/?' + matomoTracker.getCrossDomainLinkingUrlParameter();
|
|
768
|
+
* $element.append('<a href="' + url + '"/>');
|
|
769
|
+
*/
|
|
770
|
+
getCrossDomainLinkingUrlParameter: () => string
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* @param ignoreClasses array of classes to be ignored if present in link
|
|
774
|
+
*/
|
|
775
|
+
setIgnoreClasses: (ignoreClasses: string | string[]) => void
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Set request method. If you specify GET then it will automatically disable sendBeacon.
|
|
779
|
+
*
|
|
780
|
+
* @param {string} method GET or POST; default is GET
|
|
781
|
+
*/
|
|
782
|
+
setRequestMethod: (method: any) => unknown
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* Set request Content-Type header value, applicable when POST request method is used for submitting tracking events.
|
|
786
|
+
* See XMLHttpRequest Level 2 spec, section 4.7.2 for invalid headers
|
|
787
|
+
* @link http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html
|
|
788
|
+
*
|
|
789
|
+
* @param {string} requestContentType; default is 'application/x-www-form-urlencoded; charset=UTF-8'
|
|
790
|
+
*/
|
|
791
|
+
setRequestContentType: (requestContentType: any) => unknown
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* @deprecated since Matomo 4 the performance API is now used.
|
|
795
|
+
* @param generationTime
|
|
796
|
+
*/
|
|
797
|
+
setGenerationTimeMs: (generationTime: any) => unknown
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Override referrer
|
|
801
|
+
*
|
|
802
|
+
* @param {string} url
|
|
803
|
+
*/
|
|
804
|
+
setReferrerUrl: (url: any) => unknown
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Override url
|
|
808
|
+
*
|
|
809
|
+
* @param {string} url
|
|
810
|
+
*/
|
|
811
|
+
setCustomUrl: (url: any) => unknown
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* Returns the current url of the page that is currently being visited. If a custom URL was set, the
|
|
815
|
+
* previously defined custom URL will be returned.
|
|
816
|
+
*/
|
|
817
|
+
getCurrentUrl: () => unknown
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* Override document.title
|
|
821
|
+
*
|
|
822
|
+
* @param {string} title
|
|
823
|
+
*/
|
|
824
|
+
setDocumentTitle: (title: any) => unknown
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* Override PageView id for every use of logPageView(). Do not use this if you call trackPageView() multiple times during tracking (if, for example, you are tracking a single page application).
|
|
828
|
+
*
|
|
829
|
+
* @param {string} pageView
|
|
830
|
+
*/
|
|
831
|
+
setPageViewId: (pageView: any) => unknown
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* Set the URL of the Matomo API. It is used for Page Overlay.
|
|
835
|
+
* This method should only be called when the API URL differs from the tracker URL.
|
|
836
|
+
*
|
|
837
|
+
* @param {string} apiUrl
|
|
838
|
+
*/
|
|
839
|
+
setAPIUrl: (apiUrl: any) => unknown
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* Set array of classes to be treated as downloads
|
|
843
|
+
*
|
|
844
|
+
* @param {string}|array downloadClasses
|
|
845
|
+
*/
|
|
846
|
+
setDownloadClasses: (downloadClasses: any) => unknown
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Set array of classes to be treated as outlinks
|
|
850
|
+
*
|
|
851
|
+
* @param {string}|array linkClasses
|
|
852
|
+
*/
|
|
853
|
+
setLinkClasses: (linkClasses: any) => unknown
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Set array of campaign name parameters
|
|
857
|
+
*
|
|
858
|
+
* @see https://matomo.org/faq/how-to/#faq_120
|
|
859
|
+
*/
|
|
860
|
+
setCampaignNameKey: (campaignNames: string | string[]) => void
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Set array of campaign keyword parameters
|
|
864
|
+
*
|
|
865
|
+
* @see https://matomo.org/faq/how-to/#faq_120
|
|
866
|
+
* @param {string}|array campaignKeywords
|
|
867
|
+
*/
|
|
868
|
+
setCampaignKeywordKey: (campaignKeywords: string | string[]) => void
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* Strip hash tag (or anchor) from URL
|
|
872
|
+
* Note: this can be done in the Matomo>Settings>Websites on a per-website basis
|
|
873
|
+
*
|
|
874
|
+
* @deprecated
|
|
875
|
+
* @param enableFilter
|
|
876
|
+
*/
|
|
877
|
+
discardHashTag: (enableFilter: boolean) => void
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* Set first-party cookie name prefix
|
|
881
|
+
*/
|
|
882
|
+
setCookieNamePrefix: (cookieNamePrefix: string) => void
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* Set first-party cookie domain
|
|
886
|
+
*/
|
|
887
|
+
setCookieDomain: (domain: string) => void
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* Get first-party cookie domain
|
|
891
|
+
*/
|
|
892
|
+
getCookieDomain: () => string
|
|
893
|
+
|
|
894
|
+
/**
|
|
895
|
+
* Detect if cookies are enabled and supported by browser.
|
|
896
|
+
*/
|
|
897
|
+
hasCookies: () => boolean
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* Set a first-party cookie for the duration of the session.
|
|
901
|
+
*
|
|
902
|
+
* @param {string} cookieName
|
|
903
|
+
* @param {string} cookieValue
|
|
904
|
+
* @param {number} msToExpire Defaults to session cookie timeout
|
|
905
|
+
*/
|
|
906
|
+
setSessionCookie: (cookieName: any, cookieValue: any, msToExpire: any) => unknown
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* Get first-party cookie value.
|
|
910
|
+
*
|
|
911
|
+
* Returns null if cookies are disabled or if no cookie could be found for this name.
|
|
912
|
+
*
|
|
913
|
+
* @param {string} cookieName
|
|
914
|
+
*/
|
|
915
|
+
getCookie: (cookieName: any) => unknown
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* Set first-party cookie path.
|
|
919
|
+
*
|
|
920
|
+
* @param {string} domain
|
|
921
|
+
*/
|
|
922
|
+
setCookiePath: (path: any) => unknown
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* Get first-party cookie path.
|
|
926
|
+
*
|
|
927
|
+
* @param {string} domain
|
|
928
|
+
*/
|
|
929
|
+
getCookiePath: (path: any) => unknown
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* Set visitor cookie timeout (in seconds) Defaults to 13 months (timeout=33955200)
|
|
933
|
+
* @param {number} timeout
|
|
934
|
+
*/
|
|
935
|
+
setVisitorCookieTimeout: (timeout: any) => unknown
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* Set session cookie timeout (in seconds).
|
|
939
|
+
* Defaults to 30 minutes (timeout=1800)
|
|
940
|
+
* @param {number} timeout
|
|
941
|
+
*/
|
|
942
|
+
setSessionCookieTimeout: (timeout: any) => unknown
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* Get session cookie timeout (in seconds).
|
|
946
|
+
*/
|
|
947
|
+
getSessionCookieTimeout: () => unknown
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* Set referral cookie timeout (in seconds).
|
|
951
|
+
* Defaults to 6 months (15768000000)
|
|
952
|
+
* @param {number} timeout
|
|
953
|
+
*/
|
|
954
|
+
setReferralCookieTimeout: (timeout: any) => unknown
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Set conversion attribution to first referrer and campaign
|
|
958
|
+
*
|
|
959
|
+
* @param bool if true, use first referrer (and first campaign) if false, use the last referrer (or campaign)/
|
|
960
|
+
setConversionAttributionFirstReferrer: (enable) => unknown
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* Enable the Secure cookie flag on all first party cookies.
|
|
965
|
+
* This should be used when your website is only available under HTTPS
|
|
966
|
+
* so that all tracking cookies are always sent over secure connection.
|
|
967
|
+
*
|
|
968
|
+
* Warning: If your site is available under http and https,
|
|
969
|
+
* setting this might lead to duplicate or incomplete visits.
|
|
970
|
+
*
|
|
971
|
+
* @param bool
|
|
972
|
+
*/
|
|
973
|
+
setSecureCookie: (enable: boolean) => unknown
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* Set the SameSite attribute for cookies to a custom value.
|
|
977
|
+
* You might want to use this if your site is running in an iframe since
|
|
978
|
+
* then it will only be able to access the cookies if SameSite is set to 'None'.
|
|
979
|
+
*
|
|
980
|
+
*
|
|
981
|
+
* Warning:
|
|
982
|
+
* Sets CookieIsSecure to true on None, because None will only work with Secure; cookies
|
|
983
|
+
* If your site is available under http and https,
|
|
984
|
+
* using "None" might lead to duplicate or incomplete visits.
|
|
985
|
+
*
|
|
986
|
+
* @param {string} either Lax, None or Strict
|
|
987
|
+
*/
|
|
988
|
+
setCookieSameSite: (sameSite: any) => unknown
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* Disables all cookies from being set
|
|
992
|
+
*
|
|
993
|
+
* Existing cookies will be deleted on the next call to track
|
|
994
|
+
*/
|
|
995
|
+
disableCookies: () => unknown
|
|
996
|
+
|
|
997
|
+
/**
|
|
998
|
+
* Detects if cookies are enabled or not
|
|
999
|
+
*/
|
|
1000
|
+
areCookiesEnabled: () => { boolean: any }
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Enables cookies if they were disabled previously.
|
|
1004
|
+
*/
|
|
1005
|
+
setCookieConsentGiven: () => unknown
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* When called, no cookies will be set until you have called `setCookieConsentGiven()`
|
|
1009
|
+
* unless consent was given previously AND you called {@link rememberCookieConsentGiven()} when the user
|
|
1010
|
+
* gave consent.
|
|
1011
|
+
*
|
|
1012
|
+
* This may be useful when you want to implement for example a popup to ask for cookie consent.
|
|
1013
|
+
* Once the user has given consent, you should call {@link setCookieConsentGiven()}
|
|
1014
|
+
* or {@link rememberCookieConsentGiven()}.
|
|
1015
|
+
*
|
|
1016
|
+
* If you require tracking consent for example because you are tracking personal data and GDPR applies to you,
|
|
1017
|
+
* then have a look at `_paq.push(['requireConsent'])` instead.
|
|
1018
|
+
*
|
|
1019
|
+
* If the user has already given consent in the past, you can either decide to not call `requireCookieConsent` at all
|
|
1020
|
+
* or call `_paq.push(['setCookieConsentGiven'])` on each page view at any time after calling `requireCookieConsent`.
|
|
1021
|
+
*
|
|
1022
|
+
* When the user gives you the consent to set cookies, you can also call `_paq.push(['rememberCookieConsentGiven', optionalTimeoutInHours])`
|
|
1023
|
+
* and for the duration while the cookie consent is remembered, any call to `requireCoookieConsent` will be automatically ignored
|
|
1024
|
+
* until you call `forgetCookieConsentGiven`.
|
|
1025
|
+
* `forgetCookieConsentGiven` needs to be called when the user removes consent for using cookies. This means if you call `rememberCookieConsentGiven` at the
|
|
1026
|
+
* time the user gives you consent, you do not need to ever call `_paq.push(['setCookieConsentGiven'])` as the consent
|
|
1027
|
+
* will be detected automatically through cookies.
|
|
1028
|
+
*/
|
|
1029
|
+
requireCookieConsent: () => unknown
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* If the user has given cookie consent previously and this consent was remembered, it will return the number
|
|
1033
|
+
* in milliseconds since 1970/01/01 which is the date when the user has given cookie consent. Please note that
|
|
1034
|
+
* the returned time depends on the users local time which may not always be correct.
|
|
1035
|
+
*
|
|
1036
|
+
*/
|
|
1037
|
+
getRememberedCookieConsent: () => number | string
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
* Calling this method will remove any previously given cookie consent and it disables cookies for subsequent
|
|
1041
|
+
* page views. You may call this method if the user removes cookie consent manually, or if you
|
|
1042
|
+
* want to re-ask for cookie consent after a specific time period.
|
|
1043
|
+
*/
|
|
1044
|
+
forgetCookieConsentGiven: () => unknown
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* Calling this method will remember that the user has given cookie consent across multiple requests by setting
|
|
1048
|
+
* a cookie named "mtm_cookie_consent". You can optionally define the lifetime of that cookie in hours
|
|
1049
|
+
* using a parameter.
|
|
1050
|
+
*
|
|
1051
|
+
* When you call this method, we imply that the user has given cookie consent for this page view, and will also
|
|
1052
|
+
* imply consent for all future page views unless the cookie expires or the user
|
|
1053
|
+
* deletes all their cookies. Remembering cookie consent means even if you call {@link disableCookies()},
|
|
1054
|
+
* then cookies will still be enabled and it won't disable cookies since the user has given consent for cookies.
|
|
1055
|
+
*
|
|
1056
|
+
* Please note that this feature requires you to set the `cookieDomain` and `cookiePath` correctly. Please
|
|
1057
|
+
* also note that when you call this method, consent will be implied for all sites that match the configured
|
|
1058
|
+
* cookieDomain and cookiePath. Depending on your website structure, you may need to restrict or widen the
|
|
1059
|
+
* scope of the cookie domain/path to ensure the consent is applied to the sites you want.
|
|
1060
|
+
*
|
|
1061
|
+
* @param hoursToExpire After how many hours the cookie consent should expire. By default the consent is valid
|
|
1062
|
+
* for 30 years unless cookies are deleted by the user or the browser prior to this
|
|
1063
|
+
*/
|
|
1064
|
+
rememberCookieConsentGiven: (hoursToExpire: number) => void
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* One off cookies clearing. Useful to call this when you know for sure a new visitor is using the same browser,
|
|
1068
|
+
* it maybe helps to "reset" tracking cookies to prevent data reuse for different users.
|
|
1069
|
+
*/
|
|
1070
|
+
deleteCookies: () => void
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* Handle do-not-track requests
|
|
1074
|
+
*
|
|
1075
|
+
* @param enable If true, don't track if user agent sends 'do-not-track' header
|
|
1076
|
+
*/
|
|
1077
|
+
setDoNotTrack: (enable: boolean) => void
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* Enables send beacon usage instead of regular XHR which reduces the link tracking time to a minimum
|
|
1081
|
+
* of 100ms instead of 500ms (default). This means when a user clicks for example on an outlink, the
|
|
1082
|
+
* navigation to this page will happen 400ms faster.
|
|
1083
|
+
* In case you are setting a callback method when issuing a tracking request, the callback method will
|
|
1084
|
+
* be executed as soon as the tracking request was sent through "sendBeacon" and not after the tracking
|
|
1085
|
+
* request finished as it is not possible to find out when the request finished.
|
|
1086
|
+
* Send beacon will only be used if the browser actually supports it.
|
|
1087
|
+
*/
|
|
1088
|
+
alwaysUseSendBeacon: () => void
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* Disables send beacon usage instead and instead enables using regular XHR when possible. This makes
|
|
1092
|
+
* callbacks work and also tracking requests will appear in the browser developer tools console.
|
|
1093
|
+
*/
|
|
1094
|
+
disableAlwaysUseSendBeacon: () => void
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* Add click listener to a specific link element.
|
|
1098
|
+
* When clicked, Matomo will log the click automatically.
|
|
1099
|
+
*
|
|
1100
|
+
* @param element
|
|
1101
|
+
* @param enable If false, do not use pseudo click-handler (middle click + context menu)
|
|
1102
|
+
*/
|
|
1103
|
+
addListener: (element: Element, enable: boolean) => void
|
|
1104
|
+
|
|
1105
|
+
|
|
1106
|
+
/**
|
|
1107
|
+
* Install link tracker.
|
|
1108
|
+
*
|
|
1109
|
+
* If you change the DOM of your website or web application Matomo will automatically detect links
|
|
1110
|
+
* that were added newly.
|
|
1111
|
+
*
|
|
1112
|
+
* The default behaviour is to use actual click events. However, some browsers
|
|
1113
|
+
* (e.g., Firefox, Opera, and Konqueror) don't generate click events for the middle mouse button.
|
|
1114
|
+
*
|
|
1115
|
+
* To capture more "clicks", the pseudo click-handler uses mousedown + mouseup events.
|
|
1116
|
+
* This is not industry standard and is vulnerable to false positives (e.g., drag events).
|
|
1117
|
+
*
|
|
1118
|
+
* There is a Safari/Chrome/Webkit bug that prevents tracking requests from being sent
|
|
1119
|
+
* by either click handler. The workaround is to set a target attribute (which can't
|
|
1120
|
+
* be "_self", "_top", or "_parent").
|
|
1121
|
+
*
|
|
1122
|
+
* @see https://bugs.webkit.org/show_bug.cgi?id=54783
|
|
1123
|
+
*
|
|
1124
|
+
* @param enable Defaults to true.
|
|
1125
|
+
* * If "true", use pseudo click-handler (treat middle click and open contextmenu as
|
|
1126
|
+
* left click). A right click (or any click that opens the context menu) on a link
|
|
1127
|
+
* will be tracked as clicked even if "Open in new tab" is not selected.
|
|
1128
|
+
* * If "false" (default), nothing will be tracked on open context menu or middle click.
|
|
1129
|
+
* The context menu is usually opened to open a link / download in a new tab
|
|
1130
|
+
* therefore you can get more accurate results by treat it as a click but it can lead
|
|
1131
|
+
* to wrong click numbers.
|
|
1132
|
+
*/
|
|
1133
|
+
enableLinkTracking: (enable?: boolean) => void
|
|
1134
|
+
|
|
1135
|
+
/**
|
|
1136
|
+
* Enable tracking of uncaught JavaScript errors
|
|
1137
|
+
*
|
|
1138
|
+
* If enabled, uncaught JavaScript Errors will be tracked as an event by defining a
|
|
1139
|
+
* window.onerror handler. If a window.onerror handler is already defined we will make
|
|
1140
|
+
* sure to call this previously registered error handler after tracking the error.
|
|
1141
|
+
*
|
|
1142
|
+
* By default we return false in the window.onerror handler to make sure the error still
|
|
1143
|
+
* appears in the browser's console etc. Note: Some older browsers might behave differently
|
|
1144
|
+
* so it could happen that an actual JavaScript error will be suppressed.
|
|
1145
|
+
* If a window.onerror handler was registered we will return the result of this handler.
|
|
1146
|
+
*
|
|
1147
|
+
* Make sure not to overwrite the window.onerror handler after enabling the JS error
|
|
1148
|
+
* tracking as the error tracking won't work otherwise. To capture all JS errors we
|
|
1149
|
+
* recommend to include the Matomo JavaScript tracker in the HTML as early as possible.
|
|
1150
|
+
* If possible directly in <head></head> before loading any other JavaScript.
|
|
1151
|
+
*/
|
|
1152
|
+
enableJSErrorTracking: () => void
|
|
1153
|
+
|
|
1154
|
+
/**
|
|
1155
|
+
* Disable automatic performance tracking
|
|
1156
|
+
*/
|
|
1157
|
+
disablePerformanceTracking: () => void
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* Set heartbeat (in seconds)
|
|
1161
|
+
*
|
|
1162
|
+
* @param heartBeatDelayInSeconds Defaults to 15s. Cannot be lower than 5.
|
|
1163
|
+
*/
|
|
1164
|
+
enableHeartBeatTimer: (heartBeatDelayInSeconds: number) => void
|
|
1165
|
+
|
|
1166
|
+
/**
|
|
1167
|
+
* Disable heartbeat if it was previously activated.
|
|
1168
|
+
*/
|
|
1169
|
+
disableHeartBeatTimer: () => void
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* Frame buster
|
|
1173
|
+
*/
|
|
1174
|
+
killFrame: () => void
|
|
1175
|
+
|
|
1176
|
+
/**
|
|
1177
|
+
* Redirect if browsing offline (aka file: buster).
|
|
1178
|
+
*
|
|
1179
|
+
* @param url Redirect to this URL
|
|
1180
|
+
*/
|
|
1181
|
+
redirectFile: (url: string) => void
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* Count sites in pre-rendered state
|
|
1185
|
+
*
|
|
1186
|
+
* @param enable If true, track when in pre-rendered state
|
|
1187
|
+
*/
|
|
1188
|
+
setCountPreRendered: (enable: boolean) => void
|
|
1189
|
+
|
|
1190
|
+
/**
|
|
1191
|
+
* Trigger a goal
|
|
1192
|
+
*/
|
|
1193
|
+
trackGoal: (idGoal: number | string, customRevenue: number, customData: any, callback: Function) => unknown
|
|
1194
|
+
|
|
1195
|
+
/**
|
|
1196
|
+
* Manually log a click from your own code
|
|
1197
|
+
*/
|
|
1198
|
+
trackLink: (sourceUrl: string, linkType: string, customData: any, callback: Function) => unknown
|
|
1199
|
+
|
|
1200
|
+
/**
|
|
1201
|
+
* Get the number of page views that have been tracked so far within the currently loaded page.
|
|
1202
|
+
*/
|
|
1203
|
+
getNumTrackedPageViews: () => number
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* Log visit to this page
|
|
1207
|
+
*/
|
|
1208
|
+
trackPageView: (customTitle: string, customData?: any, callback?: Function) => void
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* Scans the entire DOM for all content blocks and tracks all impressions once the DOM ready event has
|
|
1212
|
+
* been triggered.
|
|
1213
|
+
*
|
|
1214
|
+
* If you only want to track visible content impressions have a look at `trackVisibleContentImpressions()`.
|
|
1215
|
+
* We do not track an impression of the same content block twice if you call this method multiple times
|
|
1216
|
+
* unless `trackPageView()` is called meanwhile. This is useful for single page applications.
|
|
1217
|
+
*/
|
|
1218
|
+
trackAllContentImpressions: () => unknown
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* Scans the entire DOM for all content blocks as soon as the page is loaded. It tracks an impression
|
|
1222
|
+
* only if a content block is actually visible. Meaning it is not hidden and the content is or was at
|
|
1223
|
+
* some point in the viewport.
|
|
1224
|
+
*
|
|
1225
|
+
* If you want to track all content blocks have a look at `trackAllContentImpressions()`.
|
|
1226
|
+
* We do not track an impression of the same content block twice if you call this method multiple times
|
|
1227
|
+
* unless `trackPageView()` is called meanwhile. This is useful for single page applications.
|
|
1228
|
+
*
|
|
1229
|
+
* Once you have called this method you can no longer change `checkOnScroll` or `timeIntervalInMs`.
|
|
1230
|
+
*
|
|
1231
|
+
* If you do want to only track visible content blocks but not want us to perform any automatic checks
|
|
1232
|
+
* as they can slow down your frames per second you can call `trackVisibleContentImpressions()` or
|
|
1233
|
+
* `trackContentImpressionsWithinNode()` manually at any time to re-scan the entire DOM for newly
|
|
1234
|
+
* visible content blocks.
|
|
1235
|
+
* o Call `trackVisibleContentImpressions(false, 0)` to initially track only visible content impressions
|
|
1236
|
+
* o Call `trackVisibleContentImpressions()` at any time again to re-scan the entire DOM for newly visible content blocks or
|
|
1237
|
+
* o Call `trackContentImpressionsWithinNode(node)` at any time to re-scan only a part of the DOM for newly visible content blocks
|
|
1238
|
+
*
|
|
1239
|
+
* @param [checkOnScroll=true] Optional, you can disable re-scanning the entire DOM automatically
|
|
1240
|
+
* after each scroll event by passing the value `false`. If enabled,
|
|
1241
|
+
* we check whether a previously hidden content blocks became visible
|
|
1242
|
+
* after a scroll and if so track the impression.
|
|
1243
|
+
* Note: If a content block is placed within a scrollable element
|
|
1244
|
+
* (`overflow: scroll`), we can currently not detect when this block
|
|
1245
|
+
* becomes visible.
|
|
1246
|
+
* @param [timeIntervalInMs=750] Optional, you can define an interval to re-scan the entire DOM
|
|
1247
|
+
* for new impressions every X milliseconds by passing
|
|
1248
|
+
* for instance `timeIntervalInMs=500` (re-scan DOM every 500ms).
|
|
1249
|
+
* Re-scanning the entire DOM and detecting the visible state of content
|
|
1250
|
+
* blocks can take a while depending on the browser and amount of content.
|
|
1251
|
+
* In case your frames per second goes down you might want to increase
|
|
1252
|
+
* this value or disable it by passing the value `0`.
|
|
1253
|
+
*/
|
|
1254
|
+
trackVisibleContentImpressions: (checkOnScroll: boolean, timeIntervalInMs: number) => void
|
|
1255
|
+
|
|
1256
|
+
/**
|
|
1257
|
+
* Tracks a content impression using the specified values. You should not call this method too often
|
|
1258
|
+
* as each call causes an XHR tracking request and can slow down your site or your server.
|
|
1259
|
+
*
|
|
1260
|
+
* @param contentName For instance "Ad Sale".
|
|
1261
|
+
* @param [contentPiece='Unknown'] For instance a path to an image or the text of a text ad.
|
|
1262
|
+
* @param [contentTarget] For instance the URL of a landing page.
|
|
1263
|
+
*/
|
|
1264
|
+
trackContentImpression: (contentName: string, contentPiece: string, contentTarget: string) => void
|
|
1265
|
+
|
|
1266
|
+
/**
|
|
1267
|
+
* Scans the given DOM node and its children for content blocks and tracks an impression for them if
|
|
1268
|
+
* no impression was already tracked for it. If you have called `trackVisibleContentImpressions()`
|
|
1269
|
+
* upfront only visible content blocks will be tracked. You can use this method if you, for instance,
|
|
1270
|
+
* dynamically add an element using JavaScript to your DOM after we have tracked the initial impressions. */
|
|
1271
|
+
trackContentImpressionsWithinNode: (domNode: Element) => void
|
|
1272
|
+
|
|
1273
|
+
/**
|
|
1274
|
+
* Tracks a content interaction using the specified values. You should use this method only in conjunction
|
|
1275
|
+
* with `trackContentImpression()`. The specified `contentName` and `contentPiece` has to be exactly the
|
|
1276
|
+
* same as the ones that were used in `trackContentImpression()`. Otherwise the interaction will not count.
|
|
1277
|
+
*
|
|
1278
|
+
* @param contentInteraction The type of interaction that happened. For instance 'click' or 'submit'.
|
|
1279
|
+
* @param contentName The name of the content. For instance "Ad Sale".
|
|
1280
|
+
* @param [contentPiece='Unknown'] The actual content. For instance a path to an image or the text of a text ad.
|
|
1281
|
+
* @param [contentTarget] For instance the URL of a landing page.
|
|
1282
|
+
*/
|
|
1283
|
+
trackContentInteraction: (contentInteraction: string, contentName: string, contentPiece: string, contentTarget: string) => void
|
|
1284
|
+
|
|
1285
|
+
/**
|
|
1286
|
+
* Tracks an interaction with the given DOM node / content block.
|
|
1287
|
+
*
|
|
1288
|
+
* By default we track interactions on click but sometimes you might want to track interactions yourself.
|
|
1289
|
+
* For instance you might want to track an interaction manually on a double click or a form submit.
|
|
1290
|
+
* Make sure to disable the automatic interaction tracking in this case by specifying either the CSS
|
|
1291
|
+
* class `matomoContentIgnoreInteraction` or the attribute `data-content-ignoreinteraction`.
|
|
1292
|
+
*
|
|
1293
|
+
* @param domNode This element itself or any of its parent elements has to be a content block
|
|
1294
|
+
* element. Meaning one of those has to have a `matomoTrackContent` CSS class or
|
|
1295
|
+
* a `data-track-content` attribute.
|
|
1296
|
+
* @param [contentInteraction='Unknown] The name of the interaction that happened. For instance
|
|
1297
|
+
* 'click', 'formSubmit', 'DblClick', ...
|
|
1298
|
+
*/
|
|
1299
|
+
trackContentInteractionNode: (domNode: Element, contentInteraction: string) => unknown
|
|
1300
|
+
|
|
1301
|
+
/**
|
|
1302
|
+
* Useful to debug content tracking. This method will log all detected content blocks to console
|
|
1303
|
+
* (if the browser supports the console). It will list the detected name, piece, and target of each
|
|
1304
|
+
* content block.
|
|
1305
|
+
*/
|
|
1306
|
+
logAllContentBlocksOnPage: () => unknown
|
|
1307
|
+
|
|
1308
|
+
/**
|
|
1309
|
+
* Records an event
|
|
1310
|
+
*
|
|
1311
|
+
* @param {string} category The Event Category (Videos, Music, Games...)
|
|
1312
|
+
* @param {string} action The Event's Action (Play, Pause, Duration, Add Playlist, Downloaded, Clicked...)
|
|
1313
|
+
* @param {string} name (optional) The Event's object Name (a particular Movie name, or Song name, or File name...)
|
|
1314
|
+
* @param {float} value (optional) The Event's value
|
|
1315
|
+
* @param {Function} callback
|
|
1316
|
+
* @param {any} customData
|
|
1317
|
+
*/
|
|
1318
|
+
trackEvent: (category: any, action: any, name: any, value: any, customData: any, callback: any) => unknown
|
|
1319
|
+
|
|
1320
|
+
/**
|
|
1321
|
+
* Log special pageview: Internal search
|
|
1322
|
+
*
|
|
1323
|
+
* @param {string} keyword
|
|
1324
|
+
* @param {string} category
|
|
1325
|
+
* @param {number} resultsCount
|
|
1326
|
+
* @param {any} customData
|
|
1327
|
+
*/
|
|
1328
|
+
trackSiteSearch: (keyword: any, category: any, resultsCount: any, customData: any) => unknown
|
|
1329
|
+
|
|
1330
|
+
/**
|
|
1331
|
+
* Used to record that the current page view is an item (product) page view, or a Ecommerce Category page view.
|
|
1332
|
+
* This must be called before trackPageView() on the product/category page.
|
|
1333
|
+
*
|
|
1334
|
+
* On a category page, you can set the parameter category, and set the other parameters to empty string or false
|
|
1335
|
+
*
|
|
1336
|
+
* Tracking Product/Category page views will allow Matomo to report on Product & Categories
|
|
1337
|
+
* conversion rates (Conversion rate = Ecommerce orders containing this product or category / Visits to the product or category)
|
|
1338
|
+
* @param {string} sku Item's SKU code being viewed
|
|
1339
|
+
* @param {string} name Item's Name being viewed
|
|
1340
|
+
* @param {string} category Category page being viewed. On an Item's page, this is the item's category
|
|
1341
|
+
* @param {float} price Item's display price, not use in standard Matomo reports, but output in API product reports.
|
|
1342
|
+
*/
|
|
1343
|
+
setEcommerceView: (sku: any, name: any, category: any, price: any) => unknown
|
|
1344
|
+
|
|
1345
|
+
/**
|
|
1346
|
+
* Returns the list of ecommerce items that will be sent when a cart update or order is tracked.
|
|
1347
|
+
* The returned value is read-only, modifications will not change what will be tracked. Use
|
|
1348
|
+
* addEcommerceItem/removeEcommerceItem/clearEcommerceCart to modify what items will be tracked.
|
|
1349
|
+
*
|
|
1350
|
+
* Note: the cart will be cleared after an order.
|
|
1351
|
+
*
|
|
1352
|
+
*/
|
|
1353
|
+
getEcommerceItems: () => Array<unknown>
|
|
1354
|
+
|
|
1355
|
+
/**
|
|
1356
|
+
* Adds an item (product) that is in the current Cart or in the Ecommerce order.
|
|
1357
|
+
* This function is called for every item (product) in the Cart or the Order.
|
|
1358
|
+
* The only required parameter is sku.
|
|
1359
|
+
* The items are deleted from this JavaScript object when the Ecommerce order is tracked via the method trackEcommerceOrder.
|
|
1360
|
+
*
|
|
1361
|
+
* If there is already a saved item for the given sku, it will be updated with the
|
|
1362
|
+
* new information.
|
|
1363
|
+
*
|
|
1364
|
+
* @param {string} sku (required) Item's SKU Code. This is the unique identifier for the product.
|
|
1365
|
+
* @param {string} name (optional) Item's name
|
|
1366
|
+
* @param {string} name (optional) Item's category, or array of up to 5 categories
|
|
1367
|
+
* @param {float} price (optional) Item's price. If not specified, will default to 0
|
|
1368
|
+
* @param {float} quantity (optional) Item's quantity. If not specified, will default to 1
|
|
1369
|
+
*/
|
|
1370
|
+
addEcommerceItem: (sku: any, name?: any, category?: any, price?: any, quantity?: any) => unknown
|
|
1371
|
+
|
|
1372
|
+
/**
|
|
1373
|
+
* Removes a single ecommerce item by SKU from the current cart.
|
|
1374
|
+
*
|
|
1375
|
+
* @param {string} sku (required) Item's SKU Code. This is the unique identifier for the product.
|
|
1376
|
+
*/
|
|
1377
|
+
removeEcommerceItem: (sku: any) => void
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* Clears the current cart, removing all saved ecommerce items. Call this method to manually clear
|
|
1381
|
+
* the cart before sending an ecommerce order.
|
|
1382
|
+
*/
|
|
1383
|
+
clearEcommerceCart: () => void
|
|
1384
|
+
|
|
1385
|
+
/**
|
|
1386
|
+
* Tracks an Ecommerce order.
|
|
1387
|
+
* If the Ecommerce order contains items (products), you must call first the addEcommerceItem() for each item in the order.
|
|
1388
|
+
* All revenues (grandTotal, subTotal, tax, shipping, discount) will be individually summed and reported in Matomo reports.
|
|
1389
|
+
* Parameters orderId and grandTotal are required. For others, you can set to false if you don't need to specify them.
|
|
1390
|
+
* After calling this method, items added to the cart will be removed from this JavaScript object.
|
|
1391
|
+
*
|
|
1392
|
+
* @param orderId (required) Unique Order ID.
|
|
1393
|
+
* This will be used to count this order only once in the event the order page is reloaded several times.
|
|
1394
|
+
* orderId must be unique for each transaction, even on different days, or the transaction will not be recorded by Matomo.
|
|
1395
|
+
* @param grandTotal (required) Grand Total revenue of the transaction (including tax, shipping, etc.)
|
|
1396
|
+
* @param subTotal (optional) Sub total amount, typically the sum of items prices for all items in this order (before Tax and Shipping costs are applied)
|
|
1397
|
+
* @param tax (optional) Tax amount for this order
|
|
1398
|
+
* @param shipping (optional) Shipping amount for this order
|
|
1399
|
+
* @param discount (optional) Discounted amount in this order
|
|
1400
|
+
*/
|
|
1401
|
+
trackEcommerceOrder: (orderId: string | number, grandTotal: number, subTotal?: number, tax?: number, shipping?: number, discount?: number) => unknown
|
|
1402
|
+
|
|
1403
|
+
/**
|
|
1404
|
+
* Tracks a Cart Update (add item, remove item, update item).
|
|
1405
|
+
* On every Cart update, you must call addEcommerceItem() for each item (product) in the cart, including the items that haven't been updated since the last cart update.
|
|
1406
|
+
* Then you can call this function with the Cart grandTotal (typically the sum of all items' prices) Calling this method does not remove from this JavaScript object the items that were added to the cart via addEcommerceItem
|
|
1407
|
+
*
|
|
1408
|
+
* @param grandTotal Items (products) amount in the Cart
|
|
1409
|
+
*/
|
|
1410
|
+
trackEcommerceCartUpdate: (grandTotal: number) => unknown
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* Sends a tracking request with custom request parameters.
|
|
1414
|
+
* Matomo will prepend the hostname and path to Matomo, as well as all other needed tracking request
|
|
1415
|
+
* parameters prior to sending the request. Useful eg if you track custom dimensions via a plugin.
|
|
1416
|
+
*
|
|
1417
|
+
* @param request eg. "param=value¶m2=value2"
|
|
1418
|
+
* @param customData
|
|
1419
|
+
* @param callback
|
|
1420
|
+
* @param pluginMethod
|
|
1421
|
+
*/
|
|
1422
|
+
trackRequest: (request: string, customData: any, callback: Function, pluginMethod: any) => unknown
|
|
1423
|
+
|
|
1424
|
+
/**
|
|
1425
|
+
* Sends a ping request.
|
|
1426
|
+
*
|
|
1427
|
+
* Ping requests do not track new actions. If they are sent within the standard visit length, they will
|
|
1428
|
+
* extend the existing visit and the current last action for the visit. If after the standard visit
|
|
1429
|
+
* length, ping requests will create a new visit using the last action in the last known visit.
|
|
1430
|
+
*/
|
|
1431
|
+
ping: () => unknown
|
|
1432
|
+
|
|
1433
|
+
/**
|
|
1434
|
+
* Disables sending requests queued
|
|
1435
|
+
*/
|
|
1436
|
+
disableQueueRequest: () => unknown
|
|
1437
|
+
|
|
1438
|
+
/**
|
|
1439
|
+
* Won't send the tracking request directly but wait for a short time to possibly send this tracking request
|
|
1440
|
+
* along with other tracking requests in one go. This can reduce the number of requests send to your server.
|
|
1441
|
+
* If the page unloads (user navigates to another page or closes the browser), then all remaining queued
|
|
1442
|
+
* requests will be sent immediately so that no tracking request gets lost.
|
|
1443
|
+
* Note: Any queued request may not be possible to be replayed in case a POST request is sent. Only queue
|
|
1444
|
+
* requests that don't have to be replayed.
|
|
1445
|
+
*
|
|
1446
|
+
* @param request eg. "param=value¶m2=value2"
|
|
1447
|
+
*/
|
|
1448
|
+
queueRequest: (request: string) => unknown
|
|
1449
|
+
|
|
1450
|
+
/**
|
|
1451
|
+
* Returns whether consent is required or not.
|
|
1452
|
+
*
|
|
1453
|
+
*/
|
|
1454
|
+
isConsentRequired: () => boolean
|
|
1455
|
+
|
|
1456
|
+
/**
|
|
1457
|
+
* If the user has given consent previously and this consent was remembered, it will return the number
|
|
1458
|
+
* in milliseconds since 1970/01/01 which is the date when the user has given consent. Please note that
|
|
1459
|
+
* the returned time depends on the users local time which may not always be correct.
|
|
1460
|
+
*
|
|
1461
|
+
*/
|
|
1462
|
+
getRememberedConsent: () => number | string
|
|
1463
|
+
|
|
1464
|
+
/**
|
|
1465
|
+
* Detects whether the user has given consent previously.
|
|
1466
|
+
*
|
|
1467
|
+
*/
|
|
1468
|
+
hasRememberedConsent: () => boolean
|
|
1469
|
+
|
|
1470
|
+
/**
|
|
1471
|
+
* When called, no tracking request will be sent to the Matomo server until you have called `setConsentGiven()`
|
|
1472
|
+
* unless consent was given previously AND you called {@link rememberConsentGiven()} when the user gave their
|
|
1473
|
+
* consent.
|
|
1474
|
+
*
|
|
1475
|
+
* This may be useful when you want to implement for example a popup to ask for consent before tracking the user.
|
|
1476
|
+
* Once the user has given consent, you should call {@link setConsentGiven()} or {@link rememberConsentGiven()}.
|
|
1477
|
+
*
|
|
1478
|
+
* If you require consent for tracking personal data for example, you should first call
|
|
1479
|
+
* `_paq.push(['requireConsent'])`.
|
|
1480
|
+
*
|
|
1481
|
+
* If the user has already given consent in the past, you can either decide to not call `requireConsent` at all
|
|
1482
|
+
* or call `_paq.push(['setConsentGiven'])` on each page view at any time after calling `requireConsent`.
|
|
1483
|
+
*
|
|
1484
|
+
* When the user gives you the consent to track data, you can also call `_paq.push(['rememberConsentGiven', optionalTimeoutInHours])`
|
|
1485
|
+
* and for the duration while the consent is remembered, any call to `requireConsent` will be automatically ignored until you call `forgetConsentGiven`.
|
|
1486
|
+
* `forgetConsentGiven` needs to be called when the user removes consent for tracking. This means if you call `rememberConsentGiven` at the
|
|
1487
|
+
* time the user gives you consent, you do not need to ever call `_paq.push(['setConsentGiven'])`.
|
|
1488
|
+
*/
|
|
1489
|
+
requireConsent: () => unknown
|
|
1490
|
+
|
|
1491
|
+
/**
|
|
1492
|
+
* Call this method once the user has given consent. This will cause all tracking requests from this
|
|
1493
|
+
* page view to be sent. Please note that the given consent won't be remembered across page views. If you
|
|
1494
|
+
* want to remember consent across page views, call {@link rememberConsentGiven()} instead.
|
|
1495
|
+
*
|
|
1496
|
+
* It will also automatically enable cookies if they were disabled previously.
|
|
1497
|
+
*
|
|
1498
|
+
* @param setCookieConsent [=true] Internal parameter. Defines whether cookies should be enabled or not.
|
|
1499
|
+
*/
|
|
1500
|
+
setConsentGiven: (setCookieConsent: boolean) => void
|
|
1501
|
+
|
|
1502
|
+
/**
|
|
1503
|
+
* Calling this method will remember that the user has given consent across multiple requests by setting
|
|
1504
|
+
* a cookie. You can optionally define the lifetime of that cookie in hours using a parameter.
|
|
1505
|
+
*
|
|
1506
|
+
* When you call this method, we imply that the user has given consent for this page view, and will also
|
|
1507
|
+
* imply consent for all future page views unless the cookie expires (if timeout defined) or the user
|
|
1508
|
+
* deletes all their cookies. This means even if you call {@link requireConsent()}, then all requests
|
|
1509
|
+
* will still be tracked.
|
|
1510
|
+
*
|
|
1511
|
+
* Please note that this feature requires you to set the `cookieDomain` and `cookiePath` correctly and requires
|
|
1512
|
+
* that you do not disable cookies. Please also note that when you call this method, consent will be implied
|
|
1513
|
+
* for all sites that match the configured cookieDomain and cookiePath. Depending on your website structure,
|
|
1514
|
+
* you may need to restrict or widen the scope of the cookie domain/path to ensure the consent is applied
|
|
1515
|
+
* to the sites you want.
|
|
1516
|
+
*
|
|
1517
|
+
* @param hoursToExpire After how many hours the consent should expire. By default the consent is valid
|
|
1518
|
+
* for 30 years unless cookies are deleted by the user or the browser prior to this
|
|
1519
|
+
*/
|
|
1520
|
+
rememberConsentGiven: (hoursToExpire: number) => unknown
|
|
1521
|
+
|
|
1522
|
+
/**
|
|
1523
|
+
* Calling this method will remove any previously given consent and during this page view no request
|
|
1524
|
+
* will be sent anymore ({@link requireConsent()}) will be called automatically to ensure the removed
|
|
1525
|
+
* consent will be enforced. You may call this method if the user removes consent manually, or if you
|
|
1526
|
+
* want to re-ask for consent after a specific time period.
|
|
1527
|
+
*/
|
|
1528
|
+
forgetConsentGiven: () => unknown
|
|
1529
|
+
|
|
1530
|
+
/**
|
|
1531
|
+
* Returns true if user is opted out, false if otherwise.
|
|
1532
|
+
*
|
|
1533
|
+
*/
|
|
1534
|
+
isUserOptedOut: () => boolean
|
|
1535
|
+
|
|
1536
|
+
/**
|
|
1537
|
+
* Alias for forgetConsentGiven(). After calling this function, the user will no longer be tracked,
|
|
1538
|
+
* (even if they come back to the site).
|
|
1539
|
+
*/
|
|
1540
|
+
optUserOut: () => void
|
|
1541
|
+
|
|
1542
|
+
/**
|
|
1543
|
+
* Alias for rememberConsentGiven(). After calling this function, the current user will be tracked.
|
|
1544
|
+
*/
|
|
1545
|
+
forgetUserOptOut: () => unknown
|
|
1546
|
+
}
|
|
1547
|
+
}
|