Connect Ga4 logo

Connect Ga4

Organization
Senuto
connect-ga4

Step-by-step guide to connect Google Analytics 4 so you can use fetch-ga4.js and GA4 data (pageviews, sessions, events, traffic sources). Use when user says "connect GA4," "set up Google Analytics," "GA4 setup," "connect Analytics," or "how to connect to GA4." No API cost — setup only.

Overview

PublisherSenuto
Repositorynodeshub-seo-skills
Skill nameconnect-ga4
Stars
41
Forks
7
Bundled files
1
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by Senuto on GitHub. Read the source before you install it.

Installation

Install the Connect Ga4 AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/Senuto/nodeshub-seo-skills/tree/main/.claude/skills/connect-ga4
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Senuto/nodeshub-seo-skills.git /tmp/nodeshub-seo-skills
mkdir -p .claude/skills
cp -r /tmp/nodeshub-seo-skills/.claude/skills/connect-ga4 .claude/skills/connect-ga4
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Connect Ga4 in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Connect Ga4 on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Connect Ga4 is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Connect with GA4

First action: Run the banner so the blue logo and skill name appear in the terminal:

bash
python3 -c "import sys; sys.path.insert(0,'.claude/skills/nod-nodeshub-api/scripts'); from banner import print_banner; print_banner('Connect GA4')"

Then walk the user through connecting Google Analytics 4 so they can run npm run fetch-ga4 and use analytics data. Do it step by step, asking for confirmation before continuing.

⛔ CRITICAL SECURITY RULE — NEVER ASK THE USER TO PASTE CREDENTIALS INTO CHAT

Anything the user types into the chat leaves their machine — it's sent to the LLM provider, written to local session logs (~/.claude/projects/<slug>/*.jsonl) in plain text, and may appear in telemetry, backups, or IDE sync. This applies to the contents of the JSON key file (the private key inside it is a secret). It also applies to the Service Account client_email — while that email alone is not critical, combined with the private key in logs/backups it lets the holder call Google APIs under the user's project.

You MUST:

  • Never ask the user to paste the contents of ga4-credentials.json into chat.
  • Never ask the user to paste the client_email into chat. Read it yourself from local/ga4-credentials.json once the user saves the file there (see Step 4).
  • The GA4 Property ID is a non-sensitive numeric ID and may be pasted if the user wants — but it's also fine to write it directly to scripts/fetch-ga4.js themselves.
  • If the user pastes the key file contents anyway, stop, refuse to use it, tell them to revoke that Service Account key in Google Cloud Console (IAM & Admin → Service Accounts → Keys → delete the leaked key) and create a new one before continuing.

Privacy: The key file local/ga4-credentials.json is stored in a gitignored path. Tell the user: do not make this repo public if it contains the file — keep the repo private or ensure sensitive files stay out of version control.


Step 0: Check if GA4 is already connected

First, check whether the GA4 credentials file exists:

  • If local/ga4-credentials.json exists: GA4 is already set up for this repo. Ask the user: "GA4 is already connected (credentials file present). Do you want to change the current integration (replace with a different Service Account) or add another GA4 property/credentials? (Reply: change / add another / no, I'm done.)"
    • If they say change → continue with Step 1 (they will create a new Service Account and replace local/ga4-credentials.json).
    • If they say add another → explain that the current script uses one credentials file; adding another property usually means using the same Service Account and updating the property ID, or they can replace the file to point at a different project. Then continue from Step 4 or Step 5 as needed.
    • If they say no, I'm done → confirm and stop.
  • If the file does not exist: no integration yet → continue with Step 1.

Step 1: Google Cloud project and API

  1. Ask the user to open Google Cloud Console (not Analytics).
  2. Tell them: create or select a project (top bar).
  3. In the left menu: APIs & Services → Library. Search for Google Analytics Data API → open it → Enable.

Ask: "Have you enabled the Google Analytics Data API? Reply yes when done."


Step 2: Service Account

  1. In Google Cloud Console: APIs & Services → Credentials.
  2. Create Credentials → Service Account.
  3. Service account name: e.g. ga4-reader. Click Create and Continue. (No role needed — skip optional steps, then Done.)
  4. Open the new Service Account (click its name). Go to the Keys tab.
  5. Add Key → Create new key → JSON → Create. A JSON file will download.

Ask: "Have you downloaded the JSON key file? Reply yes when done."


Step 3: Save the key file in the repo

  1. Tell the user to create the folder local/ in the repo root if it does not exist.
  2. Save the downloaded JSON file as:
    local/ga4-credentials.json
  3. Remind them: local/ is in .gitignore, so the file will not be committed. Do not make the repo public — it now contains a private credentials file (even though it is gitignored, keeping the repo private is safer).

Ask: "Have you saved the file as local/ga4-credentials.json? Reply yes when done."


Step 4: Read the Service Account email from the file

Once the user confirms the key file is at local/ga4-credentials.json, read the client_email yourself — do not ask the user to paste it:

bash
python3 -c "import json; print(json.load(open('local/ga4-credentials.json'))['client_email'])"

Show the email to the user and tell them they will paste it into Google Analytics in the next step (that's a Google UI field, not this chat).


Step 5: Add the Service Account in Google Analytics

  1. Ask the user to open Google Analytics (analytics.google.com, not Cloud Console).
  2. Select the property (GA4 property) they want to connect.
  3. Open Admin (gear icon, bottom left) → Property access management.
  4. Click the + button → Add users.
  5. They should paste the Service Account email (the one from Step 4) into the email field.
  6. Role: Viewer (sufficient for read-only data access).
  7. Click Add.

Ask: "Have you added the Service Account as a user in GA4? Reply yes when done."


Step 6: Get the GA4 Property ID

  1. Ask the user to stay in Google Analytics.
  2. Open Admin → Property settings → Property details.
  3. Copy the Property ID (a numeric ID, e.g. 1234567890).
  4. Ask them to paste the Property ID here.

When they paste it, update scripts/fetch-ga4.js → CONFIG.propertyId with the value.


Step 7: Verify

Run:

bash
npm install
npm run fetch-ga4

If they use a different property or paths, point them to edit scripts/fetch-ga4.js (CONFIG.propertyId, CONFIG.outputDir). Data is written to knowledge/metrics/analytics/ by default.

Ask: "Did npm run fetch-ga4 run without errors? If you see any error, paste it here."


Summary

  • Google Cloud Console (console.cloud.google.com): enable Google Analytics Data API, create Service Account, download JSON key.
  • Google Analytics (analytics.google.com): add the Service Account email as a Viewer, note the Property ID.
  • Key file in repo: local/ga4-credentials.json (gitignored). Keep the repo private — do not publish it publicly when it contains credentials.

For more detail (e.g. metrics, dimensions, filters), see the scripts/fetch-ga4.js script or the Google Analytics Data API docs.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Connect Ga4 AI skill do?

Step-by-step guide to connect Google Analytics 4 so you can use fetch-ga4.js and GA4 data (pageviews, sessions, events, traffic sources). Use when user says "connect GA4," "set up Google Analytics," "GA4 setup," "connect Analytics," or "how to connect to GA4." No API cost — setup only.

Why use Connect Ga4 on TypingMind?

Because you install it once and use it with any model. Connect Ga4 is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Connect Ga4 in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Senuto/nodeshub-seo-skills/tree/main/.claude/skills/connect-ga4. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Connect Ga4?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Connect Ga4?

As many as you like. As long as a model supports skills, you can use Connect Ga4 with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Connect Ga4 AI skill free?

It is published on GitHub by Senuto. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇