Skip to content

Commit

Permalink
fix: fix matomo tracking inside react
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzalowski committed Dec 17, 2024
1 parent 51962d9 commit d101647
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 45 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ changes.

### Fixed

-
- Move matomo initalization out of the react code

### Changed

Expand Down
31 changes: 20 additions & 11 deletions govtool/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,27 @@
</head>
<body>
<script>
var _paq = window._paq = window._paq || [];
var isMainnet = window.location.hostname == "gov.tools";
var isPreview = window.location.hostname == "preview.gov.tools";

var _paq = (window._paq = window._paq || []);
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//p80-zca17e2b0-z1743beba-gtw.z937eb260.rustrocks.fr/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true;
g.src=u+'matomo.js';
s.parentNode.insertBefore(g,s);
_paq.push(["trackPageView"]);
_paq.push(["enableLinkTracking"]);
(function () {
if (!isPreview && !isMainnet) {
return;
}

var u = "//analytics.gov.tools/";
_paq.push(["setTrackerUrl", u + "matomo.php"]);
_paq.push(["setSiteId", isMainnet ? "1" : "2"]);
var d = document,
g = d.createElement("script"),
s = d.getElementsByTagName("script")[0];
g.async = true;
g.src = u + "matomo.js";
s.parentNode.insertBefore(g, s);
})();
</script>
<div id="root"></div>
Expand Down
2 changes: 0 additions & 2 deletions govtool/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ import {
import { PublicRoute } from "./pages/PublicRoute";
import { TopBanners } from "./components/organisms/TopBanners";
import { DashboardHome } from "./pages/DashboardHome";
import { useMatomo } from "./hooks/useMatomo";

export default () => {
useMatomo();
const { isProposalDiscussionForumEnabled } = useFeatureFlag();
const { enable, isEnabled } = useCardano();
const navigate = useNavigate();
Expand Down
31 changes: 0 additions & 31 deletions govtool/frontend/src/hooks/useMatomo.ts

This file was deleted.

0 comments on commit d101647

Please sign in to comment.