Skip to content

Instantly share code, notes, and snippets.

@enternu
enternu / sql_data_viz.sql
Created March 28, 2025 14:24 — forked from zjuul/sql_data_viz.sql
Data visualisation in SQL
-- this query outputs a data visualisation to explore how many unique products people
-- see on your website, and the conversion rate
-- it uses Big Query SQL on a GA4Dataform events table - check https://github.com/superformlabs/ga4dataform-community
with products_per_user as (
SELECT
user_pseudo_id,
count( distinct if(event_name = 'view_item', i.item_name, NULL) ) as n_items_viewed,
max( if(event_name = 'purchase', 1, 0)) as purchaser