fix: umami tracking (#603)

* fix: umami tracking

* fix: umami tracking test
This commit is contained in:
Krzysztof Durek 2024-04-17 00:07:07 +02:00 committed by GitHub
parent 88c4e48e38
commit 2440d47294
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 5 deletions

View File

@ -164,12 +164,12 @@ Generated tracking code should look like:
<script async defer data-website-id="00000000-1111-2222-3333-444444444444" src="https://your-umami-app.com/umami.js"></script>
```
Use `data-website-id` as environment variable `UMAMI_WEBSITE_ID`. Take the inital root host of `src` as `UMAMI_APP_URL`, and the name of the script (i.e. `umami.js` or `script.js`) as `UMAMI_SCRIPT_NAME`.
Use `data-website-id` as environment variable `UMAMI_WEBSITE_ID`. Take the initial root host of `src` as `UMAMI_APP_URL`, and the name of the script (i.e. `umami.js` or `script.js`) as `UMAMI_SCRIPT_NAME`.
Sample event for YouTube button.
```javascript
window.umami('youtube-button');
window.umami.track('youtube-button');
```
#### Matomo

View File

@ -27,7 +27,7 @@ Use `data-website-id` as environment variable `UMAMI_WEBSITE_ID`. Take the inita
Sample event for YouTube button.
```javascript
window.umami('youtube-button');
window.umami.track('youtube-button');
```
### Matomo

View File

@ -6,7 +6,9 @@ describe('umami.js', () => {
const originalWindow = { ...window };
windowSpy.mockImplementation(() => ({
...originalWindow,
umami: mockedUmami,
umami: {
track: mockedUmami,
},
}));
it('should call umami with event', () => {
trackUmamiEvent('youtube-button');

View File

@ -1,3 +1,3 @@
export function trackUmamiEvent(event) {
window.umami(event);
window.umami.track(event);
}