Home/News/How to Connect Claude Cowork and Code to GA4 Analytics, Search Console, and Indexing API

How to Connect Claude Cowork and Code to GA4 Analytics, Search Console, and Indexing API

Adam Carter
How to Connect Claude Cowork and Code to GA4 Analytics, Search Console, and Indexing API

If you're using Claude Cowork on Mac (or Claude Code on PC), you can have Claude pull your Google Analytics data, analyze your SEO performance, and even request re-indexing for updated pages — all without leaving your terminal.

This guide gives you the prompts. You give them to Claude. Claude does the work.

What This Toolkit Does

The GA4 Analytics Toolkit connects Claude to three Google APIs:

  • GA4 Analytics — Traffic, pages, events, conversions, real-time data
  • Search Console — Search queries, page rankings, device breakdown, country data
  • Indexing API — Request re-crawling for updated pages, check index status

Every result gets saved to JSON files automatically. Ask Claude for a summary and it creates a readable markdown report.


Getting Started

1. Clone the Repository

Open Claude Cowork (or Claude Code on PC) and give it this prompt:

Prompt: Clone the GA4 Analytics Toolkit from https://github.com/adamkristopher/ga4-api-toolkit to my projects folder

Claude will run the git clone and let you know when it's ready.

2. Set Up Google Cloud

You need a Google Cloud project with the right APIs enabled. Don't worry about the steps — Claude knows them.

Prompt: Walk me through setting up a Google Cloud project and enabling the GA4 Data API, Search Console API, and Indexing API

Claude will guide you through the Google Cloud Console step by step.

3. Create a Service Account

You need a service account to authenticate. Again, let Claude guide you:

Prompt: Help me create a service account in Google Cloud and download the JSON key file

Claude will walk you through IAM & Admin → Service Accounts → Create → Download JSON key.

4. Add Service Account to GA4

The service account needs access to your GA4 property.

Prompt: Guide me through adding the service account email to my GA4 property as a Viewer

5. Add Service Account to Search Console

For SEO and indexing features, the service account needs Search Console access too.

Prompt: Help me add the service account to my Search Console property

6. Configure the Environment

Now set up the credentials in the toolkit:

Prompt: Set up the .env file for the GA4 toolkit with my credentials

Claude will ask for your GA4 Property ID (found in GA4 Admin → Property Settings), your service account email, and the private key from your JSON file.


GA4 Analytics

Once setup is complete, you can start analyzing. Here are the prompts for common tasks:

Get a Site Overview

Prompt: Give me a site overview for the last 30 days

Returns: Page views, traffic sources, user demographics, and top events.

Analyze Traffic Sources

Prompt: Analyze my traffic sources this week

Returns: Breakdown by source/medium, session data, new vs returning users.

See Top Pages

Prompt: What are my top 10 pages by views?

Returns: Top pages with views, sessions, bounce rate, and average session duration.

Check Real-Time Visitors

Prompt: Show me real-time active users

Returns: Current active users, what pages they're on, and live events.

Compare Time Periods

Prompt: Compare this month to last month

Returns: Side-by-side comparison of traffic, users, and engagement.

Analyze User Behavior

Prompt: Analyze user engagement patterns for the last 90 days

Returns: Demographics, events, engagement rate, and session duration over time.

Custom Report

Need something specific? Tell Claude what you want:

Prompt: Run a custom report showing sessions by country and device for the last 7 days

Search Console SEO

The toolkit also pulls your Search Console data. Same approach — just prompt Claude.

See Top Search Queries

Prompt: What are my top search queries?

Returns: Keywords driving traffic, with clicks, impressions, CTR, and position.

Analyze Page SEO Performance

Prompt: Show me SEO performance by page

Returns: Top pages by clicks with impressions, CTR, and average position.

Device Breakdown

Prompt: How does mobile vs desktop search traffic compare?

Returns: Performance split by device type (desktop, mobile, tablet).

Country Performance

Prompt: Which countries drive the most search traffic?

Returns: Traffic breakdown by country with clicks, impressions, and CTR.

Full SEO Overview

Prompt: Give me a full Search Console overview for the last 30 days

Returns: Combined snapshot of queries, pages, devices, and countries.

Keyword Deep Dive

Prompt: Do a keyword analysis for the last 7 days

Returns: Detailed query analysis with device breakdown.


Indexing API

Updated a blog post? Launched a new page? Request re-indexing so Google crawls it faster.

Request Re-Indexing for a URL

Prompt: Request re-indexing for https://yoursite.com/blog/new-post

Submits the URL to Google's Indexing API for re-crawling.

Check if a URL is Indexed

Prompt: Check if https://yoursite.com/about is indexed

Returns: Index status, crawl info, and any issues.

Batch Re-Index Multiple URLs

Prompt: Re-index these URLs: https://yoursite.com/page1, https://yoursite.com/page2, https://yoursite.com/page3

Submits multiple URLs in one batch.

Inspect URL Status

Prompt: Inspect the index status of my homepage

Returns: Detailed inspection including coverage, mobile usability, and rich results.


Combining Data

The real power is combining these tools. Try:

Prompt: Show me my top 10 search queries and compare their Search Console CTR to GA4 page performance

Or:

Prompt: Find pages with high impressions but low clicks, then check if they're properly indexed

Or:

Prompt: Create a weekly SEO report combining GA4 traffic, Search Console queries, and any indexing issues

Claude will pull from multiple APIs and synthesize the results.


Getting Summaries

All results are saved as JSON files in the results/ folder. To get a human-readable report:

Prompt: Create a summary of those results and save it to results/summaries/weekly-report.md

Claude will read the JSON data and write a markdown summary with tables, insights, and recommendations.


Quick Reference

GA4 Analytics Prompts

TaskPrompt
Site overview"Give me a site overview for the last 30 days"
Traffic sources"Analyze my traffic sources this week"
Top pages"What are my top pages by views?"
Real-time data"Show me real-time active users"
Period comparison"Compare this month to last month"
User behavior"Analyze user engagement patterns"

Search Console Prompts

TaskPrompt
Top queries"What are my top search queries?"
Page SEO"Show me SEO performance by page"
Device breakdown"How does mobile vs desktop compare?"
Country data"Which countries drive search traffic?"
Full overview"Give me a Search Console overview"

Indexing Prompts

TaskPrompt
Re-index URL"Request re-indexing for [URL]"
Check index status"Check if [URL] is indexed"
Batch re-index"Re-index these URLs: [URL1], [URL2]"
URL inspection"Inspect the index status of [URL]"

Troubleshooting

If something's not working, Claude can help debug:

Prompt: Test the GA4 connection and tell me if there are any credential issues
Prompt: Check if my Search Console site URL is configured correctly
Prompt: Why am I getting a permission error on the Indexing API?

Claude will check your configuration, test the connection, and tell you what's wrong.


Requirements

  • Node.js 18+
  • A Google Cloud project with APIs enabled
  • Service account credentials
  • GA4 property with service account as Viewer
  • Search Console property with service account added (for SEO features)

Claude Cowork runs on Mac. If you're on PC, use Claude Code instead — same prompts work.