Skip to main content
Google Analytics 4 SQL Bridge - Query your GA4 data using standard SQL syntax. Transform analytics insights into actionable data queries.

Overview

The GA4 SQL Driver allows you to query your Google Analytics 4 property using familiar SQL syntax. This integration transforms GA4’s Data API into a SQL-queryable interface, making it easy to analyze your analytics data alongside other databases.

Quick Start

1. Set up Google Service Account

Add our service account email as a Viewer to your GA4 property (find email below)

2. Connect SyneHQ to your GA4 Property

Navigate to Add Connections
GA4 Connection Setup

3. Run Your First Query

Finding Your Property ID

Your GA4 Property ID is the numeric ID (not the Measurement ID starting with G-):
  1. Go to GA4 Admin > Property Settings
  2. Copy the Property ID (numeric, e.g., 123456789)

SQL Syntax Reference

Supported SQL Subset

The GA4 driver supports a focused SQL subset optimized for analytics queries:

Field Types

  • Dimensions: Categorical data (country, deviceCategory, source, etc.)
  • Metrics: Numerical data (totalUsers, sessions, revenue, etc.)

Metric Prefixing

Metrics can be prefixed with m: for clarity (optional):

Date Filtering

Date filtering is required for data queries:

Discovery Commands

Explore available data with these special SQL commands:

List Available Fields

Schema Exploration

Query Examples

Basic Analytics

Device & Technology Analysis

Geographic Analysis

Page Performance

Campaign Analysis

E-commerce Analysis

Event Analysis

Field Reference

Common Dimensions

Common Metrics

Discovery Commands

Best Practices

1. Always Include Date Ranges

2. Use Appropriate Aggregation

3. Optimize Query Performance

4. Handle GA4 Limitations

Troubleshooting

Common Errors

1. “Field X is not a valid dimension”
Solution: Use LIST DIMENSIONS to see valid field names. 2. “User does not have sufficient permissions” Solution: Ensure your service account has Viewer access to the GA4 property. 3. “Property not found” Solution: Verify you’re using the correct Property ID (numeric, not Measurement ID). 4. Missing date range

Debugging Tips

  1. Start Simple: Begin with basic queries and add complexity gradually
  2. Check Field Names: Use discovery commands to verify field names
  3. Test Date Ranges: Ensure your date range contains data
  4. Monitor Limits: Be aware of GA4’s sampling and cardinality limits
  5. Check Permissions: Verify service account access

Performance Optimization

  1. Use Shorter Date Ranges for faster queries
  2. Limit Results with LIMIT clause
  3. Filter Early with WHERE conditions
  4. Avoid High-Cardinality dimensions when possible
  5. Cache Results for repeated queries

Advanced Usage

Custom Calculated Fields

Time Series Analysis


Getting Help

  • Field Reference: Use LIST DIMENSIONS and LIST METRICS commands
  • Schema Info: Use DESCRIBE ga4 for table structure
  • GA4 Documentation: GA4 Data API Schema
  • Error Messages: Check the details field in error responses for specific guidance
Start exploring your GA4 data with SQL today! 🚀