Skill Tracer
Skills › Marketing Skills › analytics › ga4-implementation.md

ga4-implementation.md

304 lines · skills/analytics/references/ga4-implementation.md at 88c79f6

Open on GitHub
1# GA4 Implementation Reference
2
3Detailed implementation guide for Google Analytics 4.
4

GA4 Implementation Reference

Detailed implementation guide for Google Analytics 4.

Raw lines 1 to 4
5## Contents
6- 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)

Contents

  • Configuration (data streams, enhanced measurement events, recommended events)
  • Custom Events (gtag.js implementation, Google Tag Manager)
  • Conversions Setup (creating conversions, conversion values)
  • Custom Dimensions and Metrics (when to use, setup steps, examples)
  • Audiences (creating audiences, audience examples)
  • Debugging (DebugView, real-time reports, common issues)
  • Data Quality (filters, cross-domain tracking, session settings)
  • Integration with Google Ads (linking, audience export)
Raw lines 5 to 14
15## Configuration

Configuration

Raw lines 15 to 16
17### Data Streams
19- One stream per platform (web, iOS, Android)
20- Enable enhanced measurement for automatic tracking
21- Configure data retention (2 months default, 14 months max)
22- Enable Google Signals (for cross-device, if consented)

Data Streams

  • One stream per platform (web, iOS, Android)
  • Enable enhanced measurement for automatic tracking
  • Configure data retention (2 months default, 14 months max)
  • Enable Google Signals (for cross-device, if consented)
Raw lines 17 to 23
24### Enhanced Measurement Events (Automatic)
26| Event | Description | Configuration |
27|-------|-------------|---------------|
28| page_view | Page loads | Automatic |
29| scroll | 90% scroll depth | Toggle on/off |
30| click | Outbound link click (`outbound: true`); cross-domain measurement domains are excluded | Toggle on/off |
31| view_search_results | Search results page with a configured search query parameter | Configure query parameters |
32| video_start, video_progress, video_complete | Embedded YouTube start, progress and completion | Toggle on/off; JS API support required |
33| file_download | PDF, docs, etc. | Configurable extensions |
35Use these exact names in event filters and triggers. The option labels "outbound clicks", "site search" and "video engagement" are not automatic event names. For video, report starts, progress milestones and completions separately; adding all three counts double-counts a viewing journey. A custom event with one of the old labels needs its own implementation. Verify enabled options and observed parameters in DebugView before expecting data.
37Contract: [Google enhanced measurement events](https://support.google.com/analytics/answer/9216061).

Enhanced Measurement Events (Automatic)

EventDescriptionConfiguration
page_viewPage loadsAutomatic
scroll90% scroll depthToggle on/off
clickOutbound link click (outbound: true); cross-domain measurement domains are excludedToggle on/off
view_search_resultsSearch results page with a configured search query parameterConfigure query parameters
video_start, video_progress, video_completeEmbedded YouTube start, progress and completionToggle on/off; JS API support required
file_downloadPDF, docs, etc.Configurable extensions

Use these exact names in event filters and triggers. The option labels "outbound clicks", "site search" and "video engagement" are not automatic event names. For video, report starts, progress milestones and completions separately; adding all three counts double-counts a viewing journey. A custom event with one of the old labels needs its own implementation. Verify enabled options and observed parameters in DebugView before expecting data.

Contract: Google enhanced measurement events.

Raw lines 24 to 38
39### Recommended Events
41Use Google's predefined events when possible for enhanced reporting:
43**All properties:**
44- login, sign_up
45- share
46- search
48**E-commerce:**
49- view_item, view_item_list
50- add_to_cart, remove_from_cart
51- begin_checkout
52- add_payment_info
53- purchase, refund
55**Games:**
56- level_up, unlock_achievement
57- post_score, spend_virtual_currency
59Reference: https://support.google.com/analytics/answer/9267735
61---

Recommended Events

Use Google's predefined events when possible for enhanced reporting:

All properties:

  • login, sign_up
  • share
  • search

E-commerce:

  • view_item, view_item_list
  • add_to_cart, remove_from_cart
  • begin_checkout
  • add_payment_info
  • purchase, refund

Games:

  • level_up, unlock_achievement
  • post_score, spend_virtual_currency

Reference: https://support.google.com/analytics/answer/9267735


Raw lines 39 to 62
63## Custom Events

Custom Events

Raw lines 63 to 64
65### gtag.js Implementation
67```javascript
68// Recommended event (your plan's signup_completed maps to GA4's sign_up)
69gtag('event', 'sign_up', {
70 'method': 'email',
71 'plan': 'free'
72});
74// Event with value
75gtag('event', 'purchase', {
76 'transaction_id': 'T12345',
77 'value': 99.99,
78 'currency': 'USD',
79 'items': [{
80 'item_id': 'SKU123',
81 'item_name': 'Product Name',
82 'price': 99.99
83 }]
84});
86// User properties
87gtag('set', 'user_properties', {
88 'user_type': 'premium',
89 'plan_name': 'pro'
90});
92// User ID (for logged-in users)
93gtag('config', 'GA_MEASUREMENT_ID', {
94 'user_id': 'USER_ID'
95});
96```

gtag.js Implementation

// Recommended event (your plan's signup_completed maps to GA4's sign_up)
gtag('event', 'sign_up', {
  'method': 'email',
  'plan': 'free'
});

// Event with value
gtag('event', 'purchase', {
  'transaction_id': 'T12345',
  'value': 99.99,
  'currency': 'USD',
  'items': [{
    'item_id': 'SKU123',
    'item_name': 'Product Name',
    'price': 99.99
  }]
});

// User properties
gtag('set', 'user_properties', {
  'user_type': 'premium',
  'plan_name': 'pro'
});

// User ID (for logged-in users)
gtag('config', 'GA_MEASUREMENT_ID', {
  'user_id': 'USER_ID'
});
Raw lines 65 to 97
98### Google Tag Manager (dataLayer)
100```javascript
101// Internal event name; a GTM GA4 Event tag sends it to GA4 as sign_up
102dataLayer.push({
103 'event': 'signup_completed',
104 'method': 'email',
105 'plan': 'free'
106});
108// Set user properties
109dataLayer.push({
110 'user_id': '12345',
111 'user_type': 'premium'
112});
114// E-commerce purchase
115dataLayer.push({
116 'event': 'purchase',
117 'ecommerce': {
118 'transaction_id': 'T12345',
119 'value': 99.99,
120 'currency': 'USD',
121 'items': [{
122 'item_id': 'SKU123',
123 'item_name': 'Product Name',
124 'price': 99.99,
125 'quantity': 1
126 }]
127 }
128});
130// Clear ecommerce before sending (best practice)
131dataLayer.push({ ecommerce: null });
132dataLayer.push({
133 'event': 'view_item',
134 'ecommerce': {
135 // ...
136 }
137});
138```
140---

Google Tag Manager (dataLayer)

// Internal event name; a GTM GA4 Event tag sends it to GA4 as sign_up
dataLayer.push({
  'event': 'signup_completed',
  'method': 'email',
  'plan': 'free'
});

// Set user properties
dataLayer.push({
  'user_id': '12345',
  'user_type': 'premium'
});

// E-commerce purchase
dataLayer.push({
  'event': 'purchase',
  'ecommerce': {
    'transaction_id': 'T12345',
    'value': 99.99,
    'currency': 'USD',
    'items': [{
      'item_id': 'SKU123',
      'item_name': 'Product Name',
      'price': 99.99,
      'quantity': 1
    }]
  }
});

// Clear ecommerce before sending (best practice)
dataLayer.push({ ecommerce: null });
dataLayer.push({
  'event': 'view_item',
  'ecommerce': {
    // ...
  }
});

Raw lines 98 to 141
142## Conversions Setup

Conversions Setup

Raw lines 142 to 143
144### Creating Conversions
1461. **Collect the event** - Ensure event is firing in GA4
1472. **Mark as conversion** - Admin > Events > Mark as conversion
1483. **Set counting method**:
149 - Once per session (leads, signups)
150 - Every event (purchases)
1514. **Import to Google Ads** - For conversion-optimized bidding

Creating Conversions

  1. Collect the event - Ensure event is firing in GA4
  2. Mark as conversion - Admin > Events > Mark as conversion
  3. Set counting method:
  4. Once per session (leads, signups)
  5. Every event (purchases)
  6. Import to Google Ads - For conversion-optimized bidding
Raw lines 144 to 152
153### Conversion Values
155```javascript
156// Event with conversion value
157gtag('event', 'purchase', {
158 'value': 99.99,
159 'currency': 'USD'
160});
161```
163Or set default value in GA4 Admin when marking conversion.
165---

Conversion Values

// Event with conversion value
gtag('event', 'purchase', {
  'value': 99.99,
  'currency': 'USD'
});

Or set default value in GA4 Admin when marking conversion.


Raw lines 153 to 166
167## Custom Dimensions and Metrics

Custom Dimensions and Metrics

Raw lines 167 to 168
169### When to Use
171**Custom dimensions:**
172- Properties you want to segment/filter by
173- User attributes (plan type, industry)
174- Content attributes (author, category)
176**Custom metrics:**
177- Numeric values to aggregate
178- Scores, counts, durations

When to Use

Custom dimensions:

  • Properties you want to segment/filter by
  • User attributes (plan type, industry)
  • Content attributes (author, category)

Custom metrics:

  • Numeric values to aggregate
  • Scores, counts, durations
Raw lines 169 to 179
180### Setup Steps
1821. Admin > Data display > Custom definitions
1832. Create dimension or metric
1843. Choose scope:
185 - **Event**: Per event (content_type)
186 - **User**: Per user (account_type)
187 - **Item**: Per product (product_category)
1884. Enter parameter name (must match event parameter)

Setup Steps

  1. Admin > Data display > Custom definitions
  2. Create dimension or metric
  3. Choose scope:
  4. Event: Per event (content_type)
  5. User: Per user (account_type)
  6. Item: Per product (product_category)
  7. Enter parameter name (must match event parameter)
Raw lines 180 to 189
190### Examples
192| Dimension | Scope | Parameter | Description |
193|-----------|-------|-----------|-------------|
194| User Type | User | user_type | Free, trial, paid |
195| Content Author | Event | author | Blog post author |
196| Product Category | Item | item_category | E-commerce category |
198---

Examples

DimensionScopeParameterDescription
User TypeUseruser_typeFree, trial, paid
Content AuthorEventauthorBlog post author
Product CategoryItemitem_categoryE-commerce category

Raw lines 190 to 199
200## Audiences
202### Creating Audiences
204Admin > Data display > Audiences
206**Use cases:**
207- Remarketing audiences (export to Ads)
208- Segment analysis
209- Trigger-based events

Creating Audiences

Admin > Data display > Audiences

Use cases:

  • Remarketing audiences (export to Ads)
  • Segment analysis
  • Trigger-based events
Raw lines 202 to 210
211### Audience Examples
213**High-intent visitors:**
214- Viewed pricing page
215- Did not convert
216- In last 7 days
218**Engaged users:**
219- 3+ sessions
220- Or 5+ minutes total engagement
222**Purchasers:**
223- Purchase event
224- For exclusion or lookalike
226---

Audience Examples

High-intent visitors:

  • Viewed pricing page
  • Did not convert
  • In last 7 days

Engaged users:

  • 3+ sessions
  • Or 5+ minutes total engagement

Purchasers:

  • Purchase event
  • For exclusion or lookalike

Raw lines 211 to 227
228## Debugging
230### DebugView
232Enable with:
233- URL parameter: `?debug_mode=true`
234- Chrome extension: GA Debugger
235- gtag: `'debug_mode': true` in config
237View at: Reports > Configure > DebugView

DebugView

Enable with:

  • URL parameter: ?debug_mode=true
  • Chrome extension: GA Debugger
  • gtag: 'debug_mode': true in config

View at: Reports > Configure > DebugView

Raw lines 230 to 238
239### Real-Time Reports
241Check events within 30 minutes:
242Reports > Real-time

Real-Time Reports

Check events within 30 minutes: Reports > Real-time

Raw lines 239 to 243
244### Common Issues
246**Events not appearing:**
247- Check DebugView first
248- Verify gtag/GTM firing
249- Check filter exclusions
251**Parameter values missing:**
252- Custom dimension not created
253- Parameter name mismatch
254- Data still processing (24-48 hrs)
256**Conversions not recording:**
257- Event not marked as conversion
258- Event name doesn't match
259- Counting method (once vs. every)
261---

Common Issues

Events not appearing:

  • Check DebugView first
  • Verify gtag/GTM firing
  • Check filter exclusions

Parameter values missing:

  • Custom dimension not created
  • Parameter name mismatch
  • Data still processing (24-48 hrs)

Conversions not recording:

  • Event not marked as conversion
  • Event name doesn't match
  • Counting method (once vs. every)

Raw lines 244 to 262
263## Data Quality
265### Filters
267Admin > Data streams > [Stream] > Configure tag settings > Define internal traffic
269**Exclude:**
270- Internal IP addresses
271- Developer traffic
272- Testing environments

Filters

Admin > Data streams > [Stream] > Configure tag settings > Define internal traffic

Exclude:

  • Internal IP addresses
  • Developer traffic
  • Testing environments
Raw lines 265 to 273
274### Cross-Domain Tracking
276For multiple domains sharing analytics:
2781. Admin > Data streams > [Stream] > Configure tag settings
2792. Configure your domains
2803. List all domains that should share sessions

Cross-Domain Tracking

For multiple domains sharing analytics:

  1. Admin > Data streams > [Stream] > Configure tag settings
  2. Configure your domains
  3. List all domains that should share sessions
Raw lines 274 to 281
282### Session Settings
284Admin > Data streams > [Stream] > Configure tag settings
286- Session timeout (default 30 min)
287- Engaged session duration (10 sec default)
289---

Session Settings

Admin > Data streams > [Stream] > Configure tag settings

  • Session timeout (default 30 min)
  • Engaged session duration (10 sec default)

Raw lines 282 to 290
291## Integration with Google Ads

Integration with Google Ads

Raw lines 291 to 292
293### Linking
2951. Admin > Product links > Google Ads links
2962. Enable auto-tagging in Google Ads
2973. Import conversions in Google Ads

Linking

  1. Admin > Product links > Google Ads links
  2. Enable auto-tagging in Google Ads
  3. Import conversions in Google Ads
Raw lines 293 to 298
299### Audience Export
301Audiences created in GA4 can be used in Google Ads for:
302- Remarketing campaigns
303- Customer match
304- Similar audiences

Audience Export

Audiences created in GA4 can be used in Google Ads for:

  • Remarketing campaigns
  • Customer match
  • Similar audiences
Raw lines 299 to 304