Skip to main content
Glama
ZLeventer

Google Analytics MCP Server

ga4_campaign_performance

Break down campaign performance by source and medium to see sessions, conversions, and revenue. Optionally filter by channel for targeted analysis.

Instructions

Campaign × source × medium breakdown with sessions/conversions/revenue. Optional channel filter.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateNoStart date: YYYY-MM-DD, NdaysAgo, yesterday, or today28daysAgo
end_dateNoEnd date: YYYY-MM-DD, NdaysAgo, yesterday, or todayyesterday
property_idNoOverride GA4_PROPERTY_ID env var for this call
limitNoMax rows to return
channelNoOptional sessionDefaultChannelGroup filter, e.g. 'Paid Search'

Implementation Reference

  • Campaign performance Zod schema: extends dateRange with optional `channel` filter string.
    export const campaignPerfSchema = {
      ...dateRange,
      channel: z.string().optional().describe("Optional sessionDefaultChannelGroup filter, e.g. 'Paid Search'"),
    };
  • Campaign performance handler function. Queries GA4 with dimensions sessionCampaignName, sessionSource, sessionMedium; metrics sessions, totalUsers, conversions, keyEvents, totalRevenue; optional channel filter; ordered by sessions desc.
    export async function campaignPerformance(args: z.infer<z.ZodObject<typeof campaignPerfSchema>>) {
      const [res] = await getClient().runReport({
        property: getProperty(args.property_id),
        dateRanges: toDateRange(args.start_date, args.end_date),
        dimensions: [
          { name: "sessionCampaignName" },
          { name: "sessionSource" },
          { name: "sessionMedium" },
        ],
        metrics: [
          { name: "sessions" },
          { name: "totalUsers" },
          { name: "conversions" },
          { name: "keyEvents" },
          { name: "totalRevenue" },
        ],
        dimensionFilter: args.channel
          ? { filter: { fieldName: "sessionDefaultChannelGroup", stringFilter: { value: args.channel } } }
          : undefined,
        orderBys: [{ metric: { metricName: "sessions" }, desc: true }],
        limit: args.limit as unknown as number,
      });
      return formatReport(res);
    }
  • src/index.ts:109-116 (registration)
    Registers the `ga4_campaign_performance` tool on the MCP server with its schema and handler.
    server.tool(
      "ga4_campaign_performance",
      "Campaign × source × medium breakdown with sessions/conversions/revenue. Optional channel filter.",
      campaignPerfSchema,
      async (args) => {
        try { return ok(await campaignPerformance(args)); } catch (e) { return err(e); }
      }
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description does not disclose behavioral traits such as read-only nature, rate limits, data freshness, or side effects. The transmission of query parameters implies a read operation, but the agent must infer this.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very concise (one sentence) with no unnecessary words. However, it could be more structured by listing dimensions and metrics separately for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and the tool's complexity (multiple dimensions and metrics), the description is insufficient. It does not explain the output format or how the breakdown is structured, leaving the agent to infer from the tool name.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds minimal value: it mentions 'Optional channel filter', which corresponds to the channel parameter, but does not elaborate on other parameters or their relationships.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly specifies the dimensions (campaign, source, medium) and metrics (sessions, conversions, revenue), with an optional channel filter. This distinguishes it from sibling tools like ga4_channel_performance or ga4_paid_search_performance, which focus on specific breakdowns.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The phrase 'Optional channel filter' hints at usage but does not explicitly state when to prefer this tool over alternatives. No guidance on when to use this vs. other GA4 performance tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ZLeventer/google-analytics-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server