dot-sdk-analytics

Installs and configures the @dotcms/analytics SDK for event tracking in Next.js projects.

950|482|Updated Mar 15, 2012
One-click install
npx skills add https://github.com/dotCMS/core --skill dot-sdk-analytics
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dot-sdk-analytics
Source: https://github.com/dotCMS/core/tree/main/.claude/skills/dot-sdk-analytics
Command: npx skills add https://github.com/dotCMS/core --skill dot-sdk-analytics

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @dotcms/analytics.

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.

Frequently Asked Questions about dot-sdk-analytics

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

FAQPage Schema
How do I install @dotcms/analytics in a Next.js project?

Run npm install @dotcms/analytics in the project directory, create a centralized analytics.config.js with your siteAuth and server values, then add the DotContentAnalytics component to your root layout for automatic pageview tracking.

How do I track custom events with the dotCMS analytics SDK?

Import useContentAnalytics from @dotcms/analytics/react and pass your analytics config as a parameter. The returned track function accepts an event name and optional properties object, such as track('cta-click', { button: 'Buy Now' }).

Does useContentAnalytics use React Context from DotContentAnalytics?

No. DotContentAnalytics only handles automatic pageview tracking and is not a context provider. The useContentAnalytics hook always requires the config object passed directly as a parameter in every component that uses it.

Why are my dotCMS analytics events not appearing?

Verify siteAuth and server values are correct, enable debug mode for console logs, and check network requests to /api/v1/analytics/content/event return 200. Analytics are automatically disabled inside the dotCMS editor, so test in preview or published mode.

When should I track a conversion event instead of a custom event?

Track conversions only after a business goal is actually completed, such as a confirmed purchase, finished download, or successful signup. Tracking conversions on clicks or attempts before success diminishes their value as conversion metrics.