Modelado de datos en BigQuery

Опубликовано: 12 Январь 2025
на канале: MIDE y VENCERÁS
483
28

¿Te preguntas cómo puedes obtener una visión completa de los usuarios de tu negocio, incluso cuando algunos no han dado su consentimiento? En este video, te cuento cómo Google BigQuery nos permite modelar datos de manera ética y responsable para estimar el total de usuarios sin comprometer la privacidad.

Te guiaré paso a paso por el proceso, explicando técnicas sencillas y efectivas para aprovechar datos disponibles y obtener insights precisos sobre el alcance real de tu negocio. ¡Es como ver el cuadro completo cuando antes solo veías una parte! Con estos métodos, podrás tomar decisiones más informadas, optimizar tus campañas y comprender mejor el comportamiento de tus clientes, todo sin violar ninguna regulación de privacidad.

Si buscas entender mejor a tus usuarios y maximizar el potencial de tus datos, ¡este video es para ti! 👇



Paso 1 – calculate consented users and sessions

WITH consented_data AS (
SELECT
PARSE_DATE('%Y%m%d', event_date) AS event_date,
COUNT(DISTINCT user_pseudo_id) AS users,
COUNT(DISTINCT CONCAT(user_pseudo_id, (SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id'))) AS sessions,
COUNTIF(event_name = 'page_view') AS views,
ROUND(COUNTIF(event_name = 'page_view') / COUNT(DISTINCT user_pseudo_id), 2) AS views_per_user,
ROUND(COUNTIF(event_name = 'page_view') / COUNT(DISTINCT CONCAT(user_pseudo_id, (SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id'))), 2) AS views_per_session
FROM `ga-new-mesurement.analytics_236829189.events_*`
WHERE privacy_info.analytics_storage = 'Yes'
GROUP BY 1
)
SELECT *
FROM consented_data;


Paso 2 – calculate unconsented views

with unconsented_data AS (
SELECT
PARSE_DATE('%Y%m%d', event_date) AS event_date,
COUNTIF(event_name = 'page_view') AS views
FROM `ga-new-mesurement.analytics_236829189.events_*`
WHERE privacy_info.analytics_storage = 'No'
GROUP BY 1
)
SELECT *
FROM unconsented_data;

Paso 3 – estimate unconsented users and sessions

SELECT
c.event_date,
c.users + ROUND(u.views/c.views_per_user, 0) AS total_users,
c.sessions + ROUND(u.views/c.views_per_session, 0) AS total_sessions,
c.views + u.views AS total_views
FROM `ga-new-mesurement.analytics_236829189.consented_data` c
LEFT JOIN `ga-new-mesurement.analytics_236829189.unconsented_data` u ON c.event_date = u.event_date
ORDER BY 1