agentleFS
omar16100omar16100/skills/setup-google-analytics/SKILL.md

setup-google-analytics

Skill0 starsChanged 10 months agoMITView on GitHub

Set up Google Analytics 4 for a website using Playwright browser automation. Creates GA4 property, gets measurement ID, and adds tracking code to HTML.

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. About 0 are common, 10 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If sign-in page appears, inform user to log in via Playwright browser window

    line 33
  2. Distinctive:

    Wait for user confirmation before proceeding

    line 34
  3. Distinctive:

    Check "Understand web and/or app traffic" checkbox (or most relevant option)

    line 64
  4. Distinctive:

    After stream creation, a dialog shows the Google tag code

    line 78
  5. Very specific:

    Search for index.html in project: Glob("/index.html")

    line 86
  6. Distinctive:

    Read the HTML file

    line 87
  7. Very specific:

    Add GA4 tracking code immediately after <head> tag:

    line 88
  8. Distinctive:

    If the website has JavaScript files with button click handlers:

    line 105
  9. Very specific:

    Search for existing analytics placeholders: Grep("analytics", path=".")

    line 107
  10. Distinctive:

    Add gtag event calls for important actions:

    line 108
  11. Distinctive:

    Property limit reached: Check account limits, may need different account

    line 123
  12. Very specific:

    Always use browser_snapshot before interacting to see current state

    line 129
  13. Distinctive:

    Use element refs from snapshot (like "e123", "f10e5") for accurate targeting

    line 130
  14. Distinctive:

    Wait for page transitions if needed

    line 133

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Google Analytics 4 Setup

Automate GA4 setup for any website via Playwright browser automation.

Prerequisites

  • Playwright MCP server must be running
  • Google account with Analytics access (user must be logged in via Playwright browser)
  • Website codebase accessible for adding tracking code

Required Information

Collect from user if not provided:

  1. Website URL (e.g., example.com) - use $ARGUMENTS if provided
  2. Property Name (defaults to domain name)
  3. Industry Category (Computers & Electronics, Business, etc.)
  4. Business Size (Small/Medium/Large/Very Large)

Setup Workflow

Step 1: Check Login Status

  1. Navigate to https://analytics.google.com
  2. Take snapshot to verify login
  3. If sign-in page appears, inform user to log in via Playwright browser window
  4. Wait for user confirmation before proceeding

Step 2: Navigate to Admin

  1. Once logged in, click "Admin" in left sidebar
  2. Take snapshot to confirm Admin page loaded

Step 3: Create New Property

  1. Click "Create" button in Admin
  2. Select "Property" from dropdown menu
  3. Take snapshot to see property creation form

Step 4: Property Details

  1. Enter property name in "Property name" textbox
  2. Select timezone if needed (defaults to US/Los Angeles)
  3. Select currency if needed (defaults to USD)
  4. Click "Next" button

Step 5: Business Details

  1. Click industry category dropdown
  2. Select appropriate category (e.g., "Computers & Electronics")
  3. Select business size radio button (typically "Small - 1 to 10 employees")
  4. Click "Next" button

Step 6: Business Objectives

  1. Take snapshot to see objectives
  2. Check "Understand web and/or app traffic" checkbox (or most relevant option)
  3. Click "Create a property" button

Step 7: Set Up Web Data Stream

  1. On "Data collection" page, click "Web" platform button
  2. Dialog opens for web stream setup
  3. Enter website URL in "Website URL" textbox (without https://)
  4. Enter stream name in "Stream name" textbox (e.g., "Website Name Website")
  5. Enhanced measurement is enabled by default (leave on)
  6. Click "Create & continue" button

Step 8: Get Measurement ID

  1. After stream creation, a dialog shows the Google tag code
  2. CRITICAL: Extract the measurement ID (format: G-XXXXXXXXXX)
  3. The ID appears in the script snippet and in stream details
  4. Take screenshot for reference
  5. Close the tag instructions dialog

Step 9: Add Tracking Code to Website

  1. Search for index.html in project: Glob("**/index.html")
  2. Read the HTML file
  3. Add GA4 tracking code immediately after <head> tag:
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-XXXXXXXXXX');
</script>

Replace G-XXXXXXXXXX with actual measurement ID.

Step 10: Add Event Tracking (Optional)

If the website has JavaScript files with button click handlers:

  1. Search for existing analytics placeholders: Grep("analytics", path=".")
  2. Add gtag event calls for important actions:
// Example: Track button clicks
if (typeof gtag !== 'undefined') {
    gtag('event', 'button_click', {
        'event_category': 'engagement',
        'event_label': buttonText
    });
}

Error Handling

  • Not logged in: Inform user to log in via Playwright browser, then resume
  • Property limit reached: Check account limits, may need different account
  • Element not found: Take snapshot to see current page state and adapt
  • Session timeout: Restart from Step 1

Tips for Playwright Navigation

  • Always use browser_snapshot before interacting to see current state
  • Use element refs from snapshot (like "e123", "f10e5") for accurate targeting
  • For dropdowns: click to open, then click the option
  • For date pickers: select year first, then month, then day
  • Wait for page transitions if needed

Output

On successful setup, report:

Google Analytics Setup Complete!

Property: [Property Name]
Measurement ID: G-XXXXXXXXXX
Website: https://[domain]
Stream: [Stream Name]

Tracking code added to: [file path]

Enhanced measurement enabled:
- Page views
- Scrolls
- Outbound clicks
- Site search
- Video engagement
- File downloads

Note: Data collection may take up to 48 hours to start appearing in reports.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.