Skip to content

Commit f2a12b1

Browse files
[#671] Add staticID for matomo idc site
1 parent 479b26c commit f2a12b1

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

frontend/.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
PUBLIC_URL=/
2-
REACT_APP_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com
3-
REACT_APP_PUBLIC_POSTHOG_KEY=phc_GGBItNncBi9Lrf8Q2Wr6sTGodzACFi4RnUd0aqIPn11
2+
REACT_APP_PUBLIC_POSTHOG_HOST=
3+
REACT_APP_PUBLIC_POSTHOG_KEY=

frontend/public/index.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,18 @@
2727

2828
<!-- Matomo Cloudron -->
2929
<script>
30-
var _paq = (window._paq = window._paq || []);
30+
var testEnvs = ["test", "localhost", "staging", "ngrok", ".dev"];
31+
var origin = window?.location?.origin;
32+
var siteID = testEnvs.some((env) => origin?.includes(env)) ? "2" : "3";
3133

34+
var _paq = (window._paq = window._paq || []);
35+
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
36+
_paq.push(["trackPageView"]);
37+
_paq.push(["enableLinkTracking"]);
3238
(function () {
3339
var u = "https://matomo.cloud.akvo.org/";
3440
_paq.push(["setTrackerUrl", u + "matomo.php"]);
35-
_paq.push(["setSiteId", "2"]);
36-
_paq.push(["enableLinkTracking"]);
37-
41+
_paq.push(["setSiteId", siteID]);
3842
var d = document,
3943
g = d.createElement("script"),
4044
s = d.getElementsByTagName("script")[0];

0 commit comments

Comments
 (0)