📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Proper Swetrix Analytics setup
Blue Mouse0ae40e0a0645
diff --git a/docs/app/components/Analytics.tsx b/docs/app/components/Analytics.tsxnew file mode 100644index 000000000..6b18b4294--- /dev/null+++ b/docs/app/components/Analytics.tsx@@ -0,0 +1,15 @@+"use client";++import { useEffect } from "react";+import * as Swetrix from "swetrix";++const SWETRIX_PID = "STEzHcB1rALV";++export default function Analytics() {+ useEffect(() => {+ Swetrix.init(SWETRIX_PID);+ Swetrix.trackViews();+ }, []);++ return null;+}diff --git a/docs/app/layout.tsx b/docs/app/layout.tsxindex 9133777a8..b61c49652 100644--- a/docs/app/layout.tsx+++ b/docs/app/layout.tsx@@ -3,8 +3,8 @@ import { DocsLayout } from "fumadocs-ui/layouts/docs";import { GithubInfo } from "fumadocs-ui/components/github-info";import type { ReactNode } from "react";import { source } from "@/lib/source";-import Script from "next/script";import Footer from "./components/Footer";+import Analytics from "./components/Analytics";import "./global.css";export const metadata = {@@ -19,17 +19,7 @@ export const metadata = {export default function RootLayout({ children }: { children: ReactNode }) {return (<html lang="en" suppressHydrationWarning>- <head>- <Script src="https://swetrix.org/swetrix.js" strategy="afterInteractive" />- <Script id="swetrix-init" strategy="afterInteractive">- {`- document.addEventListener('DOMContentLoaded', function () {- swetrix.init('STEzHcB1rALV');- swetrix.trackViews();- });- `}- </Script>- </head>+ <head /><body><RootProvider><DocsLayout@@ -68,6 +58,7 @@ export default function RootLayout({ children }: { children: ReactNode }) {{children}</DocsLayout><Footer />+ <Analytics /></RootProvider></body></html>diff --git a/docs/package-lock.json b/docs/package-lock.jsonindex ce1baaadc..dd6803421 100644--- a/docs/package-lock.json+++ b/docs/package-lock.json@@ -20,6 +20,7 @@"react": "^19.2.4","react-dom": "^19.2.4","simple-icons": "^16.9.0",+ "swetrix": "^4.1.0","tailwind-merge": "^3.5.0"},"devDependencies": {@@ -6280,6 +6281,15 @@}}},+ "node_modules/swetrix": {+ "version": "4.1.0",+ "resolved": "https://registry.npmjs.org/swetrix/-/swetrix-4.1.0.tgz",+ "integrity": "sha512-TPOr14oYBt3LquPfWqBjRP6IhbQ+WOiz8ticORRvg4gECb3loFbHB455OUWcpXPCTaFi/E9s5TVgxgqIX+viHQ==",+ "license": "MIT",+ "funding": {+ "url": "https://github.com/sponsors/Swetrix"+ }+ },"node_modules/tailwind-merge": {"version": "3.5.0","resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.5.0.tgz",diff --git a/docs/package.json b/docs/package.jsonindex 9629e1b9e..a6fe39c6c 100644--- a/docs/package.json+++ b/docs/package.json@@ -22,6 +22,7 @@"react": "^19.2.4","react-dom": "^19.2.4","simple-icons": "^16.9.0",+ "swetrix": "^4.1.0","tailwind-merge": "^3.5.0"},"devDependencies": {