Hi all,
I am quite new to matomo & react and currently having a problem with the integration. What I want is to track how often a specific Button is beeing clicked.
I am trying to follow the following guide:
What I did so far:
- I have added @datapunt/matomo-tracker-react to package.json
- I have added the adjustet data to my index.tsx:
const instance = createInstance({
urlBase: 'https://LINK.TO.DOMAIN',
siteId: 3,
}
})
ReactDOM.render(
<React.StrictMode>
<SnackbarProvider>
<App />
</SnackbarProvider>
<MatomoProvider value={instance}>
<App />
</MatomoProvider>,
</React.StrictMode>,
document.getElementById('root'),
);
- I have added the adjusted data to my MyApp.tsx
import React from 'react'
import { useMatomo } from '@datapunt/matomo-tracker-react'
const { trackPageView, trackEvent } = useMatomo()
const handleOnClick = () => {
// Track click on button
trackEvent({ category: 'sample-page', action: 'click-event' })
}
However - there seems to be a problem with my index.tsx and the ReactDOM.render() part as I always get a error message
“TypeError: Cannot destructure property ‘enqueueSnackbar’ of ‘Object(…)(…)’ as it is undefined.”
Hope you can help me with this!