Analytics

Streamlining Web Page Insights with Natural Language using Gemini CLI, Google Analytics, and MCP

Gists Abstract This report introduces a powerful method for automating Google Analytics tasks using the Gemini CLI and a custom MCP (Model Context Protocol) server built with Google Apps Script. This integration enables streamlined web page analysis through simple natural language commands, simplifying authorization and complex data retrieval workflows. Introduction Accessing and interpreting web analytics data often involves navigating complex interfaces and manual report generation. However, the emergence of natural language interfaces is changing this paradigm.

Retrieving Users, Sessions and PageViews of User Summary Report from Google Analytics using Google Apps Script

Gists This is a sample script for retrieving “Users”, “Sessions” and “PageViews” of User Summary Report from Google Analytics using Google Apps Script. When you use this, please enable Analytics Reporting API at Advanced Google services. Sample script function myFunction() { const viewId = "###"; const startDate = "2020-01-01"; const endDate = "2020-06-01"; const resource = { reportRequests: [ { viewId: viewId, dateRanges: [{ startDate: startDate, endDate: endDate }], metrics: [ { expression: "ga:users" }, { expression: "ga:sessions" }, { expression: "ga:pageviews" }, ], }, ], }; const res = AnalyticsReporting.