↓ Skip to main content

Google Analytics 4 SQLite Schema Reference #

The Google Analytics database is created and maintained automatically by scripts/google_analytics.py. Database tables, indexes, and analytical views are provisioned during sync operations.


1. Relational Tables #

daily_pages #

Stores daily pageviews, active users, sessions, active dwell time, and bounce rate broken down by country, device, and traffic source.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENTUnique row ID
property_idTEXTNOT NULLGA4 Property ID
dateTEXTNOT NULLActivity date (YYYY-MM-DD)
page_pathTEXTNOT NULLURL path component (e.g. /blog/post-1/)
page_titleTEXTHTML page title
countryTEXTVisitor country name
device_categoryTEXTDevice category (desktop, mobile, tablet)
source_mediumTEXTAcquisition source / medium (e.g. google / organic)
screen_page_viewsINTEGERDEFAULT 0Total pageviews
active_usersINTEGERDEFAULT 0Count of distinct active visitors
sessionsINTEGERDEFAULT 0Number of visitor sessions
user_engagement_durationREALDEFAULT 0.0Total active dwell time in seconds
bounce_rateREALDEFAULT 0.0Fraction of unengaged sessions (0.0 to 1.0)
raw_jsonTEXTComplete raw API row JSON payload
synced_atTEXTTimestamp of local database sync

Unique Constraint: (property_id, date, page_path, country, device_category, source_medium)


daily_traffic #

Stores daily acquisition channels, source/medium pairs, new users, engaged sessions, and dwell duration.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENTUnique row ID
property_idTEXTNOT NULLGA4 Property ID
dateTEXTNOT NULLActivity date (YYYY-MM-DD)
session_source_mediumTEXTNOT NULLSource / Medium (e.g. direct / none, linkedin.com / referral)
session_default_channel_groupTEXTHigh-level channel (Direct, Organic Search, Organic Social, Referral)
countryTEXTVisitor country name
device_categoryTEXTDevice category
sessionsINTEGERDEFAULT 0Total sessions initiated
active_usersINTEGERDEFAULT 0Total distinct active visitors
new_usersINTEGERDEFAULT 0First-time visitors
engaged_sessionsINTEGERDEFAULT 0Sessions lasting >10s, with 2+ views, or conversions
user_engagement_durationREALDEFAULT 0.0Total active dwell time in seconds
bounce_rateREALDEFAULT 0.0Bounce rate fraction
raw_jsonTEXTRaw API row JSON payload
synced_atTEXTTimestamp of local database sync

Unique Constraint: (property_id, date, session_source_medium, session_default_channel_group, country, device_category)

ℹ️ NOTE

Organic Search Tracking: GA4 records 100% of landing sessions originating from organic search across all search engines (Google, Bing, DuckDuckGo, Ecosia, AI search engines) without query-level privacy stripping. This represents actual on-site visitor arrivals and naturally aligns with Search Console property-level totals (daily_site_performance in search-analytics and GSC Web UI Performance cards).


daily_events #

Stores daily user engagement events (scroll, click, first_visit, user_engagement, page_view).

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENTUnique row ID
property_idTEXTNOT NULLGA4 Property ID
dateTEXTNOT NULLActivity date (YYYY-MM-DD)
event_nameTEXTNOT NULLEvent name identifier
page_pathTEXTURL path where event occurred
countryTEXTVisitor country
device_categoryTEXTDevice category
event_countINTEGERDEFAULT 0Total event occurrences
total_usersINTEGERDEFAULT 0Unique users triggering the event
raw_jsonTEXTRaw API row JSON payload
synced_atTEXTTimestamp of local database sync

outbound_clicks #

Stores external link exit destinations, referring pages, and user clicks.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENTUnique row ID
property_idTEXTNOT NULLGA4 Property ID
dateTEXTNOT NULLActivity date (YYYY-MM-DD)
link_urlTEXTNOT NULLDestination URL clicked
page_pathTEXTReferring page path
countryTEXTVisitor country
event_countINTEGERDEFAULT 0Total clicks on destination link
total_usersINTEGERDEFAULT 0Unique visitors clicking destination
raw_jsonTEXTRaw API row JSON payload
synced_atTEXTTimestamp of local database sync

properties #

Verified GA4 property metadata, time zone, and account configuration.

ColumnTypeConstraintsDescription
property_idTEXTPRIMARY KEYGA4 Property numeric ID (e.g. 123456789)
nameTEXTGA4 resource name (properties/123456789)
account_idTEXTParent GA4 Account ID
display_nameTEXTHuman-readable property title
industry_categoryTEXTIndustry category classification
time_zoneTEXTReporting timezone string (e.g. UTC, America/New_York)
currency_codeTEXTReporting currency code (e.g. USD)
service_levelTEXTGA4 service level (GOOGLE_ANALYTICS_STANDARD, GOOGLE_ANALYTICS_360)
create_timeTEXTCreation timestamp
update_timeTEXTModification timestamp
raw_jsonTEXTComplete raw JSON property payload
last_synced_atTEXTTimestamp of local database sync

site_milestones #

Tracks release milestones, major blog launches, and architectural updates for cohort impact analysis.

ColumnTypeConstraintsDescription
commit_hashTEXTPRIMARY KEYGit commit hash or unique milestone identifier
event_dateDATENOT NULLMilestone date (YYYY-MM-DD)
titleTEXTNOT NULLShort title of the release / milestone
descriptionTEXTDetailed context or release notes
categoryTEXTCategory (release, article, campaign, major_feature)
scopeTEXTScope tag (site, blog, oss)
authorTEXTAuthor name or handle
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPRecord creation timestamp

sync_history #

Audit log recording every backfill and incremental sync operation.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENTUnique sync run ID
property_idTEXTNOT NULLGA4 Property ID
sync_typeTEXTNOT NULLSync type (incremental, full, range)
start_dateTEXTStarting date of sync window
end_dateTEXTEnding date of sync window
pages_syncedINTEGERDEFAULT 0Count of page rows synced
traffic_syncedINTEGERDEFAULT 0Count of traffic rows synced
events_syncedINTEGERDEFAULT 0Count of event rows synced
outbound_syncedINTEGERDEFAULT 0Count of outbound click rows synced
statusTEXTNOT NULLStatus (success, failed, running)
error_messageTEXTError details if failed
started_atTEXTNOT NULLStart timestamp
finished_atTEXTCompletion timestamp

2. Analytical SQL Views #

v_daily_summary #

Daily aggregated traffic totals across all landing pages.

ColumnTypeDescription
dateTEXTActivity date (YYYY-MM-DD)
total_sessionsINTEGERSum of sessions
total_active_usersINTEGERSum of active visitors
total_page_viewsINTEGERSum of pageviews
total_engagement_minREALTotal active dwell time in minutes
avg_bounce_pctREALAverage bounce rate percentage

v_page_performance #

Page-level rollup with views, active users, average dwell time, and bounce rate.

ColumnTypeDescription
page_pathTEXTURL path
page_titleTEXTPage title tag
total_viewsINTEGERTotal pageviews
total_usersINTEGERDistinct active visitors
total_sessionsINTEGERVisitor sessions
avg_dwell_secREALAverage active dwell time per user (seconds)
total_dwell_minREALTotal cumulative active dwell time (minutes)
avg_bounce_pctREALAverage bounce rate percentage

v_channel_performance #

Acquisition channels and source/medium pairs with sessions, new users, and engagement rate %.

ColumnTypeDescription
channel_groupTEXTHigh-level channel (Direct, Organic Search, Referral)
source_mediumTEXTSpecific source / medium
total_sessionsINTEGERTotal sessions initiated
total_usersINTEGERTotal active visitors
total_new_usersINTEGERFirst-time visitors
total_engaged_sessionsINTEGERCount of engaged sessions
engagement_rate_pctREALEngagement percentage (engaged_sessions / sessions * 100)
total_dwell_minREALTotal active dwell time in minutes
avg_bounce_pctREALAverage bounce rate percentage

v_geo_breakdown #

Geographical ranking by country with sessions, pageviews, and dwell time.

ColumnTypeDescription
countryTEXTCountry name
total_sessionsINTEGERTotal sessions
total_usersINTEGERTotal active visitors
total_page_viewsINTEGERTotal pageviews
avg_dwell_secREALAverage dwell time per user (seconds)
avg_bounce_pctREALAverage bounce rate percentage

v_events_summary #

Aggregate event interaction counts.

ColumnTypeDescription
event_nameTEXTEvent name identifier
total_eventsINTEGERTotal event occurrences
total_usersINTEGERCount of distinct users triggering event

Outbound exit destinations ranked by click counts and unique referring pages.

ColumnTypeDescription
link_urlTEXTExternal destination URL
total_clicksINTEGERTotal click count
total_usersINTEGERDistinct users who clicked
referring_pages_countINTEGERNumber of distinct local pages linking to destination

v_milestone_impact #

Pre vs post milestone comparison of page traffic and engagement.

ColumnTypeDescription
commit_hashTEXTMilestone identifier
milestone_titleTEXTTitle of the milestone
milestone_dateDATEEvent date (YYYY-MM-DD)
cohortTEXTPre-Milestone or Post-Milestone
days_trackedINTEGERDays tracked in cohort
total_viewsINTEGERTotal pageviews in cohort
total_usersINTEGERTotal active visitors in cohort
total_sessionsINTEGERTotal sessions in cohort
avg_engagement_secREALAverage active engagement duration (seconds)
avg_bounce_pctREALAverage bounce rate percentage