Skip to main content
Glama
ZLeventer

Google Analytics MCP Server

ga4_channel_performance

Retrieve performance metrics by channel group: sessions, users, conversions, and revenue for Organic Search, Paid Search, Email, Direct, Referral, and more. Specify date range and property.

Instructions

Default channel group rollup: sessions/users/conversions/revenue for Organic Search, Paid Search, Email, Direct, Referral, etc.

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

  • The channelPerformance function queries GA4 for channel group rollup data (sessions, users, conversions, revenue) grouped by sessionDefaultChannelGroup.
    export async function channelPerformance(args: z.infer<z.ZodObject<typeof channelPerfSchema>>) {
      const [res] = await getClient().runReport({
        property: getProperty(args.property_id),
        dateRanges: toDateRange(args.start_date, args.end_date),
        dimensions: [{ name: "sessionDefaultChannelGroup" }],
        metrics: [
          { name: "sessions" },
          { name: "totalUsers" },
          { name: "newUsers" },
          { name: "engagementRate" },
          { name: "conversions" },
          { name: "keyEvents" },
          { name: "totalRevenue" },
        ],
        orderBys: [{ metric: { metricName: "sessions" }, desc: true }],
        limit: args.limit as unknown as number,
      });
      return formatReport(res);
    }
  • The channelPerfSchema defines input validation for channel performance: start_date, end_date, property_id, and limit.
    export const channelPerfSchema = { ...dateRange };
  • src/index.ts:100-107 (registration)
    Registration of the 'ga4_channel_performance' tool on the MCP server with its schema and handler binding.
    server.tool(
      "ga4_channel_performance",
      "Default channel group rollup: sessions/users/conversions/revenue for Organic Search, Paid Search, Email, Direct, Referral, etc.",
      channelPerfSchema,
      async (args) => {
        try { return ok(await channelPerformance(args)); } catch (e) { return err(e); }
      }
    );
  • The formatReport helper transforms raw GA4 API responses into structured row objects.
    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 };
    }
Behavior2/5

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

No annotations are provided. The description mentions 'rollup' but fails to disclose behavioral traits such as default grouping definition, permission requirements, read-only nature, or return format. Minimal transparency for a data-retrieval tool.

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?

One sentence, concise and to the point. However, it could be structured with bullet points for clarity, but it's not verbose.

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?

No output schema exists, and the description only lists metrics without explaining the response structure, pagination, or error behavior. Given the lack of annotations and output schema, the description is incomplete for agent usage.

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 description coverage is 100%, so baseline is 3. The description adds no extra meaning beyond the schema's parameter descriptions (start_date, end_date, property_id, limit). It does not elaborate on how these parameters affect the rollup.

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 a default channel group rollup with specific metrics (sessions, users, conversions, revenue) for channels like Organic Search, Paid Search, etc., distinguishing it from sibling tools that focus on specific channels or campaigns.

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

Usage Guidelines2/5

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

No explicit guidance on when to use this tool versus alternatives such as ga4_paid_search_performance or ga4_campaign_performance. The description implies an overview purpose but lacks when-to-use or when-not-to-use advice.

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