Working with GA4 Data in Hardal

Welcome to our guide on accessing and analyzing your Google Analytics 4 (GA4) data within Hardal. This documentation will help you understand how to effectively use your GA4 data that’s been collected and stored in Hardal.

Data Structure Overview

Your GA4 data is stored in a dedicated table called reporting_events_ga4_data. This table contains a comprehensive set of fields from your GA4 implementation.

Available Data Categories

Core Event Information

created_at              -- Event timestamp
ga4_event_name         -- Name of the GA4 event
server_distinct_id     -- Unique identifier for the user
client_id              -- GA4 client ID
session_id             -- Unique session identifier

Page Information

page_url               -- Full URL of the page
page_path              -- Path component of the URL
page_title             -- Page title
page_protocol          -- Protocol (http/https)
page_hostname          -- Domain name
page_hash              -- URL hash component
page_referrer          -- Referring URL

Device and Browser Details

browser_name           -- Browser name
browser_version        -- Browser version
browser_language       -- Browser language setting
browser_platform       -- Operating system platform
browser_vendor         -- Browser vendor
browser_user_agent     -- Complete user agent string
device_type           -- Type of device (mobile/desktop/tablet)

Creating Essential Reports

Let’s explore how to create meaningful reports with this data.

User Journey Analysis

Track user navigation with:

CASE 
  WHEN page_path IS NOT NULL 
  THEN REGEXP_REPLACE(page_path, '^/', '')
  ELSE '(not set)'
END

E-commerce Tracking

1

Transaction Data
2

Access e-commerce data using these fields:
3

transaction_id
transaction_value
transaction_tax
transaction_shipping
transaction_coupon
4

Product Information
5

Track product interactions:
6

product_1
product_2
product_3
7

Currency Information
8

Monitor transaction currencies:
9

currency

Creating Custom Metrics

Session Quality Score

CASE
  WHEN CAST(session_engagement AS INTEGER) > 0 
       AND CAST(page_load_time AS INTEGER) < 3000 THEN 'High'
  WHEN CAST(session_engagement AS INTEGER) > 0 THEN 'Medium'
  ELSE 'Low'
END

User Type Classification

CASE
  WHEN CAST(is_repeat AS INTEGER) > 0 THEN 'Returning User'
  ELSE 'New User'
END

Best Practices

Performance Optimization

Data Accuracy

  1. Session Handling

    -- Reliable session identification
    COALESCE(session_id, 
            CONCAT(client_id, '_', 
                  DATE_FORMAT(created_at, '%Y%m%d%H%i')))
    
  2. User Identification

    -- Consistent user tracking
    COALESCE(server_distinct_id, client_id)
    

Common Use Cases

Marketing Attribution

-- Campaign effectiveness
SELECT 
  utm_source,
  utm_medium,
  utm_campaign,
  COUNT(DISTINCT client_id) as users,
  COUNT(DISTINCT session_id) as sessions

User Experience Monitoring

-- Page performance tracking
SELECT
  page_path,
  AVG(CAST(page_load_time AS INTEGER)) as avg_load_time,
  COUNT(DISTINCT session_id) as sessions

Troubleshooting

If data is missing:

  1. Check event_name filters

  2. Verify GA4 implementation

  3. Confirm date ranges

Next Steps

After setting up your basic GA4 reporting:

  1. Create custom dashboards for different stakeholders

  2. Set up automated reporting

  3. Implement custom metrics for your business KPIs