SDK Analytics Installer
БесплатноБез исполняемых скриптовНе проверенUse this skill when the user asks to install, configure, or set up @dotcms/analytics, sdk-analytics, analytics SDK, add analytics tracking, or mentions…
от Microck★ 417 звёзд на GitHubОб этом скилле
DotCMS SDK Analytics Installation Guide
This skill provides step-by-step instructions for installing and configuring the @dotcms/analytics SDK in the Next.js example project at /core/examples/nextjs.
Overview
The @dotcms/analytics SDK is dotCMS's official JavaScript library for tracking content-aware events and analytics. It provides:
- Automatic page view tracking
- Conversion tracking (purchases, downloads, sign-ups, etc.)
- Custom event tracking
- Session management (30-minute timeout)
- Anonymous user identity tracking
- UTM campaign parameter tracking
- Event batching/queuing for performance
🚨 Important: Understanding the Analytics Components
CRITICAL: useContentAnalytics() ALWAYS requires config as a parameter. The hook does NOT use React Context.
Component Roles
<DotContentAnalytics />- Auto Page View Tracker- Only purpose: Automatically track pageviews on route changes
- NOT a React Context Provider
- Does NOT provide config to child components
- Place in root layout for automatic pageview tracking
useContentAnalytics(config)- Manual Tracking Hook- Used for custom event tracking
- ALWAYS requires config parameter
- Import centralized config in each component that uses it
Correct Usage Pattern
// 1. Create centralized config file (once)
// /src/config/analytics.config.js
export const analyticsConfig = {
siteAuth: process.env.NEXT_PUBLIC_DOTCMS_ANALYTICS_SITE_KEY,
server: process.env.NEXT_PUBLIC_DOTCMS_ANALYTICS_HOST,
autoPageView: true,
debug: process.env.NEXT_PUBLIC_DOTCMS_ANALYTICS_DEBUG === "true",
};
// 2. Add DotContentAnalytics to layout for auto pageview tracking (optional)
// /src/app/layout.js
import { DotContentAnalytics } from "@dotcms/analytics/react";
import { analyticsConfig } from "@/config/analytics.config";
<DotContentAnalytics config={analyticsConfig} />;
// 3. Import config in every component that uses the hook
// /src/components/MyComponent.js
import { useContentAnalytics } from "@dotcms/analytics/react";
import { analyticsConfig } from "@/config/analytics.config";
const { track } = useContentAnalytics(analyticsConfig); // ✅ Config required!
Why centralize config? While you must import it in each component, centralizing prevents duplication and makes updates easier.
Quick Setup Summary
Here's the complete setup flow:
1. Install package
└─> npm install @dotcms/analytics
2. Create centralized config file
└─> /src/config/analytics.config.js
└─> export const analyticsConfig = { siteAuth, server, debug, ... }
3. (Optional) Add DotContentAnalytics for auto pageview tracking
└─> /src/app/layout.js
└─> import { analyticsConfig } from "@/config/analytics.config"
└─> <DotContentAnalytics config={analyticsConfig} />
4. Import config in EVERY component that uses the hook
└─> /src/components/MyComponent.js
└─> import { analyticsConfig } from "@/config/analytics.config"
└─> const { track } = useContentAnalytics(analyticsConfig) // ✅ Config required!
Key Benefits of Centralized Config:
- ✅ Single source of truth for configuration values
- ✅ Easy to update environment variables in one place
- ✅ Consistent config across all components
- ✅ Better than duplicating config in every file
Installation Steps
1. Install the Package
Navigate to the Next.js example directory and install the package:
cd /core/examples/nextjs
npm install @dotcms/analytics
2. Verify Installation
Check that the package was added to package.json:
grep "@dotcms/analytics" package.json
Expected output: "@dotcms/analytics": "latest" or similar version.
3. Create Centralized Analytics Configuration
Create a dedicated configuration file to centralize your analytics settings. This makes it easier to maintain and reuse across your application.
File: /core/examples/nextjs/src/config/analytics.config.js
/**
* Centralized analytics configuration for dotCMS Content Analytics
*
* This configuration is used by:
* - DotContentAnalytics provider in layout.js
* - useContentAnalytics() hook when used standalone (optional)
*
* Environment variables required:
* - NEXT_PUBLIC_DOTCMS_ANALYTICS_SITE_KEY
* - NEXT_PUBLIC_DOTCMS_ANALYTICS_HOST
* - NEXT_PUBLIC_DOTCMS_ANALYTICS_DEBUG (optional)
*/
export const analyticsConfig = {
siteAuth: process.env.NEXT_PUBLIC_DOTCMS_ANALYTICS_SITE_KEY,
server: process.env.NEXT_PUBLIC_DOTCMS_ANALYTICS_HOST,
autoPageView: true, // Automatically track page views on route changes
debug: process.env.NEXT_PUBLIC_DOTCMS_ANALYTICS_DEBUG === "true",
queue: {
eventBatchSize: 15, // Send when 15 events are queued
flushInterval: 5000, // Or send every 5 seconds (ms)
},
};
Benefits of this approach:
- ✅ Single source of truth for analytics configuration
- ✅ Easy to import and reuse across components
- ✅ Centralized
Установить SDK Analytics Installer в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadWriteEditBashGrepGlobВложенные файлы
FAQ
Что делает скилл SDK Analytics Installer?
Use this skill when the user asks to install, configure, or set up @dotcms/analytics, sdk-analytics, analytics SDK, add analytics tracking, or mentions installing analytics in Next.js or React projects
Как установить скилл SDK Analytics Installer?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл SDK Analytics Installer запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic