Skip to main content
Glama
ZLeventer

Google Analytics MCP Server

ga4_all_paid_performance

Retrieve paid performance data across all channels (Search, Social, Video, Display, Other) with breakdowns by channel, campaign, source, and medium, including cost and ROAS metrics.

Instructions

Paid: all paid channels (Search + Social + Video + Display + Other) broken down by channel × campaign × source × medium, with cost and ROAS.

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

Implementation Reference

  • src/index.ts:73-80 (registration)
    Registers the 'ga4_all_paid_performance' tool on the MCP server with its description, schema, and handler.
    server.tool(
      "ga4_all_paid_performance",
      "Paid: all paid channels (Search + Social + Video + Display + Other) broken down by channel × campaign × source × medium, with cost and ROAS.",
      allPaidSchema,
      async (args) => {
        try { return ok(await allPaidPerformance(args)); } catch (e) { return err(e); }
      }
    );
  • Schema for all paid channels: accepts start_date, end_date, property_id, and limit (spread from common).
    // All paid channels (Paid Search, Paid Social, Paid Video, Display, Paid Other)
    export const allPaidSchema = { ...common };
  • Executes a GA4 Data API runReport query filtering for all paid channels (sessionDefaultChannelGroup CONTAINS 'Paid'), broken down by channel, campaign, source, and medium, returning sessions, conversions, revenue, cost, and ROAS.
    export async function allPaidPerformance(args: z.infer<z.ZodObject<typeof allPaidSchema>>) {
      const [res] = await getClient().runReport({
        property: getProperty(args.property_id),
        dateRanges: [{ startDate: args.start_date, endDate: args.end_date }],
        dimensions: [
          { name: "sessionDefaultChannelGroup" },
          { name: "sessionCampaignName" },
          { name: "sessionSource" },
          { name: "sessionMedium" },
        ],
        metrics: [
          { name: "sessions" },
          { name: "conversions" },
          { name: "keyEvents" },
          { name: "totalRevenue" },
          { name: "advertiserAdClicks" },
          { name: "advertiserAdCost" },
          { name: "returnOnAdSpend" },
        ],
        dimensionFilter: {
          filter: {
            fieldName: "sessionDefaultChannelGroup",
            stringFilter: { matchType: "CONTAINS", value: "Paid" },
          },
        },
        orderBys: [{ metric: { metricName: "advertiserAdCost" }, desc: true }],
        limit: args.limit as unknown as number,
      });
      return formatReport(res);
    }
  • Shared helper that transforms the GA4 API raw response into a structured { rowCount, rows } format, mapping dimension and metric headers to cell values.
    function formatReport(res: any) {
      const rows = (res.rows ?? []).map((r: any) => {
        const out: Record<string, string | number> = {};
        (res.dimensionHeaders ?? []).forEach((h: any, i: number) => {
          out[h.name] = r.dimensionValues?.[i]?.value ?? "";
        });
        (res.metricHeaders ?? []).forEach((h: any, i: number) => {
          const v = r.metricValues?.[i]?.value ?? "0";
          const n = Number(v);
          out[h.name] = Number.isFinite(n) ? n : v;
        });
        return out;
      });
      return { rowCount: res.rowCount ?? rows.length, rows };
    }
  • src/index.ts:17-24 (registration)
    Imports the allPaidPerformance handler and allPaidSchema from src/tools/paid.ts at the top of the entry point.
    import {
      allPaidPerformance,
      allPaidSchema,
      googleAdsPerformance,
      googleAdsSchema,
      paidSearchPerformance,
      paidSearchSchema,
    } from "./tools/paid.js";
Behavior2/5

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

No annotations provided, and the description does not confirm it is read-only or non-destructive. For a reporting tool, this is a gap; it should at least indicate it only reads data.

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

Conciseness5/5

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

Single sentence, front-loaded with key information, no wasted words.

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

Completeness3/5

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

No output schema; description mentions cost and ROAS and dimensions, but lacks full metric list, pagination behavior, or any mention of row limits. Adequate but not complete.

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?

All 4 parameters are fully described in the input schema (100% coverage). The description adds no additional meaning beyond the schema.

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 states the tool returns paid channel performance broken down by channel, campaign, source, and medium with cost and ROAS. It differentiates from siblings like ga4_paid_search_performance which only covers search.

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 description implies it's for all paid channels but doesn't explicitly state when to use this versus other sibling tools like ga4_channel_performance or ga4_google_ads_performance. Guidance is implicit but not explicit.

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