{"id":15908,"date":"2026-11-24T14:58:00","date_gmt":"2026-11-24T13:58:00","guid":{"rendered":"https:\/\/www.lukaswojcik.com\/blog\/?p=15908"},"modified":"2026-10-25T17:55:33","modified_gmt":"2026-10-25T16:55:33","slug":"ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables","status":"publish","type":"post","link":"https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/","title":{"rendered":"GA4 BigQuery Export: Sessions That Cross Midnight Land in Two Tables"},"content":{"rendered":"<p>A visit starts on 13 October at 23:50 and continues until 00:10 the next day. GA4 can treat that activity as one session. In the BigQuery export, however, the events can appear in two daily tables: events_20261013 and events_20261014. Midnight changes the event&#8217;s date; it does not by itself start a new session.<\/p>\n<p>The result depends on the question. A count of sessions with activity on each day can return one on Tuesday and one on Wednesday. Across both days, the same session counts once. Adding the two daily results would answer a different question from counting distinct sessions across the whole period.<\/p>\n<figure class=\"lw-diagram\"><img decoding=\"async\" src=\"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/diagrams\/dia-15908-midnight-20261025.png\" width=\"1120\" height=\"580\" loading=\"lazy\" alt=\"One session with activity before and after midnight: two daily appearances but one distinct key across the period.\"><figcaption>Daily activity and session starts are different questions.<\/figcaption><\/figure>\n<h2>What identifies the session?<\/h2>\n<p>Google generates ga_session_id from the session&#8217;s start time in seconds. Two different visitors can start in the same second, so that number alone is not a unique session key. user_pseudo_id identifies a browser or app installation rather than a verified person. The example keeps that identifier and ga_session_id together, and uses stream_id to distinguish the configured website or app data sources. Separate grouping columns avoid accidental collisions from joining strings without a separator.<\/p>\n<p>The session ID sits inside the repeated event_params field, a list of event parameters. Google tags and Firebase SDKs normally attach it; Measurement Protocol and Data Import do not attach it automatically. Missing identifiers must be reported separately, not combined into one invented session. Replacing user_pseudo_id with user_id midway through a visit can also split the count when a login changes the available identifier.<\/p>\n<h2>The first row found is not necessarily the start<\/h2>\n<p>MIN(event_timestamp) finds the earliest timestamp among the rows actually read. If the query reads only Wednesday, the first Tuesday event is outside its view. A window function calculates a value across related rows, such as all events with the same session key. It cannot recover a missing row. Reading one previous day helps with some visits, but does not guarantee a full history: an active session has no fixed maximum duration.<\/p>\n<p>The start encoded in an automatically generated session ID offers another route. It can reveal a Tuesday start even when only a Wednesday event is available. This relies on the documented ID format. A manually assigned Measurement Protocol ID needs separate validation. Neither route discovers sessions with no exported event in the selected data.<\/p>\n<h2>Dates and export delivery are separate<\/h2>\n<p>event_date records a date in the configured reporting time zone. event_timestamp is a UTC value in microseconds; the current schema describes receipt by Analytics. It is not the time when the BigQuery export job ran. A BigQuery dataset&#8217;s storage location does not set its reporting time zone.<\/p>\n<p>For an explicit timestamp conversion, DATE(TIMESTAMP_MICROS(event_timestamp), &#8216;Europe\/Warsaw&#8217;) uses Warsaw time. Without the time-zone argument, DATE uses UTC. For example, 00:30 in Warsaw in summer corresponds to 22:30 UTC on the previous day. A timestamp-derived date and the exported event_date should not be assumed interchangeable for every delayed event or changed time-zone configuration.<\/p>\n<p>The daily export is not a job guaranteed to finish at midnight. Google describes typical afternoon delivery, with possible delays into the following day. Daily tables can receive late events for several days and can exceptionally be reprocessed later. A present table is therefore not proof that no more rows will arrive.<\/p>\n<h2>One query, two clearly named counts<\/h2>\n<p>The following GoogleSQL example reads only the daily tables for 13 and 14 October 2026. The project and dataset names are placeholders. It reports distinct session keys observed in those tables, the subset whose ID indicates a start in that period, and the number of event rows without a usable key. The last number counts events, not missing sessions.<\/p>\n<figure style=\"--cbb-digits:2\" class=\"cbb cbb--wrap cbb--numbers wp-block-code-beautifier-block-code\" data-lang=\"sql\"><figcaption class=\"cbb-head\"><span class=\"cbb-lang\">SQL<\/span><span class=\"cbb-actions\"><button type=\"button\" class=\"cbb-button cbb-button--wrap\" data-cbb-action=\"wrap\" aria-pressed=\"true\" title=\"Wrap long lines\"><svg aria-hidden=\"true\" focusable=\"false\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\"><path d=\"M2 4h12M2 8h9.5a2.5 2.5 0 0 1 0 5H8m0 0 1.5-1.5M8 13l1.5 1.5M2 12h3\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/><\/svg><span class=\"cbb-sr\">Wrap long lines<\/span><\/button><button type=\"button\" class=\"cbb-button cbb-button--copy\" data-cbb-action=\"copy\" aria-label=\"Copy code\" data-cbb-status-done=\"Code copied to the clipboard.\" data-cbb-status-failed=\"Copying failed. The code is selected for copying with Ctrl+C or \u2318+C.\" data-cbb-status-noselect=\"Copying failed.\"><svg aria-hidden=\"true\" focusable=\"false\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\"><rect x=\"5.5\" y=\"5.5\" width=\"8\" height=\"8.5\" rx=\"1.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><path d=\"M10.5 3.5V3A1.5 1.5 0 0 0 9 1.5H4A1.5 1.5 0 0 0 2.5 3v6.5A1.5 1.5 0 0 0 4 11h.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><\/svg><span class=\"cbb-button-label\">Copy<\/span><\/button><\/span><\/figcaption><pre class=\"cbb-pre\" tabindex=\"0\" role=\"region\" aria-label=\"Code example: SQL\"><code class=\"cbb-code language-sql\" style=\"counter-reset:cbb-line 0;\"><span class=\"cbb-line\"><span class=\"cbb-keyword\">WITH<\/span> extracted <span class=\"cbb-keyword\">AS<\/span> (\n<\/span><span class=\"cbb-line\">  <span class=\"cbb-keyword\">SELECT<\/span>\n<\/span><span class=\"cbb-line\">    stream_id,\n<\/span><span class=\"cbb-line\">    user_pseudo_id,\n<\/span><span class=\"cbb-line\">    (<span class=\"cbb-keyword\">SELECT<\/span> <span class=\"cbb-keyword\">IF<\/span>(<span class=\"cbb-function\">COUNT<\/span>(*) = <span class=\"cbb-number\">1<\/span>, <span class=\"cbb-function\">MAX<\/span>(param.value.int_value), <span class=\"cbb-constant\">NULL<\/span>)\n<\/span><span class=\"cbb-line\">     <span class=\"cbb-keyword\">FROM<\/span> <span class=\"cbb-keyword\">UNNEST<\/span>(event_params) <span class=\"cbb-keyword\">AS<\/span> param\n<\/span><span class=\"cbb-line\">     <span class=\"cbb-keyword\">WHERE<\/span> param.<span class=\"cbb-keyword\">key<\/span> = <span class=\"cbb-string\">'ga_session_id'<\/span>) <span class=\"cbb-keyword\">AS<\/span> session_id\n<\/span><span class=\"cbb-line\">  <span class=\"cbb-keyword\">FROM<\/span> <span class=\"cbb-variable\">`example-project.analytics_123456789.events_*`<\/span>\n<\/span><span class=\"cbb-line\">  <span class=\"cbb-keyword\">WHERE<\/span> _TABLE_SUFFIX <span class=\"cbb-keyword\">BETWEEN<\/span> <span class=\"cbb-string\">'20261013'<\/span> <span class=\"cbb-keyword\">AND<\/span> <span class=\"cbb-string\">'20261014'<\/span>\n<\/span><span class=\"cbb-line\">    <span class=\"cbb-keyword\">AND<\/span> <span class=\"cbb-function\">REGEXP_CONTAINS<\/span>(_TABLE_SUFFIX, r<span class=\"cbb-string\">'^\\d{8}$'<\/span>)\n<\/span><span class=\"cbb-line\">), valid_keys <span class=\"cbb-keyword\">AS<\/span> (\n<\/span><span class=\"cbb-line\">  <span class=\"cbb-keyword\">SELECT<\/span> <span class=\"cbb-keyword\">DISTINCT<\/span> stream_id, user_pseudo_id, session_id\n<\/span><span class=\"cbb-line\">  <span class=\"cbb-keyword\">FROM<\/span> extracted\n<\/span><span class=\"cbb-line\">  <span class=\"cbb-keyword\">WHERE<\/span> stream_id <span class=\"cbb-keyword\">IS<\/span> <span class=\"cbb-keyword\">NOT<\/span> <span class=\"cbb-constant\">NULL<\/span>\n<\/span><span class=\"cbb-line\">    <span class=\"cbb-keyword\">AND<\/span> user_pseudo_id <span class=\"cbb-keyword\">IS<\/span> <span class=\"cbb-keyword\">NOT<\/span> <span class=\"cbb-constant\">NULL<\/span>\n<\/span><span class=\"cbb-line\">    <span class=\"cbb-keyword\">AND<\/span> session_id <span class=\"cbb-keyword\">BETWEEN<\/span> <span class=\"cbb-number\">1<\/span> <span class=\"cbb-keyword\">AND<\/span> <span class=\"cbb-number\">253402214399<\/span>\n<\/span><span class=\"cbb-line\">), dated_keys <span class=\"cbb-keyword\">AS<\/span> (\n<\/span><span class=\"cbb-line\">  <span class=\"cbb-keyword\">SELECT<\/span> *,\n<\/span><span class=\"cbb-line\">    <span class=\"cbb-type\">DATE<\/span>(<span class=\"cbb-function\">TIMESTAMP_SECONDS<\/span>(session_id), <span class=\"cbb-string\">'Europe\/Warsaw'<\/span>) <span class=\"cbb-keyword\">AS<\/span> start_date\n<\/span><span class=\"cbb-line\">  <span class=\"cbb-keyword\">FROM<\/span> valid_keys\n<\/span><span class=\"cbb-line\">)\n<\/span><span class=\"cbb-line\"><span class=\"cbb-keyword\">SELECT<\/span>\n<\/span><span class=\"cbb-line\">  <span class=\"cbb-function\">COUNT<\/span>(*) <span class=\"cbb-keyword\">AS<\/span> sessions_observed_in_range,\n<\/span><span class=\"cbb-line\">  <span class=\"cbb-function\">COALESCE<\/span>(<span class=\"cbb-function\">COUNTIF<\/span>(start_date <span class=\"cbb-keyword\">BETWEEN<\/span> <span class=\"cbb-type\">DATE<\/span> <span class=\"cbb-string\">'2026-10-13'<\/span> <span class=\"cbb-keyword\">AND<\/span> <span class=\"cbb-type\">DATE<\/span> <span class=\"cbb-string\">'2026-10-14'<\/span>), <span class=\"cbb-number\">0<\/span>)\n<\/span><span class=\"cbb-line\">    <span class=\"cbb-keyword\">AS<\/span> observed_sessions_started_in_range,\n<\/span><span class=\"cbb-line\">  (<span class=\"cbb-keyword\">SELECT<\/span> <span class=\"cbb-function\">COUNT<\/span>(*) <span class=\"cbb-keyword\">FROM<\/span> extracted\n<\/span><span class=\"cbb-line\">   <span class=\"cbb-keyword\">WHERE<\/span> stream_id <span class=\"cbb-keyword\">IS<\/span> <span class=\"cbb-constant\">NULL<\/span> <span class=\"cbb-keyword\">OR<\/span> user_pseudo_id <span class=\"cbb-keyword\">IS<\/span> <span class=\"cbb-constant\">NULL<\/span>\n<\/span><span class=\"cbb-line\">      <span class=\"cbb-keyword\">OR<\/span> session_id <span class=\"cbb-keyword\">IS<\/span> <span class=\"cbb-constant\">NULL<\/span>\n<\/span><span class=\"cbb-line\">      <span class=\"cbb-keyword\">OR<\/span> session_id <span class=\"cbb-keyword\">NOT<\/span> <span class=\"cbb-keyword\">BETWEEN<\/span> <span class=\"cbb-number\">1<\/span> <span class=\"cbb-keyword\">AND<\/span> <span class=\"cbb-number\">253402214399<\/span>)\n<\/span><span class=\"cbb-line\">    <span class=\"cbb-keyword\">AS<\/span> events_without_usable_session_key\n<\/span><span class=\"cbb-line\"><span class=\"cbb-keyword\">FROM<\/span> dated_keys;<\/span><\/code><\/pre><span class=\"cbb-status\" role=\"status\"><\/span><\/figure>\n<p>The numeric range prevents impossible timestamp conversions; it does not prove that an ID was generated correctly. Repeated ga_session_id parameters are treated as unusable instead of choosing an arbitrary value. The chosen stream-based key keeps streams separate; it is not a cross-device identity model.<\/p>\n<p>For a complete count of session starts, the export must contain enough evidence of those sessions. The example cannot recover a missing table, an excluded stream or an unexported start with no later observed event. A dry run checks the query without running the full analysis. In the target BigQuery project, it can check syntax, permissions and the estimated scan size before a paid query runs.<\/p>\n<h2>Daily and intraday tables must not overlap<\/h2>\n<p>events_* also matches names beginning events_intraday_. The example&#8217;s eight-digit suffix filter excludes those staging tables. Intraday data arrives quickly but can have gaps; it is not a final copy of the day. Attribution fields can also be incomplete.<\/p>\n<p>A query combining daily and intraday data needs an explicit choice for each date: the available completed daily table, or a provisional intraday table where no suitable daily table is available. \u201cDaily until yesterday, intraday only today\u201d can miss yesterday if its daily export is delayed. A bare UNION ALL of two overlapping wildcards can count the same events twice. A union with genuinely disjoint table selections is valid.<\/p>\n<h2>Why a correct query can still differ from GA4<\/h2>\n<p>GA4 estimates session counts using HyperLogLog++, an algorithm for counting many distinct keys with less memory. COUNT(DISTINCT) can count exported keys exactly; BigQuery also offers approximate functions. Google&#8217;s published session precision is 12. The Cloud table gives approximately \u00b13.25 percent for the 95 percent confidence interval at that precision, not \u00b11.63 percent. This statistical interval is not a guarantee that any UI-versus-export comparison falls inside it.<\/p>\n<p>Reports and exports can also differ because of modeling, report filters, identity settings and missing data. Cookieless events can appear in the raw export, but the modeled additions used in reports are not exported. Counting session_start rows is a separate operation from counting distinct session keys; the two must not be declared identical without checking the data.<\/p>\n<div class=\"lw-faq\"><h2>Questions and answers<\/h2><h3>Is a daily count always wrong?<\/h3><p>No. It can correctly describe sessions with activity on that day. The mistake is adding those daily counts and presenting the sum as unique sessions across the whole period. The sum can equal the period count when no key appears on more than one day.<\/p><h3>Must every query read the previous day?<\/h3><p>No. A count of keys observed today does not require yesterday. A reconstruction from the earliest observed row needs enough earlier data, while a trusted timestamp-based session ID can supply the start date without that lookup. The question and the available evidence determine the required range.<\/p><h3>Should a Wednesday purchase move to Tuesday?<\/h3><p>Not in a report about when purchases occurred. Tuesday can be the session&#8217;s start date while the purchase remains a Wednesday event. Assigning all events to the start day creates a different analysis and needs an explicit label.<\/p><\/div>\n<div class=\"lw-quellen\"><h2>Sources<\/h2><ul><li><a href=\"https:\/\/support.google.com\/analytics\/answer\/7029846?hl=en\" target=\"_blank\" rel=\"noopener noreferrer\">Google Analytics: BigQuery Export schema<\/a><\/li><li><a href=\"https:\/\/support.google.com\/analytics\/answer\/9191807?hl=en\" target=\"_blank\" rel=\"noopener noreferrer\">Google Analytics: About Analytics sessions<\/a><\/li><li><a href=\"https:\/\/support.google.com\/analytics\/answer\/9358801?hl=en\" target=\"_blank\" rel=\"noopener noreferrer\">Google Analytics: BigQuery Export and table updates<\/a><\/li><li><a href=\"https:\/\/developers.google.com\/analytics\/blog\/2022\/hll\" target=\"_blank\" rel=\"noopener noreferrer\">Google Analytics: Unique count approximation<\/a><\/li><li><a href=\"https:\/\/docs.cloud.google.com\/bigquery\/docs\/sketches\" target=\"_blank\" rel=\"noopener noreferrer\">Google Cloud: HLL++ sketches and confidence intervals<\/a><\/li><li><a href=\"https:\/\/docs.cloud.google.com\/bigquery\/docs\/querying-wildcard-tables\" target=\"_blank\" rel=\"noopener noreferrer\">Google Cloud: Query multiple tables using a wildcard<\/a><\/li><li><a href=\"https:\/\/docs.cloud.google.com\/bigquery\/docs\/reference\/standard-sql\/date_functions\" target=\"_blank\" rel=\"noopener noreferrer\">Google Cloud: Date functions<\/a><\/li><li><a href=\"https:\/\/docs.cloud.google.com\/bigquery\/docs\/reference\/standard-sql\/timestamp_functions\" target=\"_blank\" rel=\"noopener noreferrer\">Google Cloud: Timestamp functions<\/a><\/li><li><a href=\"https:\/\/developers.google.com\/analytics\/bigquery\/basic-queries\" target=\"_blank\" rel=\"noopener noreferrer\">Google Analytics: Basic queries for event export<\/a><\/li><\/ul><\/div>\n","protected":false},"excerpt":{"rendered":"<p>A visit can continue across midnight while its events appear in two BigQuery tables. Daily activity counts and distinct sessions answer different questions. A SQL example separates observed sessions from session starts.<\/p>\n","protected":false},"author":1,"featured_media":29668,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[91333,91297,91258,91252],"class_list":["post-15908","post","type-post","status-publish","format-standard","hentry","category-digital-analytics","tag-bigquery","tag-data-quality","tag-google-analytics-4","tag-web-analytics"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>GA4 BigQuery Export: Sessions That Cross Midnight Land in Two Tables | Lukas Wojcik<\/title>\n<meta name=\"description\" content=\"How the GA4 BigQuery export splits sessions crossing midnight into two tables, and the SQL window function that restores the correct count.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"GA4 BigQuery Export: Sessions That Cross Midnight Land in Two Tables | Lukas Wojcik\" \/>\n<meta property=\"og:description\" content=\"How the GA4 BigQuery export splits sessions crossing midnight into two tables, and the SQL window function that restores the correct count.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/\" \/>\n<meta property=\"og:site_name\" content=\"Lukas Wojcik - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-24T13:58:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/11\/flux-voll-15908-15908.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Lukas Wojcik\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Lukas Wojcik\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/digital-analytics\\\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/digital-analytics\\\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\\\/\"},\"author\":{\"name\":\"Lukas Wojcik\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#\\\/schema\\\/person\\\/895f7604f9b6b71aad9bba33af28d0f9\"},\"headline\":\"GA4 BigQuery Export: Sessions That Cross Midnight Land in Two Tables\",\"datePublished\":\"2026-11-24T13:58:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/digital-analytics\\\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\\\/\"},\"wordCount\":1200,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#\\\/schema\\\/person\\\/895f7604f9b6b71aad9bba33af28d0f9\"},\"image\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/digital-analytics\\\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/flux-voll-15908-15908.png\",\"keywords\":[\"BigQuery\",\"Data Quality\",\"Google Analytics 4\",\"Web Analytics\"],\"articleSection\":[\"Digital Analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/digital-analytics\\\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/digital-analytics\\\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\\\/\",\"url\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/digital-analytics\\\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\\\/\",\"name\":\"GA4 BigQuery Export: Sessions That Cross Midnight Land in Two Tables | Lukas Wojcik\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/digital-analytics\\\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/digital-analytics\\\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/flux-voll-15908-15908.png\",\"datePublished\":\"2026-11-24T13:58:00+00:00\",\"description\":\"How the GA4 BigQuery export splits sessions crossing midnight into two tables, and the SQL window function that restores the correct count.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/digital-analytics\\\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/digital-analytics\\\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/digital-analytics\\\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/flux-voll-15908-15908.png\",\"contentUrl\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/flux-voll-15908-15908.png\",\"width\":1200,\"height\":630,\"caption\":\"GA4 BigQuery Export: Sessions That Cross Midnight Land in Two Tables\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/digital-analytics\\\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/de\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"GA4 BigQuery Export: Sessions That Cross Midnight Land in Two Tables\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/\",\"name\":\"Lukas Wojcik - Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#\\\/schema\\\/person\\\/895f7604f9b6b71aad9bba33af28d0f9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#\\\/schema\\\/person\\\/895f7604f9b6b71aad9bba33af28d0f9\",\"name\":\"Lukas Wojcik\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/lw-x2.jpg\",\"url\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/lw-x2.jpg\",\"contentUrl\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/lw-x2.jpg\",\"width\":424,\"height\":636,\"caption\":\"Lukas Wojcik\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/lw-x2.jpg\"},\"sameAs\":[\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"GA4 BigQuery Export: Sessions That Cross Midnight Land in Two Tables | Lukas Wojcik","description":"How the GA4 BigQuery export splits sessions crossing midnight into two tables, and the SQL window function that restores the correct count.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/","og_locale":"en_US","og_type":"article","og_title":"GA4 BigQuery Export: Sessions That Cross Midnight Land in Two Tables | Lukas Wojcik","og_description":"How the GA4 BigQuery export splits sessions crossing midnight into two tables, and the SQL window function that restores the correct count.","og_url":"https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/","og_site_name":"Lukas Wojcik - Blog","article_published_time":"2026-11-24T13:58:00+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/11\/flux-voll-15908-15908.png","type":"image\/png"}],"author":"Lukas Wojcik","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Lukas Wojcik","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/#article","isPartOf":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/"},"author":{"name":"Lukas Wojcik","@id":"https:\/\/www.lukaswojcik.com\/blog\/#\/schema\/person\/895f7604f9b6b71aad9bba33af28d0f9"},"headline":"GA4 BigQuery Export: Sessions That Cross Midnight Land in Two Tables","datePublished":"2026-11-24T13:58:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/"},"wordCount":1200,"commentCount":0,"publisher":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/#\/schema\/person\/895f7604f9b6b71aad9bba33af28d0f9"},"image":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/#primaryimage"},"thumbnailUrl":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/11\/flux-voll-15908-15908.png","keywords":["BigQuery","Data Quality","Google Analytics 4","Web Analytics"],"articleSection":["Digital Analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/","url":"https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/","name":"GA4 BigQuery Export: Sessions That Cross Midnight Land in Two Tables | Lukas Wojcik","isPartOf":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/#primaryimage"},"image":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/#primaryimage"},"thumbnailUrl":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/11\/flux-voll-15908-15908.png","datePublished":"2026-11-24T13:58:00+00:00","description":"How the GA4 BigQuery export splits sessions crossing midnight into two tables, and the SQL window function that restores the correct count.","breadcrumb":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/#primaryimage","url":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/11\/flux-voll-15908-15908.png","contentUrl":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/11\/flux-voll-15908-15908.png","width":1200,"height":630,"caption":"GA4 BigQuery Export: Sessions That Cross Midnight Land in Two Tables"},{"@type":"BreadcrumbList","@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/digital-analytics\/ga4-bigquery-export-sessions-that-cross-midnight-land-in-two-tables\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.lukaswojcik.com\/blog\/de\/"},{"@type":"ListItem","position":2,"name":"GA4 BigQuery Export: Sessions That Cross Midnight Land in Two Tables"}]},{"@type":"WebSite","@id":"https:\/\/www.lukaswojcik.com\/blog\/#website","url":"https:\/\/www.lukaswojcik.com\/blog\/","name":"Lukas Wojcik - Blog","description":"","publisher":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/#\/schema\/person\/895f7604f9b6b71aad9bba33af28d0f9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.lukaswojcik.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.lukaswojcik.com\/blog\/#\/schema\/person\/895f7604f9b6b71aad9bba33af28d0f9","name":"Lukas Wojcik","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/07\/lw-x2.jpg","url":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/07\/lw-x2.jpg","contentUrl":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/07\/lw-x2.jpg","width":424,"height":636,"caption":"Lukas Wojcik"},"logo":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/07\/lw-x2.jpg"},"sameAs":["https:\/\/www.lukaswojcik.com\/blog"]}]}},"_links":{"self":[{"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/posts\/15908","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/comments?post=15908"}],"version-history":[{"count":7,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/posts\/15908\/revisions"}],"predecessor-version":[{"id":25051,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/posts\/15908\/revisions\/25051"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/media\/29668"}],"wp:attachment":[{"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/media?parent=15908"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/categories?post=15908"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/tags?post=15908"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}