dd-instrument-product-analytics
Installation
SKILL.md
Datadog Product Analytics
Product Analytics turns the sessions, page views and clicks that the Datadog RUM Browser SDK collects into funnels, retention, pathways and per-user journeys. It uses the same SDK and the same RUM application as RUM, so there is no second SDK to install.
How it works
- The switch is on the RUM application, not in the code. Product Analytics is enabled when the application has
product_analytics_retention_state: MAX. Without it, Product Analytics stays disabled even when the code is correct. - RUM comes first. Product Analytics reads what the RUM Browser SDK sends, so an app with no RUM init needs RUM set up first.
- Identity comes from
datadogRum.setUser. Without it, no journey is tied to an account. From SDK v6, visitors without a login are still counted anonymously, becausetrackAnonymousUserdefaults to true; v5 has no anonymous id. - Clicks need action collection.
trackUserInteractionsdefaults to true from SDK v6 and to false in v5. SDK v4 and older name the optiontrackInteractions. - Credentials. The application ID and client token are public and already in the RUM setup. Switching the product on through the API needs an API key and an application key, and both are secret.
Set up
- Inspect. If the request or target project is a mobile app (iOS, Android, React Native, Flutter, or Kotlin Multiplatform), stop before any browser search or edit: say that this skill is for the browser product (
@datadog/browser-rum) only, and do not give the Manage Applications enable path. Otherwise, find the browser app; in a monorepo with several, ask which one. Search source and HTML files, skippingnode_modulesand build output, for the RUM setup: aninitcall on thedatadogRumimport from@datadog/browser-rum, including renamed imports and wrapper modules, or a CDNDD_RUM.init. Record the number of inits, the SDK version,trackUserInteractions, thesite(absent meansdatadoghq.com), the application ID, and how users sign in, through an auth library or the app's own session or user state. When the init reads the application ID or the site from environment variables, read only those lines of the env file, for examplegrep -E '^VITE_DD_(RUM_APPLICATION_ID|SITE)=' .env.local, because env files often hold secrets.