SDK Analytics Installer

Install and configure the @dotcms/analytics SDK in Next.js and React projects.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/tony-adm/dotCMSdocker --skill sdk-analytics-installer-tony-adm
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: SDK Analytics Installer
Source: https://github.com/tony-adm/dotCMSdocker/tree/main/.claude/skills/sdk-analytics
Command: npx skills add https://github.com/tony-adm/dotCMSdocker --skill sdk-analytics-installer-tony-adm

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill automates installing and configuring the dotCMS Analytics SDK (@dotcms/analytics) in Next.js/React projects, ensuring a consistent, ready-to-use analytics setup that saves time and reduces errors.

Core Features & Use Cases

  • Automated SDK installation: Install and configure the analytics SDK quickly in Next.js apps.
  • Centralized configuration: Provide a single source of truth for site authentication and server endpoints.
  • Use Case: Wire up analytics in a Next.js project to auto-track page views and events with a centralized config.

Quick Start

Use the SDK Analytics Installer skill to set up the analytics SDK in the Next.js example project at /core/examples/nextjs. Ensure environment variables NEXT_PUBLIC_DOTCMS_ANALYTICS_SITE_KEY and NEXT_PUBLIC_DOTCMS_ANALYTICS_HOST are defined.

Frequently Asked Questions about SDK Analytics Installer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up analytics tracking in a Next.js project?

Install the @dotcms/analytics SDK and configure it with a centralized analytics.config.js file containing siteAuth and server settings. Add the DotContentAnalytics integration to your root layout to enable automatic page view tracking on route changes and manual event tracking via the useContentAnalytics() hook.

What environment variables do I need for the Analytics SDK in Next.js?

Set NEXT_PUBLIC_DOTCMS_ANALYTICS_SITE_KEY and NEXT_PUBLIC_DOTCMS_ANALYTICS_HOST as environment variables. These supply the required siteAuth and server configuration to the SDK for tracking initialization and session management.

Can I track custom events with the Analytics SDK in React?

Yes, use the useContentAnalytics() hook with a config argument to manually track custom events. The SDK batches events automatically and maintains 30-minute session timeouts with anonymous identity and UTM parameter tracking.

Does the Analytics SDK work with both Next.js and React applications?

The SDK supports both Next.js and React projects. Next.js apps gain automatic page view tracking on route changes when integrated in the root layout, while React apps use manual event tracking through the useContentAnalytics() hook.

What configuration is required before using the useContentAnalytics hook?

Create a central analytics.config.js file that exposes siteAuth and server endpoints. This centralized configuration is mandatory for the useContentAnalytics() hook to function and enables consistent analytics behavior across your application.