Install Matomo React

This commit is contained in:
Dilson's Pickles
2023-03-29 15:08:34 +01:00
parent 3c492f02cf
commit 1135cf532d
3 changed files with 27 additions and 22 deletions

17
package-lock.json generated
View File

@@ -10,6 +10,7 @@
"dependencies": {
"@astrojs/react": "^2.0.2",
"@astrojs/tailwind": "^3.0.1",
"@datapunt/matomo-tracker-react": "^0.5.1",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.10",
"astro": "^2.0.10",
@@ -506,6 +507,22 @@
"node": ">=6.9.0"
}
},
"node_modules/@datapunt/matomo-tracker-js": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/@datapunt/matomo-tracker-js/-/matomo-tracker-js-0.5.1.tgz",
"integrity": "sha512-9/MW9vt/BA5Db7tO6LqCeQKtuvBNjyq51faF3AzUmPMlYsJCnASIxcut3VqJKiribhUoey7aYbPIYuj9x4DLPA=="
},
"node_modules/@datapunt/matomo-tracker-react": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/@datapunt/matomo-tracker-react/-/matomo-tracker-react-0.5.1.tgz",
"integrity": "sha512-lrNYM9hFL6XK0VAdtMb7MwZrLWhaAconx4c7gOGAMvoWuoVm+ZZIYFuKtfYdYMeBf0avxWtmKRwjZEg7T8jV2A==",
"dependencies": {
"@datapunt/matomo-tracker-js": "^0.5.1"
},
"peerDependencies": {
"react": ">= 16.8.0"
}
},
"node_modules/@emmetio/abbreviation": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/@emmetio/abbreviation/-/abbreviation-2.2.3.tgz",

View File

@@ -12,6 +12,7 @@
"dependencies": {
"@astrojs/react": "^2.0.2",
"@astrojs/tailwind": "^3.0.1",
"@datapunt/matomo-tracker-react": "^0.5.1",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.10",
"astro": "^2.0.10",

View File

@@ -1,4 +1,5 @@
---
import { MatomoProvider, createInstance } from "@datapunt/matomo-tracker-react";
import Footer from "../components/footer/Footer.astro";
import NavigationReact from "../components/navigation/NavigationReact";
@@ -6,6 +7,11 @@ export interface Props {
title: string;
}
const { title } = Astro.props;
const instance = createInstance({
urlBase: 'https://audacity.github.io',
siteId: 3,
})
---
<!DOCTYPE html>
@@ -16,30 +22,11 @@ const { title } = Astro.props;
<link rel="icon" type="image/svg+xml" href="/favicon.png" />
<meta name="generator" content={Astro.generator} />
<title>{title}</title>
<!-- Matomo -->
<script>
var _paq = (window._paq = window._paq || []);
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["trackPageView"]);
_paq.push(["enableLinkTracking"]);
(function () {
var u = "https://audacity.matomo.cloud/";
_paq.push(["setTrackerUrl", u + "matomo.php"]);
_paq.push(["setSiteId", "2"]);
var d = document,
g = d.createElement("script"),
s = d.getElementsByTagName("script")[0];
g.async = true;
g.src = "//cdn.matomo.cloud/audacity.matomo.cloud/matomo.js";
s.parentNode.insertBefore(g, s);
})();
</script>
<!-- End Matomo Code -->
</head>
<body>
<MatomoProvider value={instance}>
<NavigationReact client:load />
<slot />
<Footer />
</body>
</MatomoProvider>
</html>