ga4-gtag-implementation

Implement GA4 tracking with gtag.js across HTML, JS, React, Vue, and Angular codebases.

77|9|Updated Oct 10, 2025
One-click install
npx skills add https://github.com/henkisdabro/claudecode-marketplace --skill ga4-gtag-implementation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ga4-gtag-implementation
Source: https://github.com/henkisdabro/claudecode-marketplace/tree/main/ga-suite/skills/ga4-gtag-implementation
Command: npx skills add https://github.com/henkisdabro/claudecode-marketplace --skill ga4-gtag-implementation

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and assets (resource) components.

What problem does it solve?

This Skill guides implementing Google Analytics 4 directly with gtag.js (no GTM), including event tracking, user properties, and SPA considerations.

Core Features & Use Cases

  • gtag.js Installation: Full snippet placement and configuration.
  • gtag('event') & gtag('set'): Standard event tracking and user property management.
  • SPA & Debugging: Manual page_view handling for single-page apps and verification tips.

Quick Start

Install gtag.js on your site, set a user_id on login with gtag('set'), and send a purchase event with an items array.

Frequently Asked Questions about ga4-gtag-implementation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement GA4 tracking directly with gtag.js without Google Tag Manager?

Direct gtag.js integration bypasses GTM by embedding the GA4 measurement ID and tracking code directly into your website or application files. Place the gtag.js snippet in your HTML head, configure your measurement ID, and call gtag('config') to initialize tracking—this approach gives you full control over event firing and data layer interactions without a third-party tag management dependency.

Can I use gtag.js tracking with single-page applications and React/Vue/Angular frameworks?

Yes, gtag.js works across React, Vue, Angular, Next.js, and vanilla JavaScript SPAs. For SPAs, manually trigger gtag('event', 'page_view') on route changes since gtag.js doesn't detect client-side navigation automatically. Each framework integration follows the same core gtag API—config, event, and set commands—adapted to your framework's lifecycle or routing layer.

What's the difference between gtag('event'), gtag('set'), and gtag('config') commands?

gtag('config') initializes GA4 with your measurement ID and default parameters. gtag('event') sends discrete user interactions—purchases, clicks, form submissions—with optional parameters like value and items array. gtag('set') stores persistent user properties like user_id that persist across sessions without firing an event, typically called on login or user identification.

How do I track ecommerce events like purchases with gtag.js?

Send purchase events by calling gtag('event', 'purchase', {transaction_id, value, currency, items: [{item_id, item_name, price, quantity}]}). The items array structure matches GA4's schema. This populates your ecommerce reports with revenue, product performance, and conversion data directly from your checkout or confirmation page.

Do I need to manage the window.dataLayer object when using direct gtag.js?

gtag.js manages window.dataLayer internally, but you can manually push custom data to dataLayer if needed for advanced use cases or third-party integrations. Direct gtag API calls (gtag('event'), gtag('set')) are the primary method; dataLayer is an optional escape hatch for complex tracking scenarios or legacy compatibility.

How do I verify that GA4 gtag.js tracking is working on my website?

Use the Google Analytics Debugger browser extension to see real-time events firing in your browser console, or check the Realtime report in GA4 within seconds of triggering an event. Inspect network requests for gtag collect calls, and validate that your measurement ID matches your GA4 property. These steps confirm gtag.js initialization and event transmission.