@lidofinance/analytics-matomo v0.51.0
@lidofinance/analytics-matomo
Matomo analytics. You can read about Matomo there.
Installation
yarn add @lidofinance/analytics-matomo
Cookie
Module does not send matomo event if cookie forbids.
If you need to send matomo event, you should set cookie with one of key:
- 'LIDO_WIDGET__COOKIES_ALLOWED' soon will be deprecated
- 'cookie-allowed' use it
and cookie value must be 'yes'.
document.cookie = 'cookie-allowed=yes'Usage
Init Matomo
Variant 1
- Make sure that
windowcontains__env__; - Make sure that
window.__env__containsmatomoHostsomething likewindow.__env__.matomoHost='https://matomo.somedomain.com/'; - Just import any from
@lidofinance/analytics-matomo, for example:
import { trackEvent } from '@lidofinance/analytics-matomo'If you can't provide matomoHost to window.__env__ see Variant 2.
Variant 2
- Import
initMatomofrom@lidofinance/analytics-matomo; - Run
initMatomowith parametermatomoHost: stringlike below:
import { initMatomo } from '@lidofinance/analytics-matomo'
initMatomo('https://matomo.somedomain.com/')
// some codeYou can also pass any matomo configuration as a second argument
initMatomo('https://matomo.somedomain.com/', [
// enable option
['option', true],
['option'],
// disable option
['option', false],
// enable and customize option
['option', 'value'],
])Track event
import { callMatomo, trackEvent, wrapWithEventTrack } from '@lidofinance/analytics-matomo'
const matomoSomeEvent: MatomoEventType = [
'Some_Stacking_Widget',
'Push "Some" button',
'some_widget_some_button_clicked',
]
// Variant 1
callMatomo('trackEvent', ...matomoSomeEvent)
// Variant 2
trackEvent(...matomoSomeEvent)
// Variant 3: through the decorator
const someHandler = wrapWithEventTrack(matomoSomeEvent, (arg1, arg2) => {
// some function
})
someHandler('some_value1', 'some_value2')11 months ago
1 year ago
11 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago