Skip to content

Commit

Permalink
Update external_tracking.md (#161)
Browse files Browse the repository at this point in the history
Umami Analytics tracking setup.
  • Loading branch information
h0ek authored Nov 12, 2024
1 parent a454e3e commit 957de0f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/external_tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,38 @@ navigation.addEventListener("navigate", function (e) {
trackPageView()
});
```
## Set up for Umami Analytics

> ⚠️ Make sure to use your actual values for DOMAIN SCRIPT URL and <WEBSITE_ID>
### Allow loading tracking script

Set the following env vars:

```ini
SECURITY_HEADER_SCRIPT_SRC_ALLOW=https://umami.example.com/script.js
SECURITY_HEADER_CSP_CONNECT_SRC=https://umami.example.com/script.js
```

### Add custom JavaScript

Add the following to Settings > Custom JS

```javascript
(function() {
var d = document, s = d.createElement('script'), g = d.getElementsByTagName('script')[0];
s.defer = true;
s.src = 'https://umami.example.com/script.js';
s.setAttribute('data-website-id', '<WEBSITE_ID>');
g.parentNode.insertBefore(s, g);
})();

navigation.addEventListener("navigate", function (e) {
if (window.umami && typeof umami.trackView === 'function') {
umami.trackView(document.title, window.location.pathname);
}
});
```

## Other tools / custom tracking

Expand Down

0 comments on commit 957de0f

Please sign in to comment.