This commit is contained in:
parent
ca6ba2eb51
commit
69386eed63
6 changed files with 53 additions and 3 deletions
3
src/components/Analytics.astro
Normal file
3
src/components/Analytics.astro
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<script>
|
||||
import '../scripts/analytics';
|
||||
</script>
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
import Footer from '../components/Footer.astro';
|
||||
import Header from '../components/Header.astro';
|
||||
import Analytics from '../components/Analytics.astro';
|
||||
import { absoluteUrl, optimizeOgImage, site } from '../lib/site';
|
||||
import defaultOg from '../assets/og-default.jpg';
|
||||
import themeInit from '../scripts/theme-init.js?raw';
|
||||
|
|
@ -167,6 +168,7 @@ const jsonLdStrings = jsonLdEntries.map((entry) =>
|
|||
<script is:inline type="application/ld+json" set:html={jsonLdString} />
|
||||
))
|
||||
}
|
||||
<Analytics />
|
||||
</head>
|
||||
<body>
|
||||
<Header />
|
||||
|
|
|
|||
17
src/scripts/analytics.ts
Normal file
17
src/scripts/analytics.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { init as plausibleInit } from '@plausible-analytics/tracker';
|
||||
|
||||
const ANALYTICS_AUTO_CAPTURE_PAGEVIEWS = true;
|
||||
const ANALYTICS_DOMAIN = 'schmelczer.dev';
|
||||
const ANALYTICS_ENDPOINT = 'https://stats.schmelczer.dev/status';
|
||||
const ANALYTICS_LOGGING = import.meta.env.DEV;
|
||||
|
||||
try {
|
||||
plausibleInit({
|
||||
domain: ANALYTICS_DOMAIN,
|
||||
endpoint: ANALYTICS_ENDPOINT,
|
||||
autoCapturePageviews: ANALYTICS_AUTO_CAPTURE_PAGEVIEWS,
|
||||
logging: ANALYTICS_LOGGING,
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Could not initialize analytics.', error);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue