RADZOR
ComponentsRecipesDocsContributeGitHub
Get Started
RADZOR

The universal component registry for LLM-driven development. Empowering developers to build better apps, faster.

Product
  • Components
  • Standard
Resources
  • Documentation
  • API Reference
  • AI Agent Integration
  • Pipeline Guide
  • MCP Server
Community
  • GitHub
  • X / Twitter
  • Discord

© 2026 Radzor Registry. All rights reserved.

Cookbook
Intermediateanalyticsdataproduct

Analytics PipelineAI Workflow

Track user events, segment users by behavior, run A/B tests with variant assignment, analyze conversion funnels, and export reports to CSV. A complete product analytics stack.

Prerequisites

Environment variables

ANALYTICS_ENDPOINT

Install

$npx radzor@latest recipe add analytics-dashboard

AI Prompt

“Run `npx radzor@latest add event-tracker user-segmentation ab-test funnel-report csv-export` to install 5 Radzor components. Then read components/radzor/event-tracker/radzor.manifest.json, components/radzor/user-segmentation/radzor.manifest.json, components/radzor/ab-test/radzor.manifest.json, components/radzor/funnel-report/radzor.manifest.json, components/radzor/csv-export/radzor.manifest.json and each component's llm/integration.md. Wire them together to track user events, segment users by behavior, run A/B tests with variant assignment, analyze conversion funnels, and export reports to CSV. A complete product analytics stack. Use the manifest's inputs (check envVar for required environment variables), outputs (check fields for object shapes), composability (check mapField for field extraction), and actions — don't invent custom interfaces.”

Paste this into Claude Code, Cursor, Windsurf, or any AI coding agent.

Pipeline

EventTracker

Tracks user events and page views

→
↓
events

UserSegmentation

Segments users by attributes

→
↓
segment

ABTest

Assigns variants and tracks conversions

→
↓
variant

FunnelReporter

Analyzes conversion funnels

→
↓
report

CsvExport

Exports results to CSV

Scaffolded Code

analytics-dashboard-recipe.ts
// npx radzor@latest add event-tracker user-segmentation ab-test funnel-report csv-export
import { EventTracker }     from "./components/radzor/event-tracker"
import { UserSegmentation } from "./components/radzor/user-segmentation"
import { ABTest }           from "./components/radzor/ab-test"
import { FunnelReporter }   from "./components/radzor/funnel-report"
import { CsvExport }        from "./components/radzor/csv-export"

const tracker = new EventTracker({
  endpoint: process.env.ANALYTICS_ENDPOINT!,
  batchSize: 50,
  flushIntervalMs: 10_000,
})

const segments = new UserSegmentation({})
segments.defineSegment("power-users", "Users with 10+ sessions", [
  { field: "sessionCount", operator: "gte", value: 10 },
])
segments.defineSegment("new-users", "Users signed up in last 7 days", [
  { field: "daysSinceSignup", operator: "lte", value: 7 },
])

const ab = new ABTest({ salt: "my-secret-salt" })
ab.createExperiment("new-checkout", ["control", "variant-a", "variant-b"])

const funnel = new FunnelReporter({ funnelId: "checkout", steps: ["view_product", "add_to_cart", "begin_checkout", "purchase"] })

const csv = new CsvExport({ delimiter: "," })

// --- Usage in your app ---
async function trackUserAction(userId: string, action: string, attrs: Record<string, unknown>) {
  // Track the event
  tracker.track(action, { userId, ...attrs })

  // Evaluate user segment
  const { segments: userSegments } = segments.evaluate(userId, attrs)

  // Get A/B test variant
  const { variant } = ab.getVariant("new-checkout", userId)

  // Record funnel step
  if (["view_product", "add_to_cart", "begin_checkout", "purchase"].includes(action)) {
    funnel.recordStep(userId, action)

    // Track conversion for A/B test on purchase
    if (action === "purchase") {
      ab.trackConversion("new-checkout", userId, (attrs.amount as number) ?? 0)
    }
  }

  return { userSegments, variant }
}

// --- Generate reports ---
function exportReports() {
  const funnelData = funnel.getReport()
  const abResults = ab.getResults("new-checkout")

  // Export funnel report
  const funnelCsv = csv.generate(funnelData.steps.map(s => ({
    step: s.name,
    users: s.count,
    conversionRate: s.conversionRate,
    dropoff: s.dropoff,
  })))

  // Export A/B test results
  const abCsv = csv.generate(Object.entries(abResults.variants).map(([name, data]) => ({
    variant: name,
    participants: data.participants,
    conversions: data.conversions,
    conversionRate: data.conversionRate,
    revenue: data.totalValue,
  })))

  return { funnelCsv, abCsv }
}

Components used

EventTrackerTracks user events and page views
View
UserSegmentationSegments users by attributes
View
ABTestAssigns variants and tracks conversions
View
FunnelReporterAnalyzes conversion funnels
View
CsvExportExports results to CSV
View

LLM tip

Pass all 5 radzor.manifest.json files to your agent at once. It will read the outputs of each step and match them against the inputs of the next — wiring the full pipeline without any extra instructions.

event-tracker/manifest.jsonuser-segmentation/manifest.jsonab-test/manifest.jsonfunnel-report/manifest.jsoncsv-export/manifest.json