Skip to main content

Overview

The Analysis API processes stored prompts to identify brand mentions, extract metrics, and provide insights into how AI providers reference your brand and competitors.

Endpoints

analyzeMetrics

Analyze prompts for a workspace to extract brand mentions and generate metrics. Type: Mutation (Authorized Workspace) Rate Limit: 10 requests per minute
workspaceId
string
required
ID of the workspace to analyze prompts for
analyzeAll
boolean
default:"true"
Whether to analyze all prompts or only unanalyzed ones
  • true: Re-analyze all prompts in the workspace
  • false: Only analyze prompts that haven’t been analyzed yet
analyzed
number
Number of prompts that were analyzed
mentions
number
Total number of brand mentions found
prompts
array
Array of analyzed prompt results
const result = await trpc.analysis.analyzeMetrics.mutate({
  workspaceId: "ws_abc123",
  analyzeAll: false // Only analyze new prompts
});

When to Use analyzeAll

Incremental Analysis (analyzeAll: false)
  • Use when you want to analyze only newly added prompts
  • More efficient for workspaces with many prompts
  • Recommended for regular/scheduled analysis
Complete Re-analysis (analyzeAll: true)
  • Use when you’ve updated your brand tracking configuration
  • Useful for backfilling analysis after adding new competitors
  • Use when you want to ensure all prompts reflect the latest analysis logic

fetchAnalysis

Retrieve analyzed prompt data and brand mention metrics for the workspace. Type: Query (Authorized Workspace)
workspaceId
string
required
ID of the workspace
prompts
array
Array of analyzed prompts with brand mentions
totalPrompts
number
Total number of prompts analyzed
totalMentions
number
Total number of brand mentions found
brandBreakdown
array
Aggregated statistics per brand
const analysis = await trpc.analysis.fetchAnalysis.query({
  workspaceId: "ws_abc123"
});

Analysis Workflow

A typical workflow for analyzing brand mentions:

1. Store Prompts

First, add prompts to your workspace:
await trpc.prompt.store.mutate({
  workspaceId: "ws_abc123",
  prompts: [
    "What are the best alternatives to Salesforce?",
    "Compare HubSpot vs Salesforce for small teams"
  ]
});

2. Run Analysis

Analyze the prompts to extract brand mentions:
const result = await trpc.analysis.analyzeMetrics.mutate({
  workspaceId: "ws_abc123",
  analyzeAll: false // Only analyze new prompts
});

console.log(`Analyzed ${result.analyzed} prompts, found ${result.mentions} mentions`);

3. Fetch Results

Retrieve the analyzed data:
const analysis = await trpc.analysis.fetchAnalysis.query({
  workspaceId: "ws_abc123"
});

// Access brand breakdown
analysis.brandBreakdown.forEach(brand => {
  console.log(`${brand.brand}: ${brand.mentions} mentions, avg position ${brand.averagePosition}`);
});

Understanding Analysis Results

Brand Mentions

Each mention includes:
  • brand: The name of the brand or company mentioned
  • context: The context in which the brand was mentioned
  • sentiment: Sentiment analysis (positive, neutral, negative)
  • position: Ranking position when mentioned in a list (1 = first mentioned)

Position Tracking

Position indicates where a brand appears in AI responses:
  • Position 1: First brand mentioned (highest visibility)
  • Position 2+: Subsequent mentions
  • Lower average positions indicate better visibility

Sentiment Analysis

Sentiment values:
  • positive: Brand mentioned favorably
  • neutral: Brand mentioned without sentiment
  • negative: Brand mentioned unfavorably

Performance Considerations

Incremental Analysis

For workspaces with many prompts, use incremental analysis:
// Only analyze new prompts since last analysis
const result = await trpc.analysis.analyzeMetrics.mutate({
  workspaceId: "ws_abc123",
  analyzeAll: false
});

Complete Re-analysis

When you need to re-analyze all historical data:
// Re-analyze all prompts (slower but comprehensive)
const result = await trpc.analysis.analyzeMetrics.mutate({
  workspaceId: "ws_abc123",
  analyzeAll: true
});

Prompts API

Store prompts for analysis

Agent API

Automate prompt collection and analysis

Workspace API

Configure workspace settings

Build docs developers (and LLMs) love