@lidofinance/matomo
Matomo analytics. You can read about Matomo there.
Installation
yarn add @lidofinance/analytics-matomo
Usage
Init Matomo
Variant 1
- Make sure that
window
contains __env__
; - Make sure that
window.__env__
contains matomoHost
something like window.__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
initMatomo
from @lidofinance/analytics-matomo
; - Run
initMatomo
with parameter matomoHost: string
like below:
import { initMatomo } from '@lidofinance/analytics-matomo'
initMatomo('https://matomo.somedomain.com/')
Track event
import { callMatomo, trackEvent, wrapWithEventTrack } from '@lidofinance/analytics-matomo'
const matomoSomeEvent: MatomoEventType = [
'Some_Stacking_Widget',
'Push "Some" button',
'some_widget_some_button_clicked',
]
callMatomo('trackEvent', ...matomoSomeEvent)
trackEvent(...matomoSomeEvent)
const someHandler = wrapWithEventTrack(matomoSomeEvent, (arg1, arg2) => {
})
someHandler('some_value1', 'some_value2')