Skip to main content
Glama

get_landing_pages

Retrieve landing page analysis from Google Analytics 4 to identify entry points and understand initial user interactions for traffic optimization.

Instructions

ランディングページ(ユーザーが最初にアクセスしたページ)の分析結果を取得します。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
propertyIdNoGA4プロパティID
periodYes集計期間
limitNo取得件数(デフォルト: 10)

Implementation Reference

  • The main handler function that executes the get_landing_pages tool logic by querying GA4 for landing pages report and processing the data.
    export async function getLandingPages( input: GetLandingPagesInput ): Promise<GetLandingPagesOutput> { const propertyId = getPropertyId(input.propertyId); const property = formatPropertyPath(propertyId); const dateRange = periodToDateRange(input.period); const limit = input.limit || 10; const response = await executeReport({ property, dateRanges: [dateRange], dimensions: [{ name: "landingPage" }], metrics: [ { name: "sessions" }, { name: "totalUsers" }, { name: "bounceRate" }, { name: "averageSessionDuration" }, ], orderBys: [{ metric: { metricName: "sessions" }, desc: true }], limit, }); const landingPages: LandingPage[] = []; for (const row of response.rows || []) { const dimensionValues = row.dimensionValues || []; const metricValues = row.metricValues || []; const getValue = (index: number): number => { const value = metricValues[index]?.value; return value ? parseFloat(value) : 0; }; landingPages.push({ pagePath: dimensionValues[0]?.value || "", entrances: Math.round(getValue(0)), users: Math.round(getValue(1)), bounceRate: formatPercentageFromDecimal(getValue(2)), avgSessionDuration: formatDuration(getValue(3)), }); } return { landingPages }; }
  • TypeScript interfaces defining the input schema (GetLandingPagesInput), output structure (GetLandingPagesOutput), and related LandingPage type for the tool.
    // get_landing_pages export interface GetLandingPagesInput extends PropertyId { period: ShortPeriod; limit?: number; } export interface LandingPage { pagePath: string; entrances: number; users: number; bounceRate: string; avgSessionDuration: string; } export interface GetLandingPagesOutput { landingPages: LandingPage[]; }
  • src/server.ts:357-377 (registration)
    MCP tool registration entry defining the tool name, description, and input schema validation.
    { name: "get_landing_pages", description: "ランディングページ(ユーザーが最初にアクセスしたページ)の分析結果を取得します。", inputSchema: { type: "object" as const, properties: { propertyId: { type: "string", description: "GA4プロパティID" }, period: { type: "string", enum: ["7days", "28days", "30days"], description: "集計期間", }, limit: { type: "number", description: "取得件数(デフォルト: 10)", }, }, required: ["period"], }, },
  • src/server.ts:688-693 (registration)
    Dispatch handler in the switch statement that calls the getLandingPages function with parsed arguments.
    case "get_landing_pages": return await getLandingPages({ propertyId: args.propertyId as string | undefined, period: args.period as "7days" | "28days" | "30days", limit: args.limit as number | undefined, });
  • Re-export of the getLandingPages handler from its implementation file for convenient import in server.ts.
    export { getLandingPages } from "./getLandingPages.js";

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/Shin-sibainu/ga4-mcp-server'

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