Skip to content

Commit

Permalink
fix: umami tracking (techno-tim#603)
Browse files Browse the repository at this point in the history
* fix: umami tracking

* fix: umami tracking test
  • Loading branch information
kdurek authored Apr 16, 2024
1 parent 88c4e48 commit 2440d47
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/analytics/__test__/umami.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/analytics/umami.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function trackUmamiEvent(event) {
window.umami(event);
window.umami.track(event);
}

0 comments on commit 2440d47

Please sign in to comment.