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 Syne to your GA4 Property
Navigate to Add Connections
3. Run Your First Query
Finding Your Property ID
Your GA4 Property ID is the numeric ID (not the Measurement ID starting with G-):- Go to GA4 Admin > Property Settings
- 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 withm:
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
Field | Description |
---|---|
date | Date in YYYY-MM-DD format |
country | User’s country |
region | User’s region/state |
city | User’s city |
deviceCategory | Device type (desktop, mobile, tablet) |
operatingSystem | Operating system |
browser | Browser name |
source | Traffic source |
medium | Traffic medium |
campaignName | Campaign name |
sessionDefaultChannelGroup | Default channel grouping |
pagePath | Page path |
pageTitle | Page title |
eventName | Event name |
Common Metrics
Field | Description |
---|---|
totalUsers | Total number of users |
activeUsers | Number of active users |
newUsers | Number of new users |
sessions | Number of sessions |
engagedSessions | Number of engaged sessions |
engagementRate | Engagement rate percentage |
bounceRate | Bounce rate percentage |
screenPageViews | Number of page/screen views |
averageSessionDuration | Average session duration |
conversions | Number of conversions |
totalRevenue | Total revenue |
eventCount | Number of events |
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”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
- Start Simple: Begin with basic queries and add complexity gradually
- Check Field Names: Use discovery commands to verify field names
- Test Date Ranges: Ensure your date range contains data
- Monitor Limits: Be aware of GA4’s sampling and cardinality limits
- Check Permissions: Verify service account access
Performance Optimization
- Use Shorter Date Ranges for faster queries
- Limit Results with
LIMIT
clause - Filter Early with
WHERE
conditions - Avoid High-Cardinality dimensions when possible
- Cache Results for repeated queries
Advanced Usage
Custom Calculated Fields
Time Series Analysis
Getting Help
- Field Reference: Use
LIST DIMENSIONS
andLIST 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