Skip to main content
Glama
ZLeventer

google-ads-mcp

gads_conversions_by_campaign

Retrieve conversions and conversion value per campaign and conversion action, sorted by conversions descending. Analyze performance across campaigns to identify high-converting actions.

Instructions

Conversions and conversion value broken down by campaign × conversion action. Sorted by conversions desc. Default last 28 days.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateNo28daysAgo
end_dateNoyesterday
customer_idNo
limitNo

Implementation Reference

  • src/index.ts:119-124 (registration)
    Registers the 'gads_conversions_by_campaign' tool with the MCP server, passing the schema and handler function.
    server.tool(
      "gads_conversions_by_campaign",
      "Conversions and conversion value broken down by campaign × conversion action. Sorted by conversions desc. Default last 28 days.",
      conversionsByCampaignSchema,
      async (args) => { try { return ok(await conversionsByCampaign(args)); } catch (e) { return err(e); } }
    );
  • Defines the input schema for conversionsByCampaign: start_date, end_date, customer_id, and limit with defaults.
    export const conversionsByCampaignSchema = {
      start_date: z.string().default(DEFAULT_START),
      end_date: z.string().default(DEFAULT_END),
      customer_id: z.string().optional(),
      limit: z.number().int().positive().max(10000).default(100),
    };
  • The async handler that executes a GAQL query against Google Ads API, returning conversion metrics (conversions, conversion value, cost per conversion, value per conversion) grouped by campaign and conversion action, sorted by conversions descending.
    export async function conversionsByCampaign(args: z.infer<z.ZodObject<typeof conversionsByCampaignSchema>>) {
      const customer = getCustomer(args.customer_id);
      const start = resolveDate(args.start_date);
      const end = resolveDate(args.end_date);
      const rows = await customer.query(`
        SELECT
          campaign.id,
          campaign.name,
          segments.conversion_action_name,
          metrics.conversions,
          metrics.conversions_value,
          metrics.cost_per_conversion,
          metrics.value_per_conversion
        FROM campaign
        WHERE segments.date BETWEEN '${start}' AND '${end}'
          AND metrics.conversions > 0
        ORDER BY metrics.conversions DESC
        LIMIT ${args.limit}
      `);
      return { rowCount: rows.length, rows };
    }
  • getCustomer helper used by the handler to obtain an authenticated Google Ads Customer instance.
    export function getCustomer(override?: string): Customer {
      const refresh_token = process.env.GOOGLE_ADS_REFRESH_TOKEN;
      if (!refresh_token) throw new GoogleAdsError("GOOGLE_ADS_REFRESH_TOKEN is not set");
      const customer_id = (override ?? process.env.GOOGLE_ADS_CUSTOMER_ID ?? "").replace(/-/g, "");
      if (!customer_id) throw new GoogleAdsError("GOOGLE_ADS_CUSTOMER_ID is not set and no customer_id was passed");
      const login_customer_id = process.env.GOOGLE_ADS_LOGIN_CUSTOMER_ID?.replace(/-/g, "") || undefined;
      return getApi().Customer({ customer_id, login_customer_id, refresh_token });
    }
  • Default date constants (DEFAULT_START, DEFAULT_END) and resolveDate helper used to parse date arguments.
    export const DEFAULT_START = "28daysAgo";
    export const DEFAULT_END = "yesterday";
    
    export function resolveDate(d: string): string {
      if (/^\d{4}-\d{2}-\d{2}$/.test(d)) return d;
      if (d === "today") return toISO(new Date());
      if (d === "yesterday") return toISO(offsetDays(new Date(), -1));
      const m = d.match(/^(\d+)daysAgo$/);
      if (m) return toISO(offsetDays(new Date(), -parseInt(m[1], 10)));
      throw new GoogleAdsError(`Unrecognized date: ${d}. Use YYYY-MM-DD, today, yesterday, or NdaysAgo.`);
    }
Behavior3/5

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

With no annotations, the description carries the full burden. It discloses default time range and sorting order, but does not state that it is a read-only operation, auth requirements, or potential data latency. The behavior is implicitly safe but not fully transparent.

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, using a single sentence plus additional notes. It is front-loaded with the purpose. However, it could be slightly more structured by separating parameter info.

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 the complexity of 4 parameters and no output schema, the description is incomplete. It lacks details on return format, parameter specifications, and usage context, which are needed for correct invocation.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must explain parameters. It only hints at start_date/end_date defaults via 'Default last 28 days', but does not describe customer_id, limit, or the meaning of the fields. This leaves significant gaps for the agent.

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 retrieves conversions and conversion value broken down by campaign and conversion action, with sorting by conversions descending. This distinguishes it from sibling tools like gads_campaign_performance or gads_keyword_performance, which do not include the conversion action breakdown.

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 does not explicitly state when to use this tool versus alternatives. It implies its use case by specifying the breakdown, but lacks guidance on when not to use it or how it differs from other performance reports.

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-ads-mcp'

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