Skip to main content
Glama
ZLeventer

Google Analytics MCP Server

ga4_google_ads_performance

Retrieve Google Ads campaign, ad group, and keyword performance metrics from GA4, including impressions, clicks, cost, CPC, conversions, and ROAS. Requires linked Google Ads and GA4 account.

Instructions

Paid: Google Ads campaign × ad group × keyword performance (impressions, clicks, cost, CPC, conversions, ROAS). Requires Google Ads ↔ GA4 link.

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 handler function that executes GA4 Google Ads performance report logic. Calls runReport with Google Ads dimensions (campaign, ad group, keyword) and metrics (impressions, clicks, cost, CPC, sessions, key events, revenue, ROAS). No dimension filter (applies to all linked Google Ads data).
    export async function googleAdsPerformance(args: z.infer<z.ZodObject<typeof googleAdsSchema>>) {
      const [res] = await getClient().runReport({
        property: getProperty(args.property_id),
        dateRanges: [{ startDate: args.start_date, endDate: args.end_date }],
        dimensions: [
          { name: "googleAdsCampaignName" },
          { name: "googleAdsAdGroupName" },
          { name: "googleAdsKeyword" },
        ],
        metrics: [
          { name: "advertiserAdImpressions" },
          { name: "advertiserAdClicks" },
          { name: "advertiserAdCost" },
          { name: "advertiserAdCostPerClick" },
          { name: "sessions" },
          { name: "keyEvents" },
          { name: "totalRevenue" },
          { name: "returnOnAdSpend" },
        ],
        orderBys: [{ metric: { metricName: "advertiserAdCost" }, desc: true }],
        limit: args.limit as unknown as number,
      });
      return formatReport(res);
    }
  • Schema definition for googleAds tool. Extends common schema (start_date, end_date, property_id, limit) with no additional fields.
    export const googleAdsSchema = { ...common };
  • src/index.ts:82-89 (registration)
    Tool registration via server.tool() with name 'ga4_google_ads_performance', description, schema, and handler.
    server.tool(
      "ga4_google_ads_performance",
      "Paid: Google Ads campaign × ad group × keyword performance (impressions, clicks, cost, CPC, conversions, ROAS). Requires Google Ads ↔ GA4 link.",
      googleAdsSchema,
      async (args) => {
        try { return ok(await googleAdsPerformance(args)); } catch (e) { return err(e); }
      }
    );
  • Formatting helper used by googleAdsPerformance to transform the GA4 API response into a clean row-based structure with typed metric 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 };
    }
  • Common schema fields shared by googleAdsSchema (start_date, end_date, property_id, limit).
    const common = {
      start_date: z.string().default(DEFAULT_START).describe("Start date: YYYY-MM-DD, NdaysAgo, yesterday, or today"),
      end_date: z.string().default(DEFAULT_END).describe("End date: YYYY-MM-DD, NdaysAgo, yesterday, or today"),
      property_id: z.string().optional().describe("Override GA4_PROPERTY_ID env var for this call"),
      limit: z.number().int().positive().max(10000).default(50).describe("Max rows to return"),
    };
Behavior2/5

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

No annotations provided, so description should compensate. It discloses the prerequisite (GA4 link) but does not state that the tool is read-only, has rate limits, or other behavioral traits. The term 'performance' implies non-destructive, but not explicit.

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 plus a requirement line. Front-loaded with key identifier 'Paid: Google Ads...' and metric list. No superfluous words; every part adds value.

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?

Covers what data is returned and the prerequisite, but does not mention default sorting, pagination behavior, or what happens when limit is reached. Given no output schema, description could be more 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?

Schema coverage is 100%, so baseline is 3. Description does not add additional parameter meaning beyond what is already in the schema. Parameters are adequately described in schema, but no extra context provided.

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?

Description clearly states it returns paid Google Ads performance data at campaign × ad group × keyword granularity, with specific metrics listed. Distinguishes from siblings like ga4_campaign_performance and ga4_paid_search_performance by specifying 'Google Ads' and the precise dimensions.

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?

Mentions prerequisite 'Requires Google Ads ↔ GA4 link' but does not explicitly guide when to use this over siblings such as ga4_all_paid_performance or ga4_paid_search_performance. Usage context is implied but not directly addressed.

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