What problem does it solve?
Setting up content analytics in a Next.js or React application requires correctly installing the @dotcms/analytics SDK, centralizing configuration, wiring environment variables, and using the right components and hooks—mistakes like treating DotContentAnalytics as a context provider cause silent tracking failures.
Core Features & Use Cases
- Guided SDK Installation: Step-by-step setup of @dotcms/analytics in the Next.js example project, including package install, centralized analytics.config.js creation, and .env.local environment variables.
- Correct Usage Patterns: Explains the critical distinction between the DotContentAnalytics component (auto pageview tracking only) and the useContentAnalytics(config) hook, which always requires an explicit config parameter.
- Event Tracking Recipes: Ready-to-use code for page views, custom events, conversions (purchases, downloads, signups), impression tracking, and click tracking with queue/batching configuration.
- Use Case: A developer adding analytics to a dotCMS-powered Next.js site follows the guide to install the package, create the centralized config, add DotContentAnalytics to the root layout, and track a purchase conversion after checkout.
Quick Start
Install and configure the @dotcms/analytics SDK in the Next.js example project with automatic pageview tracking and a centralized config file.