{"id":20455201,"url":"https://github.com/timuric/google-analytics-cookbook","last_synced_at":"2026-03-06T18:32:23.835Z","repository":{"id":262719555,"uuid":"888138213","full_name":"timuric/google-analytics-cookbook","owner":"timuric","description":"Recipes for Google analytics 4 with BigQuery","archived":false,"fork":false,"pushed_at":"2024-11-15T11:09:15.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T10:19:45.401Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timuric.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-13T22:04:43.000Z","updated_at":"2024-11-19T19:22:28.000Z","dependencies_parsed_at":"2024-11-14T18:38:18.535Z","dependency_job_id":null,"html_url":"https://github.com/timuric/google-analytics-cookbook","commit_stats":null,"previous_names":["timuric/ga-bigquery-cheatsheet","timuric/google-analytics-cookbook"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/timuric/google-analytics-cookbook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timuric%2Fgoogle-analytics-cookbook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timuric%2Fgoogle-analytics-cookbook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timuric%2Fgoogle-analytics-cookbook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timuric%2Fgoogle-analytics-cookbook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timuric","download_url":"https://codeload.github.com/timuric/google-analytics-cookbook/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timuric%2Fgoogle-analytics-cookbook/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30190819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T18:30:16.692Z","status":"ssl_error","status_checked_at":"2026-03-06T18:30:13.818Z","response_time":250,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T11:18:13.264Z","updated_at":"2026-03-06T18:32:23.804Z","avatar_url":"https://github.com/timuric.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Analytics Cookbook for BigQuery\nCheat sheet for Bigquery using Google Analytics dataset\n\n### Table of contents\n- [Working with dates](#working-with-dates)\n- [Data Quality Check](#data-quality-check)\n  - [Events](#events)\n  - [Ecommerce](#ecommerce)\n  - [User](#user)\n  - [Items](#items)\n  - [Traffic Source](#traffic-source)\n  - [Device](#device)\n  - [Geo](#geo)\n- [Funnel Analysis](#funnel-analysis)\n  - [Checkout by Device](#checkout-by-device)\n  - [Checkout by Item Quantity](#checkout-by-item-quantity)\n  - [Checkout by Basket Size](#checkout-by-basket-size)\n\n## Working with dates\n\nRelative date range:\n\n```sql\nFROM `project.analytics_123.events_*`\nWHERE regexp_extract(_table_suffix, '[0-9]+') BETWEEN format_date('%Y%m%d', current_date() - 30) AND format_date('%Y%m%d', current_date())\n```\n\nToday:\n\n```sql\nFROM `project.analytics_123.events_*`\nWHERE regexp_extract(_table_suffix,'[0-9]+') = format_date('%Y%m%d', current_date())\n```\n\n## Data Quality Check\n\n### Null Checks\n\nItems:\n\n```sql\nselect \nevent_name,\nCOUNT(*) as event_count,\nROUND(COUNTIF(items.item_id IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_item_id,\nROUND(COUNTIF(items.item_name IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_item_name,\nROUND(COUNTIF(items.item_brand IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_item_brand,\nROUND(COUNTIF(items.item_variant IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_item_variant,\nROUND(COUNTIF(items.item_category IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_item_category,\nROUND(COUNTIF(items.item_category2 IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_item_category2,\nROUND(COUNTIF(items.item_category3 IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_item_category3,\nROUND(COUNTIF(items.item_category4 IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_item_category4,\nROUND(COUNTIF(items.item_category5 IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_item_category5,\nROUND(COUNTIF(items.price_in_usd IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_price_in_usd,\nROUND(COUNTIF(items.price IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_price,\nROUND(COUNTIF(items.quantity IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_quantity,\nROUND(COUNTIF(items.item_revenue_in_usd IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_item_revenue_in_usd,\nROUND(COUNTIF(items.item_revenue IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_item_revenue,\nROUND(COUNTIF(items.item_refund_in_usd IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_item_refund_in_usd,\nROUND(COUNTIF(items.item_refund IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_item_refund,\nROUND(COUNTIF(items.coupon IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_coupon,\nROUND(COUNTIF(items.affiliation IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_affiliation,\nROUND(COUNTIF(items.location_id IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_location_id,\nROUND(COUNTIF(items.item_list_id IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_item_list_id,\nROUND(COUNTIF(items.item_list_name IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_item_list_name,\nROUND(COUNTIF(items.item_list_index IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_item_list_index,\nROUND(COUNTIF(items.promotion_id IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_promotion_id,\nROUND(COUNTIF(items.promotion_name IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_promotion_name,\nROUND(COUNTIF(items.creative_name IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_creative_name,\nROUND(COUNTIF(items.creative_slot IS NOT NULL) / COUNT(*) * 100.0,2 ) as items_creative_slot\nFROM `project.analytics_123.events_*`\n  UNNEST(items) AS items\nWHERE\n  regexp_extract(_table_suffix, '[0-9]+') BETWEEN format_date('%Y%m%d', current_date() - 1) AND format_date('%Y%m%d', current_date())\n  group by event_name\nORDER BY 1\nLIMIT 100\n```\n\nEcommerce:\n\n```sql\nselect \nevent_name,\nCOUNT(*) as event_count,\nROUND(COUNTIF(ecommerce.total_item_quantity IS NOT NULL) / COUNT(*) * 100.0, 2) AS ecommerce_total_item_quantity,\nROUND(COUNTIF(ecommerce.purchase_revenue_in_usd IS NOT NULL) / COUNT(*) * 100.0, 2) AS ecommerce_purchase_revenue_in_usd,\nROUND(COUNTIF(ecommerce.purchase_revenue IS NOT NULL) / COUNT(*) * 100.0, 2) AS ecommerce_purchase_revenue,\nROUND(COUNTIF(ecommerce.refund_value_in_usd IS NOT NULL) / COUNT(*) * 100.0, 2) AS ecommerce_refund_value_in_usd,\nROUND(COUNTIF(ecommerce.refund_value IS NOT NULL) / COUNT(*) * 100.0, 2) AS ecommerce_refund_value,\nROUND(COUNTIF(ecommerce.shipping_value_in_usd IS NOT NULL) / COUNT(*) * 100.0, 2) AS ecommerce_shipping_value_in_usd,\nROUND(COUNTIF(ecommerce.shipping_value IS NOT NULL) / COUNT(*) * 100.0, 2) AS ecommerce_shipping_value,\nROUND(COUNTIF(ecommerce.tax_value_in_usd IS NOT NULL) / COUNT(*) * 100.0, 2) AS ecommerce_tax_value_in_usd,\nROUND(COUNTIF(ecommerce.tax_value IS NOT NULL) / COUNT(*) * 100.0, 2) AS ecommerce_value,\nROUND(COUNTIF(ecommerce.transaction_id IS NOT NULL) / COUNT(*) * 100.0, 2) AS ecommerce_transaction_id,\nROUND(COUNTIF(ecommerce.unique_items IS NOT NULL) / COUNT(*) * 100.0, 2) AS ecommerce_unique_items,\nFROM `project.analytics_123.events_*`\nWHERE\n  regexp_extract(_table_suffix, '[0-9]+') BETWEEN format_date('%Y%m%d', current_date() - 1) AND format_date('%Y%m%d', current_date())\n  group by event_name\nORDER BY 1\nLIMIT 100\n```\n\nUser:\n\n```sql\nSELECT \nevent_name,\nCOUNT(*) as event_count,\nROUND(COUNTIF(is_active_user IS NULL) / COUNT(*) * 100.0, 2) AS is_active_user,\nROUND(COUNTIF(user_id IS NULL) / COUNT(*) * 100.0, 2) AS user_id,\nROUND(COUNTIF(user_pseudo_id IS NULL) / COUNT(*) * 100.0, 2) AS user_pseudo_id,\nROUND(COUNTIF(user_first_touch_timestamp IS NULL) / COUNT(*) * 100.0, 2) AS user_first_touch_timestamp,\nFROM `project.analytics_123.events_*`\nWHERE\n  regexp_extract(_table_suffix, '[0-9]+') BETWEEN format_date('%Y%m%d', current_date() - 1) AND format_date('%Y%m%d', current_date())\n  group by event_name\norder by 1\nlimit 100\n```\n\nEvents:\n\n```sql\nSELECT \nevent_name,\nCOUNT(*) as event_count,\nROUND(COUNTIF(event_params.value.double_value IS NULL) / COUNT(*) * 100.0, 2) AS events_value_double_value,\nROUND(COUNTIF(event_timestamp IS NULL) / COUNT(*) * 100.0, 2) AS event_timestamp,\nROUND(COUNTIF(event_date IS NULL) / COUNT(*) * 100.0, 2) AS event_date,\nROUND(COUNTIF(event_value_in_usd IS NULL) / COUNT(*) * 100.0, 2) AS event_event_value_in_usd,\nROUND(COUNTIF(event_server_timestamp_offset IS NULL) / COUNT(*) * 100.0, 2) AS event_server_timestamp_offset,\nROUND(COUNTIF(event_params.key IS NULL) / COUNT(*) * 100.0, 2) AS event_params_key,\nROUND(COUNTIF(event_params.value IS NULL) / COUNT(*) * 100.0, 2) AS event_params_value,\nROUND(COUNTIF(event_params.value.string_value IS NULL) / COUNT(*) * 100.0, 2) AS event_params_value_string_value,\nROUND(COUNTIF(event_params.value.int_value IS NULL) / COUNT(*) * 100.0, 2) AS event_params_value_int_value,\nROUND(COUNTIF(event_params.value.double_value IS NULL) / COUNT(*) * 100.0, 2) AS event_params_value_double_value,\nROUND(COUNTIF(event_params.value.float_value IS NULL) / COUNT(*) * 100.0, 2) AS event_params_value_float_value,\nFROM `project.analytics_123.events_*`\nUNNEST(event_params) as event_params\nWHERE\n  regexp_extract(_table_suffix, '[0-9]+') BETWEEN format_date('%Y%m%d', current_date() - 1) AND format_date('%Y%m%d', current_date())\n  group by event_name\norder by 1\nlimit 100\n```\n\nGeo:\n\n```sql\nselect \nevent_name,\nCOUNT(*) as event_count,\nROUND(COUNTIF(geo.continent IS NOT NULL) / COUNT(*) * 100.0, 2) AS geo_continent,\nROUND(COUNTIF(geo.country IS NOT NULL) / COUNT(*) * 100.0, 2) AS geo_country,\nROUND(COUNTIF(geo.region IS NOT NULL) / COUNT(*) * 100.0, 2) AS geo_region,\nROUND(COUNTIF(geo.sub_continent IS NOT NULL) / COUNT(*) * 100.0, 2) AS geo_sub_continent,\nROUND(COUNTIF(geo.metro IS NOT NULL) / COUNT(*) * 100.0, 2) AS geo_metro,\nFROM `project.analytics_123.events_*`\nWHERE\n  regexp_extract(_table_suffix, '[0-9]+') BETWEEN format_date('%Y%m%d', current_date() - 1) AND format_date('%Y%m%d', current_date())\n  group by event_name\norder by 1\nlimit 100\n```\n\nTraffic source:\n\n```sql\nselect \nevent_name,\nCOUNT(*) as event_count,\nROUND(COUNTIF(traffic_source.name IS NOT NULL) / COUNT(*) * 100.0, 2) AS traffic_source_name,\nROUND(COUNTIF(traffic_source.medium IS NOT NULL) / COUNT(*) * 100.0, 2) AS traffic_source_medium,\nROUND(COUNTIF(traffic_source.source IS NOT NULL) / COUNT(*) * 100.0, 2) AS traffic_source_source,\nFROM `project.analytics_123.events_*`\nWHERE\n  regexp_extract(_table_suffix, '[0-9]+') BETWEEN format_date('%Y%m%d', current_date() - 1) AND format_date('%Y%m%d', current_date())\n  group by event_name\norder by 1\nlimit 100\n```\n\nDevice:\n\n```sql\nselect \nevent_name,\nCOUNT(*) as event_count,\nROUND(COUNTIF(device.operating_system IS NOT NULL) / COUNT(*) * 100.0, 2) AS device_operating_system,\nROUND(COUNTIF(device.mobile_brand_name IS NOT NULL) / COUNT(*) * 100.0, 2) AS device_mobile_brand_name,\nROUND(COUNTIF(device.mobile_model_name IS NOT NULL) / COUNT(*) * 100.0, 2) AS device_mobile_model_name,\nROUND(COUNTIF(device.mobile_marketing_name IS NOT NULL) / COUNT(*) * 100.0, 2) AS device_mobile_marketing_name,\nROUND(COUNTIF(device.mobile_os_hardware_model IS NOT NULL) / COUNT(*) * 100.0, 2) AS device_mobile_os_hardware_model,\nROUND(COUNTIF(device.advertising_id IS NOT NULL) / COUNT(*) * 100.0, 2) AS device_advertising_id,\nROUND(COUNTIF(device.browser IS NOT NULL) / COUNT(*) * 100.0, 2) AS device_browser,\nROUND(COUNTIF(device.browser_version IS NOT NULL) / COUNT(*) * 100.0, 2) AS device_browser_version,\nROUND(COUNTIF(device.is_limited_ad_tracking IS NOT NULL) / COUNT(*) * 100.0, 2) AS device_is_limited_ad_tracking\nFROM `project.analytics_123.events_*`\nWHERE\n  regexp_extract(_table_suffix, '[0-9]+') BETWEEN format_date('%Y%m%d', current_date() - 1) AND format_date('%Y%m%d', current_date())\n  group by event_name\norder by 1\nlimit 100\n```\n### Funnel Analysis\n\n#### Checkout by Device\n```sql\nSELECT\n    device.category,\n    count(DISTINCT CASE\n      WHEN event_name = 'minicart_click' THEN user_pseudo_id\n      ELSE NULL\n    END) AS minicart_click,\n    count(DISTINCT CASE\n      WHEN event_name = 'begin_checkout' THEN user_pseudo_id\n      ELSE NULL\n    END) AS begin_checkout,\n    count(DISTINCT CASE\n      WHEN event_name = 'add_shipping_info' THEN user_pseudo_id\n      ELSE NULL\n    END) AS add_shipping_info,\n    count(DISTINCT CASE\n      WHEN event_name = 'add_payment_info' THEN user_pseudo_id\n      ELSE NULL\n    END) AS add_payment_info,\n    count(DISTINCT CASE\n      WHEN event_name = 'purchase' THEN user_pseudo_id\n      ELSE NULL\n    END) AS purchase,\n    ROUND((count(DISTINCT CASE\n      WHEN event_name = 'begin_checkout' THEN user_pseudo_id\n      ELSE NULL\n    END) / count(DISTINCT CASE\n      WHEN event_name = 'minicart_click' THEN user_pseudo_id\n      ELSE NULL\n    END)) * 100, 2) AS begin_checkout_percentage,\n    ROUND((count(DISTINCT CASE\n      WHEN event_name = 'add_shipping_info' THEN user_pseudo_id\n      ELSE NULL\n    END) / count(DISTINCT CASE\n      WHEN event_name = 'begin_checkout' THEN user_pseudo_id\n      ELSE NULL\n    END)) * 100, 2) AS add_shipping_info_percentage,\n    ROUND((count(DISTINCT CASE\n      WHEN event_name = 'add_payment_info' THEN user_pseudo_id\n      ELSE NULL\n    END) / count(DISTINCT CASE\n      WHEN event_name = 'add_shipping_info' THEN user_pseudo_id\n      ELSE NULL\n    END)) * 100, 2) AS add_payment_info_percentage,\n    ROUND((count(DISTINCT CASE\n      WHEN event_name = 'purchase' THEN user_pseudo_id\n      ELSE NULL\n    END) / count(DISTINCT CASE\n      WHEN event_name = 'add_payment_info' THEN user_pseudo_id\n      ELSE NULL\n    END)) * 100, 2) AS purchase_percentage\n  FROM `project.analytics_123.events_*`\n  WHERE regexp_extract(_table_suffix, '[0-9]+') BETWEEN format_date('%Y%m%d', current_date() - 30) AND format_date('%Y%m%d', current_date())\n  and user_pseudo_id is not null\n  and event_name IN(\n    'minicart_click', 'begin_checkout', 'add_shipping_info', 'add_payment_info', 'purchase'\n  )\n  and device.category in ('mobile', 'desktop','tablet')\n  group by device.category;\n```\n\n#### Checkout by Item Quantity\n```sql\nwith t as (\nSELECT\n  CASE\n    WHEN ecommerce.total_item_quantity \u003c 200 THEN '01. 0-200'\n    WHEN ecommerce.total_item_quantity BETWEEN 200 AND 399 THEN '02. 200-400'\n    WHEN ecommerce.total_item_quantity BETWEEN 400 AND 599 THEN '03. 400-600'\n    WHEN ecommerce.total_item_quantity BETWEEN 600 AND 799 THEN '04. 600-800'\n    WHEN ecommerce.total_item_quantity BETWEEN 800 AND 999 THEN '05. 800-1000'\n    WHEN ecommerce.total_item_quantity BETWEEN 1000 AND 1199 THEN '06. 1000-1200'\n    WHEN ecommerce.total_item_quantity BETWEEN 1200 AND 1399 THEN '07. 1200-1400'\n    WHEN ecommerce.total_item_quantity BETWEEN 1400 AND 1599 THEN '08. 1400-1600'\n    WHEN ecommerce.total_item_quantity BETWEEN 1600 AND 1799 THEN '09. 1600-1800'\n    WHEN events.value.double_value BETWEEN 1800 AND 1999 THEN '10. 1800-2000'\n    ELSE '11. 2000-...'\n  END AS bins,\n  count(DISTINCT CASE\n    WHEN event_name = 'begin_checkout' THEN user_pseudo_id\n    ELSE NULL\n  END) AS begin_checkout,\n  count(DISTINCT CASE\n    WHEN event_name = 'add_shipping_info' THEN user_pseudo_id\n    ELSE NULL\n  END) AS add_shipping_info,\n  count(DISTINCT CASE\n    WHEN event_name = 'add_payment_info' THEN user_pseudo_id\n    ELSE NULL\n  END) AS add_payment_info,\n  count(DISTINCT CASE\n    WHEN event_name = 'purchase' THEN user_pseudo_id\n    ELSE NULL\n  END) AS purchase\nFROM\n  FROM `project.analytics_123.events_*`\n  UNNEST(event_params) AS events\nWHERE\n  regexp_extract(_table_suffix, '[0-9]+') BETWEEN format_date('%Y%m%d', current_date() - 1) AND format_date('%Y%m%d', current_date())\n  AND user_pseudo_id IS NOT NULL\n  AND (\n    event_name = 'begin_checkout'\n    AND events.value.double_value IS NOT NULL\n  )\n  OR event_name IN(\n    'begin_checkout',\n    'add_shipping_info',\n    'add_payment_info',\n    'purchase'\n  )\nGROUP BY\n  1\norder by 1\n)\nselect *,\n  round((begin_checkout - add_shipping_info) / begin_checkout * 100, 2) as checkout_to_shipping_drop,\n  round((add_shipping_info - add_payment_info) / add_shipping_info * 100, 2) as shipping_to_payment_drop,\n  round((add_payment_info - purchase) / add_payment_info * 100, 2) as payment_to_purchase_drop\nfrom `t`;\n```\n\n#### Checkout by Basket Size\n```sql\nwith t as (\nSELECT\n  CASE\n    WHEN events.value.double_value \u003c 200 THEN '01. 0-200'\n    WHEN events.value.double_value BETWEEN 200 AND 399 THEN '02. 200-400'\n    WHEN events.value.double_value BETWEEN 400 AND 599 THEN '03. 400-600'\n    WHEN events.value.double_value BETWEEN 600 AND 799 THEN '04. 600-800'\n    WHEN events.value.double_value BETWEEN 800 AND 999 THEN '05. 800-1000'\n    WHEN events.value.double_value BETWEEN 1000 AND 1199 THEN '06. 1000-1200'\n    WHEN events.value.double_value BETWEEN 1200 AND 1399 THEN '07. 1200-1400'\n    WHEN events.value.double_value BETWEEN 1400 AND 1599 THEN '08. 1400-1600'\n    WHEN events.value.double_value BETWEEN 1600 AND 1799 THEN '09. 1600-1800'\n    WHEN events.value.double_value BETWEEN 1800 AND 1999 THEN '10. 1800-2000'\n    ELSE '11. 2000-...'\n  END AS bins,\n  count(DISTINCT CASE\n    WHEN event_name = 'begin_checkout' THEN user_pseudo_id\n    ELSE NULL\n  END) AS begin_checkout,\n  count(DISTINCT CASE\n    WHEN event_name = 'add_shipping_info' THEN user_pseudo_id\n    ELSE NULL\n  END) AS add_shipping_info,\n  count(DISTINCT CASE\n    WHEN event_name = 'add_payment_info' THEN user_pseudo_id\n    ELSE NULL\n  END) AS add_payment_info,\n  count(DISTINCT CASE\n    WHEN event_name = 'purchase' THEN user_pseudo_id\n    ELSE NULL\n  END) AS purchase\nFROM `project.analytics_123.events_*`\n  UNNEST(event_params) AS events\nWHERE\n  regexp_extract(_table_suffix, '[0-9]+') BETWEEN format_date('%Y%m%d', current_date() - 1) AND format_date('%Y%m%d', current_date())\n  AND user_pseudo_id IS NOT NULL\n  AND (\n    event_name = 'begin_checkout'\n    AND events.value.double_value IS NOT NULL\n  )\n  OR event_name IN(\n    'begin_checkout',\n    'add_shipping_info',\n    'add_payment_info',\n    'purchase'\n  )\nGROUP BY\n  1\norder by 1\n)\nselect *,\n  round((begin_checkout - add_shipping_info) / begin_checkout * 100, 2) as checkout_to_shipping_drop,\n  round((add_shipping_info - add_payment_info) / add_shipping_info * 100, 2) as shipping_to_payment_drop,\n  round((add_payment_info - purchase) / add_payment_info * 100, 2) as payment_to_purchase_drop\nfrom `t`;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimuric%2Fgoogle-analytics-cookbook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimuric%2Fgoogle-analytics-cookbook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimuric%2Fgoogle-analytics-cookbook/lists"}