Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Add domain filter to tracker.

Mike Cao195eb06a0291
diff --git a/package.json b/package.json
index 0d602350b..c21f3076d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "umami",
- "version": "0.77.0",
+ "version": "0.78.0",
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
"author": "Mike Cao <[email protected]>",
"license": "MIT",
diff --git a/tracker/index.js b/tracker/index.js
index 154e0034b..df4c52161 100644
--- a/tracker/index.js
+++ b/tracker/index.js
@@ -19,8 +19,19 @@ import { removeTrailingSlash } from '../lib/url';
const autoTrack = attr('data-auto-track') !== 'false';
const dnt = attr('data-do-not-track');
const useCache = attr('data-cache');
-
- if (!script || (dnt && doNotTrack())) return;
+ const domains = attr('data-domains');
+
+ if (
+ !script ||
+ (dnt && doNotTrack()) ||
+ (domains &&
+ !domains
+ .split(',')
+ .map(n => n.trim())
+ .includes(hostname))
+ ) {
+ return;
+ }
const root = hostUrl
? removeTrailingSlash(hostUrl)