Advertisement
festinko

Untitled

Sep 28th, 2022
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.51 KB | None | 0 0
  1. WITH
  2.  
  3.  ---added user_id compared to the query from
  4.         flat_user_properties AS (
  5.         select
  6.             user_pseudo_id,
  7.             event_timestamp,
  8.             event_name,
  9.             user_id,
  10.             user_properties.key,
  11.             user_properties.value.string_value,
  12.             user_properties.value.int_value,
  13.             user_properties.value.float_value,
  14.             user_properties.value.double_value,
  15.             user_properties.value.set_timestamp_micros,
  16.             concat(user_pseudo_id,event_timestamp,event_name,dedup_id) as join_key
  17.         from (
  18.             select
  19.                 row_number() over(partition by user_pseudo_id, event_timestamp, event_name) as dedup_id,
  20.                 *
  21.             from
  22.                 -- change this to your google analytics 4 export location in bigquery
  23.                 `uptimerobot-001.analytics_220800152.events_*`
  24.             where
  25.             -- define static and/or dynamic start and end date
  26.             _table_suffix between '20220805' and '20220927'),
  27.             unnest(user_properties) as user_properties
  28.             ),
  29.  
  30. /*list of users from GA4 completed G4 with ABTestVariant dimenssion*/
  31.  
  32. ABTest as
  33.     (SELECT
  34.           user_id,
  35.           event_name,
  36.           key,
  37.           string_value as ABTestVariant,
  38.           event_timestamp
  39.  
  40.       FROM
  41.           flat_user_properties
  42.       WHERE
  43.           key = "ABTest2"
  44.           AND event_name LIKE ("G4_First_Subscription_Paid")
  45.     )
  46.  
  47. SELECT
  48. *
  49. FROM ABTest
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement