Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Sets up, audits, and improves analytics tracking with GA4, GTM, Mixpanel, Segment, and UTM parameters.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/ga4-implementation.md
1# GA4 Implementation Reference23Detailed implementation guide for Google Analytics 4.45## Contents6- Configuration (data streams, enhanced measurement events, recommended events)7- Custom Events (gtag.js implementation, Google Tag Manager)8- Conversions Setup (creating conversions, conversion values)9- Custom Dimensions and Metrics (when to use, setup steps, examples)10- Audiences (creating audiences, audience examples)11- Debugging (DebugView, real-time reports, common issues)12- Data Quality (filters, cross-domain tracking, session settings)13- Integration with Google Ads (linking, audience export)1415## Configuration1617### Data Streams1819- One stream per platform (web, iOS, Android)20- Enable enhanced measurement for automatic tracking21- Configure data retention (2 months default, 14 months max)22- Enable Google Signals (for cross-device, if consented)2324### Enhanced Measurement Events (Automatic)2526| Event | Description | Configuration |27|-------|-------------|---------------|28| page_view | Page loads | Automatic |29| scroll | 90% scroll depth | Toggle on/off |30| outbound_click | Click to external domain | Automatic |31| site_search | Search query used | Configure parameter |32| video_engagement | YouTube video plays | Toggle on/off |33| file_download | PDF, docs, etc. | Configurable extensions |3435### Recommended Events3637Use Google's predefined events when possible for enhanced reporting:3839**All properties:**40- login, sign_up41- share42- search4344**E-commerce:**45- view_item, view_item_list46- add_to_cart, remove_from_cart47- begin_checkout48- add_payment_info49- purchase, refund5051**Games:**52- level_up, unlock_achievement53- post_score, spend_virtual_currency5455Reference: https://support.google.com/analytics/answer/92677355657---5859## Custom Events6061### gtag.js Implementation6263```javascript64// Basic event65gtag('event', 'signup_completed', {66'method': 'email',67'plan': 'free'68});6970// Event with value71gtag('event', 'purchase', {72'transaction_id': 'T12345',73'value': 99.99,74'currency': 'USD',75'items': [{76'item_id': 'SKU123',77'item_name': 'Product Name',78'price': 99.9979}]80});8182// User properties83gtag('set', 'user_properties', {84'user_type': 'premium',85'plan_name': 'pro'86});8788// User ID (for logged-in users)89gtag('config', 'GA_MEASUREMENT_ID', {90'user_id': 'USER_ID'91});92```9394### Google Tag Manager (dataLayer)9596```javascript97// Custom event98dataLayer.push({99'event': 'signup_completed',100'method': 'email',101'plan': 'free'102});103104// Set user properties105dataLayer.push({106'user_id': '12345',107'user_type': 'premium'108});109110// E-commerce purchase111dataLayer.push({112'event': 'purchase',113'ecommerce': {114'transaction_id': 'T12345',115'value': 99.99,116'currency': 'USD',117'items': [{118'item_id': 'SKU123',119'item_name': 'Product Name',120'price': 99.99,121'quantity': 1122}]123}124});125126// Clear ecommerce before sending (best practice)127dataLayer.push({ ecommerce: null });128dataLayer.push({129'event': 'view_item',130'ecommerce': {131// ...132}133});134```135136---137138## Conversions Setup139140### Creating Conversions1411421. **Collect the event** - Ensure event is firing in GA41432. **Mark as conversion** - Admin > Events > Mark as conversion1443. **Set counting method**:145- Once per session (leads, signups)146- Every event (purchases)1474. **Import to Google Ads** - For conversion-optimized bidding148149### Conversion Values150151```javascript152// Event with conversion value153gtag('event', 'purchase', {154'value': 99.99,155'currency': 'USD'156});157```158159Or set default value in GA4 Admin when marking conversion.160161---162163## Custom Dimensions and Metrics164165### When to Use166167**Custom dimensions:**168- Properties you want to segment/filter by169- User attributes (plan type, industry)170- Content attributes (author, category)171172**Custom metrics:**173- Numeric values to aggregate174- Scores, counts, durations175176### Setup Steps1771781. Admin > Data display > Custom definitions1792. Create dimension or metric1803. Choose scope:181- **Event**: Per event (content_type)182- **User**: Per user (account_type)183- **Item**: Per product (product_category)1844. Enter parameter name (must match event parameter)185186### Examples187188| Dimension | Scope | Parameter | Description |189|-----------|-------|-----------|-------------|190| User Type | User | user_type | Free, trial, paid |191| Content Author | Event | author | Blog post author |192| Product Category | Item | item_category | E-commerce category |193194---195196## Audiences197198### Creating Audiences199200Admin > Data display > Audiences201202**Use cases:**203- Remarketing audiences (export to Ads)204- Segment analysis205- Trigger-based events206207### Audience Examples208209**High-intent visitors:**210- Viewed pricing page211- Did not convert212- In last 7 days213214**Engaged users:**215- 3+ sessions216- Or 5+ minutes total engagement217218**Purchasers:**219- Purchase event220- For exclusion or lookalike221222---223224## Debugging225226### DebugView227228Enable with:229- URL parameter: `?debug_mode=true`230- Chrome extension: GA Debugger231- gtag: `'debug_mode': true` in config232233View at: Reports > Configure > DebugView234235### Real-Time Reports236237Check events within 30 minutes:238Reports > Real-time239240### Common Issues241242**Events not appearing:**243- Check DebugView first244- Verify gtag/GTM firing245- Check filter exclusions246247**Parameter values missing:**248- Custom dimension not created249- Parameter name mismatch250- Data still processing (24-48 hrs)251252**Conversions not recording:**253- Event not marked as conversion254- Event name doesn't match255- Counting method (once vs. every)256257---258259## Data Quality260261### Filters262263Admin > Data streams > [Stream] > Configure tag settings > Define internal traffic264265**Exclude:**266- Internal IP addresses267- Developer traffic268- Testing environments269270### Cross-Domain Tracking271272For multiple domains sharing analytics:2732741. Admin > Data streams > [Stream] > Configure tag settings2752. Configure your domains2763. List all domains that should share sessions277278### Session Settings279280Admin > Data streams > [Stream] > Configure tag settings281282- Session timeout (default 30 min)283- Engaged session duration (10 sec default)284285---286287## Integration with Google Ads288289### Linking2902911. Admin > Product links > Google Ads links2922. Enable auto-tagging in Google Ads2933. Import conversions in Google Ads294295### Audience Export296297Audiences created in GA4 can be used in Google Ads for:298- Remarketing campaigns299- Customer match300- Similar audiences301