From nodeshub-seo-skills
Step-by-step guide to connect Google Analytics 4 for fetching pageviews, sessions, events, and traffic sources. Activates when user mentions GA4 setup or connection.
How this skill is triggered — by the user, by Claude, or both
Slash command
/nodeshub-seo-skills:connect-ga4This skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
**First action:** Run the banner so the blue logo and skill name appear in the terminal:
First action: Run the banner so the blue logo and skill name appear in the terminal:
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.
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:
ga4-credentials.json into chat.client_email into chat. Read it yourself from local/ga4-credentials.json once the user saves the file there (see Step 4).scripts/fetch-ga4.js themselves.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.
First, check whether the GA4 credentials file exists:
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.)"
local/ga4-credentials.json).Ask: "Have you enabled the Google Analytics Data API? Reply yes when done."
ga4-reader. Click Create and Continue. (No role needed — skip optional steps, then Done.)Ask: "Have you downloaded the JSON key file? Reply yes when done."
local/ in the repo root if it does not exist.local/ga4-credentials.json
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."
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:
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).
Ask: "Have you added the Service Account as a user in GA4? Reply yes when done."
1234567890).When they paste it, update scripts/fetch-ga4.js → CONFIG.propertyId with the value.
Run:
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."
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.
npx claudepluginhub senuto/nodeshub-seo-skills --plugin nodeshub-seo-skillsStep-by-step guide to connect Google Search Console credentials and set up GSC data access for use with fetch-gsc.js. Walks through Google Cloud Console setup and credential file creation.
Guides GA4 property setup, event tracking (automatic, recommended, custom), custom dimensions, BigQuery integration, gtag.js/GTM implementation, reporting, and privacy compliance for web/app analytics.
Adds or repairs Google Analytics 4 on websites with privacy-compliant gtag/GTM setup, GA4 event taxonomy, and exact UI steps for tracking goals and AdSense revenue.