How to add and configure analytics providers in slidenerds decks
How to add analytics to a slidenerds deck. Each provider has a pre-built component the CLI generates.
The fastest way to add analytics:
npx slidenerds analytics --gtm GTM-XXXXXX
npx slidenerds analytics --ga4 G-XXXXXXXXXX
npx slidenerds analytics --posthog phc_XXXXXXXXXX
npx slidenerds analytics --plausible yourdomain.com
npx slidenerds analytics --custom
Each command creates a component in components/ with the provider ID wired in. Import it in your root layout to activate.
Analytics components go in the root layout, inside the <body> tag:
import { SlideRuntime } from '@slidenerds/runtime'
import { GTMAnalytics } from '@/components/gtm-analytics'
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
<GTMAnalytics />
<SlideRuntime>{children}</SlideRuntime>
</body>
</html>
)
}
GTM-XXXXXXG-XXXXXXXXXXphc_XXXXXXXXXXyourdomain.comAfter adding analytics:
npm run devgoogletagmanager.comgoogle-analytics.comapp.posthog.complausible.ioSlidenerds platform analytics (from slidenerds.com) and first-party analytics (GTM, GA4, etc.) coexist. They measure different things:
Both run independently and don't interfere with each other.
使用 Arthas 的 watch/trace 获取 EagleEye traceId / 获取请求的 traceId