Skip to main content
Glama
ruchernchong

mcp-server-google-analytics

by ruchernchong

getPageViews

Retrieve page view metrics from Google Analytics 4 for a specified date range. Analyze website traffic by grouping data with dimensions like page or country to understand visitor behavior patterns.

Instructions

Get page view metrics for a specific date range

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dimensionsNoDimensions to group by (e.g., page, country)
endDateYesEnd date in YYYY-MM-DD format
startDateYesStart date in YYYY-MM-DD format

Implementation Reference

  • Handler implementation for the getPageViews tool. Extracts parameters, validates date range, and fetches analytics data for page views using the screenPageViews metric, grouped by specified dimensions (default: page).
    case "getPageViews": { const { startDate, endDate, dimensions = ["page"], } = args as { startDate: string; endDate: string; dimensions?: string[]; }; validateDateRange(startDate, endDate); return fetchAnalyticsData({ dateRanges: [{ startDate, endDate }], dimensions: dimensions.map((dimension) => ({ name: dimension })), metrics: [{ name: "screenPageViews" }], }); }
  • Schema definition for the getPageViews tool, registered in the listTools response. Includes input schema requiring startDate and endDate, with optional dimensions.
    { name: "getPageViews", description: "Get page view metrics for a specific date range", inputSchema: { type: "object", properties: { startDate: { type: "string", description: "Start date in YYYY-MM-DD format", }, endDate: { type: "string", description: "End date in YYYY-MM-DD format", }, dimensions: { type: "array", items: { type: "string" }, description: "Dimensions to group by (e.g., page, country)", }, }, required: ["startDate", "endDate"], }, },

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/ruchernchong/mcp-server-google-analytics'

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