From 76bcdf8c3653d3f1cb084059611991e7e0dc9597 Mon Sep 17 00:00:00 2001 From: Andres Gregori Altamirano Date: Mon, 6 May 2024 16:59:49 +0000 Subject: [PATCH] Version 3.0.0 (#19) --- dashboards/acquisition.dashboard.lookml | 4 +- dashboards/arima.dashboard.lookml | 563 ++++++++++++++++++ dashboards/audience.dashboard.lookml | 6 +- dashboards/avbb.dashboard.lookml | 457 ++++++++++++++ dashboards/behavior.dashboard.lookml | 4 +- dashboards/campaign_impact.dashboard.lookml | 2 +- .../custom_goal_conversions.dashboard.lookml | 2 +- dashboards/event_funnel.dashboard.lookml | 2 +- dashboards/overview.dashboard.lookml | 4 +- dashboards/page_funnel.dashboard.lookml | 2 +- ...performance_metrics_model.dashboard.lookml | 19 +- dashboards/propensity_model.dashboard.lookml | 52 +- explores/sessions.explore.lkml | 16 +- .../arima_event_model/forecasting.view.lkml | 62 ++ .../arima_event_model/model_arima.view.lkml | 55 ++ .../training_input_arima.view.lkml | 18 + views/bqml/avbb/training_data_avbb.view.lkml | 127 ++++ views/events.view.lkml | 1 + views/sessions/session_tags.view.lkml | 31 +- 19 files changed, 1366 insertions(+), 61 deletions(-) create mode 100644 dashboards/arima.dashboard.lookml create mode 100644 dashboards/avbb.dashboard.lookml create mode 100644 views/bqml/arima_event_model/forecasting.view.lkml create mode 100644 views/bqml/arima_event_model/model_arima.view.lkml create mode 100644 views/bqml/arima_event_model/training_input_arima.view.lkml create mode 100644 views/bqml/avbb/training_data_avbb.view.lkml diff --git a/dashboards/acquisition.dashboard.lookml b/dashboards/acquisition.dashboard.lookml index 6e032fa..be3b983 100644 --- a/dashboards/acquisition.dashboard.lookml +++ b/dashboards/acquisition.dashboard.lookml @@ -854,7 +854,7 @@ \ href=\"/dashboards-next/ga4::propensity_model\">\n\n\n\nPropensity Model\n\n" + >\n\nModels\n\n" row: 0 col: 0 width: 24 @@ -975,4 +975,4 @@ model: ga4 explore: sessions listens_to_filters: [] - field: attribution_sources.attribution_source_channel + field: attribution_sources.attribution_source_channel \ No newline at end of file diff --git a/dashboards/arima.dashboard.lookml b/dashboards/arima.dashboard.lookml new file mode 100644 index 0000000..773a72e --- /dev/null +++ b/dashboards/arima.dashboard.lookml @@ -0,0 +1,563 @@ +--- +- dashboard: arima + title: "[GA4] ARIMA Model" + layout: newspaper + preferred_viewer: dashboards-next + description: '' + preferred_slug: Earwwr3dvZ4OQPQZzyBlDn + elements: + - name: " box" + type: text + title_text: '' + subtitle_text: '' + body_text: "
\n\t
\n\t\t\n\t

\n\n
" + row: 0 + col: 0 + width: 24 + height: 4 + + - name: " (4)" + type: text + title_text: '' + subtitle_text: '' + body_text: "
\n\t
\n\n
" + row: 0 + col: 0 + width: 20 + height: 2 + + + + + - name: ARIMA Model + title: ARIMA Model + merged_queries: + - model: ga4 + explore: sessions + type: looker_line + fields: [forecasting.forecast_timestamp, forecasting.prediction_interval_lower_bound, + forecasting.forecast_value, forecasting.prediction_interval_upper_bound] + fill_fields: [forecasting.forecast_timestamp] + filters: + forecasting.events_event_name: '' + sorts: [forecasting.forecast_timestamp desc] + limit: 500 + column_limit: 50 + x_axis_gridlines: false + y_axis_gridlines: true + show_view_names: false + show_y_axis_labels: true + show_y_axis_ticks: true + y_axis_tick_density: default + y_axis_tick_density_custom: 5 + show_x_axis_label: true + show_x_axis_ticks: true + y_axis_scale_mode: linear + x_axis_reversed: false + y_axis_reversed: false + plot_size_by_field: false + trellis: '' + stacking: '' + limit_displayed_rows: false + legend_position: center + point_style: none + show_value_labels: false + label_density: 25 + x_axis_scale: auto + y_axis_combined: true + show_null_points: true + interpolation: linear + hidden_pivots: {} + show_row_numbers: true + transpose: false + truncate_text: true + hide_totals: false + hide_row_totals: false + size_to_fit: true + table_theme: white + enable_conditional_formatting: false + header_text_alignment: left + header_font_size: 12 + rows_font_size: 12 + conditional_formatting_include_totals: false + conditional_formatting_include_nulls: false + defaults_version: 1 + join_fields: [] + - model: ga4 + explore: sessions + type: looker_line + fields: [sum_of_session_event_count, events.event_time_date, sessions.total_sessions] + fill_fields: [events.event_time_date] + filters: + events.event_name: '' + sorts: [events.event_time_date desc] + limit: 500 + column_limit: 50 + dynamic_fields: + - measure: sum_of_session_event_count + based_on: sessions.session_data_session_event_count + expression: '' + label: Sum of Session Event Count + type: sum + _kind_hint: measure + _type_hint: number + x_axis_gridlines: false + y_axis_gridlines: true + show_view_names: false + show_y_axis_labels: true + show_y_axis_ticks: true + y_axis_tick_density: default + y_axis_tick_density_custom: 5 + show_x_axis_label: true + show_x_axis_ticks: true + y_axis_scale_mode: linear + x_axis_reversed: false + y_axis_reversed: false + plot_size_by_field: false + trellis: '' + stacking: '' + limit_displayed_rows: false + legend_position: center + point_style: none + show_value_labels: false + label_density: 25 + x_axis_scale: auto + y_axis_combined: true + show_null_points: true + interpolation: linear + x_axis_zoom: true + y_axis_zoom: true + swap_axes: false + hidden_pivots: {} + show_row_numbers: true + transpose: false + truncate_text: true + hide_totals: false + hide_row_totals: false + size_to_fit: true + table_theme: white + enable_conditional_formatting: false + header_text_alignment: left + header_font_size: 12 + rows_font_size: 12 + conditional_formatting_include_totals: false + conditional_formatting_include_nulls: false + defaults_version: 1 + hidden_fields: [sum_of_session_event_count] + join_fields: + - field_name: events.event_time_date + source_field_name: forecasting.forecast_timestamp + x_axis_gridlines: false + y_axis_gridlines: true + show_view_names: false + y_axes: [{label: '', orientation: left, series: [{axisId: sessions.total_sessions, + id: sessions.total_sessions, name: Sessions}, {axisId: forecasting.prediction_interval_lower_bound, + id: forecasting.prediction_interval_lower_bound, name: Prediction Interval + Lower Bound}, {axisId: forecasting.forecast_value, id: forecasting.forecast_value, + name: Forecast Value}, {axisId: forecasting.prediction_interval_upper_bound, + id: forecasting.prediction_interval_upper_bound, name: Prediction Interval + Upper Bound}], showLabels: true, showValues: true, maxValue: 200, unpinAxis: false, + tickDensity: default, type: linear}] + show_y_axis_labels: true + show_y_axis_ticks: true + y_axis_tick_density: default + y_axis_tick_density_custom: 5 + show_x_axis_label: true + show_x_axis_ticks: true + y_axis_scale_mode: linear + x_axis_reversed: false + y_axis_reversed: false + plot_size_by_field: false + x_axis_zoom: true + y_axis_zoom: true + trellis: '' + stacking: '' + limit_displayed_rows: false + legend_position: center + series_types: + forecasting.prediction_interval_upper_bound: area + forecasting.prediction_interval_lower_bound: area + point_style: none + series_colors: + forecasting.forecast_value: "#1A73E8" + show_value_labels: false + label_density: 25 + x_axis_scale: auto + y_axis_combined: true + show_null_points: false + interpolation: linear + type: looker_line + hidden_fields: [sum_of_session_event_count, forecasting.forecast_value, sessions.total_sessions] + dynamic_fields: + - category: table_calculation + expression: case(when(is_null(${sessions.total_sessions}),${forecasting.forecast_value}),${sessions.total_sessions}) + label: Real value and forecasted value + value_format: + value_format_name: + _kind_hint: measure + table_calculation: real_value_and_forecasted_value + _type_hint: number + listen: + - Event Name: forecasting.events_event_name + - Event Name: events.event_name + row: 6 + col: 0 + width: 24 + height: 8 + - title: Model Evaluation + name: Model Evaluation + model: ga4 + explore: model_evaluation + type: looker_grid + fields: [model_evaluation.events_event_name, model_evaluation.AIC, model_evaluation.log_likelihood, + model_evaluation.non_seasonal_p, model_evaluation.non_seasonal_d, model_evaluation.non_seasonal_q, + model_evaluation.has_drift] + sorts: [model_evaluation.events_event_name] + limit: 500 + column_limit: 50 + show_view_names: false + show_row_numbers: false + transpose: false + truncate_text: true + hide_totals: false + hide_row_totals: false + size_to_fit: true + table_theme: white + limit_displayed_rows: false + enable_conditional_formatting: false + header_text_alignment: left + header_font_size: '12' + rows_font_size: '12' + conditional_formatting_include_totals: false + conditional_formatting_include_nulls: false + show_sql_query_menu_options: false + show_totals: true + show_row_totals: true + truncate_header: false + minimum_column_width: 75 + defaults_version: 1 + listen: + Event Name: model_evaluation.events_event_name + row: 17 + col: 0 + width: 24 + height: 3 + - title: AR + name: AR + model: ga4 + explore: model_evaluation + type: single_value + fields: [model_evaluation.non_seasonal_p] + sorts: [model_evaluation.non_seasonal_p] + limit: 500 + column_limit: 50 + custom_color_enabled: true + show_single_value_title: true + show_comparison: false + comparison_type: value + comparison_reverse_colors: false + show_comparison_label: true + enable_conditional_formatting: true + conditional_formatting_include_totals: false + conditional_formatting_include_nulls: false + single_value_title: AR Steps + conditional_formatting: [{type: not null, value: !!null '', background_color: "#E8710A", + font_color: "#ffff", color_application: {collection_id: 7c56cc21-66e4-41c9-81ce-a60e1c3967b2, + palette_id: 56d0c358-10a0-4fd6-aa0b-b117bef527ab}, bold: false, italic: false, + strikethrough: false, fields: !!null ''}] + show_view_names: false + show_row_numbers: true + transpose: false + truncate_text: true + hide_totals: false + hide_row_totals: false + size_to_fit: true + table_theme: white + limit_displayed_rows: false + header_text_alignment: left + header_font_size: 12 + rows_font_size: 12 + defaults_version: 1 + listen: + Event Name: model_evaluation.events_event_name + row: 20 + col: 0 + width: 8 + height: 4 + - title: Integrated + name: Integrated + model: ga4 + explore: model_evaluation + type: single_value + fields: [model_evaluation.non_seasonal_d] + filters: {} + sorts: [model_evaluation.non_seasonal_d] + limit: 500 + column_limit: 50 + custom_color_enabled: true + show_single_value_title: true + show_comparison: false + comparison_type: value + comparison_reverse_colors: false + show_comparison_label: true + enable_conditional_formatting: true + conditional_formatting_include_totals: false + conditional_formatting_include_nulls: false + single_value_title: Integrated value + conditional_formatting: [{type: not null, value: !!null '', background_color: "#12B5CB", + font_color: "#ffff", color_application: {collection_id: 7c56cc21-66e4-41c9-81ce-a60e1c3967b2, + palette_id: 56d0c358-10a0-4fd6-aa0b-b117bef527ab}, bold: false, italic: false, + strikethrough: false, fields: !!null ''}] + show_view_names: false + show_row_numbers: true + transpose: false + truncate_text: true + hide_totals: false + hide_row_totals: false + size_to_fit: true + table_theme: white + limit_displayed_rows: false + header_text_alignment: left + header_font_size: 12 + rows_font_size: 12 + defaults_version: 1 + listen: + Event Name: model_evaluation.events_event_name + row: 20 + col: 8 + width: 8 + height: 4 + - title: Moving Averages + name: Moving Averages + model: ga4 + explore: model_evaluation + type: single_value + fields: [model_evaluation.non_seasonal_q] + filters: {} + sorts: [model_evaluation.non_seasonal_q] + limit: 500 + column_limit: 50 + custom_color_enabled: true + show_single_value_title: true + show_comparison: false + comparison_type: value + comparison_reverse_colors: false + show_comparison_label: true + enable_conditional_formatting: true + conditional_formatting_include_totals: false + conditional_formatting_include_nulls: false + single_value_title: Moving Averages + conditional_formatting: [{type: not null, value: !!null '', background_color: "#A8A116", + font_color: "#fff", color_application: {collection_id: 7c56cc21-66e4-41c9-81ce-a60e1c3967b2, + palette_id: 56d0c358-10a0-4fd6-aa0b-b117bef527ab}, bold: false, italic: false, + strikethrough: false, fields: !!null ''}] + show_view_names: false + show_row_numbers: true + transpose: false + truncate_text: true + hide_totals: false + hide_row_totals: false + size_to_fit: true + table_theme: white + limit_displayed_rows: false + header_text_alignment: left + header_font_size: 12 + rows_font_size: 12 + defaults_version: 1 + listen: + Event Name: model_evaluation.events_event_name + row: 20 + col: 16 + width: 8 + height: 4 + - title: Lower Bound + name: Lower Bound + model: ga4 + explore: sessions + type: single_value + fields: [forecasting.forecast_timestamp, forecasting.forecast_value, forecasting.prediction_interval_lower_bound, + forecasting.prediction_interval_upper_bound] + fill_fields: [forecasting.forecast_timestamp] + filters: {} + sorts: [forecasting.forecast_timestamp desc] + limit: 1 + column_limit: 50 + filter_expression: "${forecasting.forecast_timestamp}<=add_days(1,now())" + custom_color_enabled: true + show_single_value_title: true + show_comparison: false + comparison_type: value + comparison_reverse_colors: false + show_comparison_label: true + enable_conditional_formatting: true + conditional_formatting_include_totals: false + conditional_formatting_include_nulls: false + single_value_title: Lower Bound + value_format: '0.00' + conditional_formatting: [{type: not null, value: !!null '', background_color: "#F9AB00", + font_color: "#ffffff", color_application: {collection_id: 7c56cc21-66e4-41c9-81ce-a60e1c3967b2, + palette_id: 56d0c358-10a0-4fd6-aa0b-b117bef527ab}, bold: false, italic: false, + strikethrough: false, fields: !!null ''}] + show_view_names: false + defaults_version: 1 + hidden_fields: [forecasting.forecast_value] + listen: + Event Name: forecasting.events_event_name + row: 0 + col: 0 + width: 8 + height: 6 + - name: '' + type: text + title_text: '' + subtitle_text: '' + body_text: | + *** + + # Model Evaluation + row: 14 + col: 0 + width: 24 + height: 3 + - title: Users Expected Tomorrow (Copy) + name: Users Expected Tomorrow (Copy) + model: ga4 + explore: sessions + type: single_value + fields: [forecasting.forecast_timestamp, forecasting.forecast_value, forecasting.prediction_interval_lower_bound, + forecasting.prediction_interval_upper_bound] + fill_fields: [forecasting.forecast_timestamp] + filters: {} + sorts: [forecasting.forecast_timestamp desc] + limit: 1 + column_limit: 50 + filter_expression: "${forecasting.forecast_timestamp}<=add_days(1,now())" + custom_color_enabled: true + show_single_value_title: true + show_comparison: false + comparison_type: value + comparison_reverse_colors: false + show_comparison_label: true + enable_conditional_formatting: true + conditional_formatting_include_totals: false + conditional_formatting_include_nulls: false + single_value_title: Users Expected Tomorrow + value_format: '0.00' + conditional_formatting: [{type: not null, value: !!null '', background_color: "#1A73E8", + font_color: !!null '', color_application: {collection_id: 7c56cc21-66e4-41c9-81ce-a60e1c3967b2, + palette_id: 56d0c358-10a0-4fd6-aa0b-b117bef527ab}, bold: false, italic: false, + strikethrough: false, fields: !!null ''}] + show_view_names: false + defaults_version: 1 + listen: + Event Name: forecasting.events_event_name + row: 0 + col: 8 + width: 8 + height: 6 + - title: Upper Bound + name: Upper Bound + model: ga4 + explore: sessions + type: single_value + fields: [forecasting.forecast_timestamp, forecasting.forecast_value, forecasting.prediction_interval_lower_bound, + forecasting.prediction_interval_upper_bound] + fill_fields: [forecasting.forecast_timestamp] + filters: {} + sorts: [forecasting.forecast_timestamp desc] + limit: 1 + column_limit: 50 + filter_expression: "${forecasting.forecast_timestamp}<=add_days(1,now())" + custom_color_enabled: true + show_single_value_title: true + show_comparison: false + comparison_type: value + comparison_reverse_colors: false + show_comparison_label: true + enable_conditional_formatting: true + conditional_formatting_include_totals: false + conditional_formatting_include_nulls: false + single_value_title: Upper Bound + value_format: '0.00' + conditional_formatting: [{type: not null, value: !!null '', background_color: "#EA4335", + font_color: "#ffffff", color_application: {collection_id: 7c56cc21-66e4-41c9-81ce-a60e1c3967b2, + palette_id: 56d0c358-10a0-4fd6-aa0b-b117bef527ab}, bold: false, italic: false, + strikethrough: false, fields: !!null ''}] + show_view_names: false + defaults_version: 1 + hidden_fields: [forecasting.forecast_value, forecasting.prediction_interval_lower_bound] + listen: + Event Name: forecasting.events_event_name + row: 0 + col: 16 + width: 8 + height: 6 + filters: + - name: Event Name + title: Event Name + type: field_filter + default_value: '' + allow_multiple_values: true + required: false + ui_config: + type: tag_list + display: popover + model: ga4 + explore: sessions + listens_to_filters: [] + field: events.event_name \ No newline at end of file diff --git a/dashboards/audience.dashboard.lookml b/dashboards/audience.dashboard.lookml index 9c0c5f7..bd33a48 100644 --- a/dashboards/audience.dashboard.lookml +++ b/dashboards/audience.dashboard.lookml @@ -17,7 +17,7 @@ height: 4 - title: Sessions name: Sessions - model: + model: ga4 explore: sessions type: single_value fields: [sessions.total_sessions, sessions.total_first_visit_sessions_percentage] @@ -1592,7 +1592,7 @@ \ href=\"/dashboards-next/ga4::propensity_model\">\n\n\n\nPropensity Model\n\n
" + >\n\nModels\n\n" row: 0 col: 0 width: 24 @@ -1716,4 +1716,4 @@ model: ga4 explore: sessions listens_to_filters: [] - field: attribution_sources.attribution_source_channel + field: attribution_sources.attribution_source_channel \ No newline at end of file diff --git a/dashboards/avbb.dashboard.lookml b/dashboards/avbb.dashboard.lookml new file mode 100644 index 0000000..38b94e1 --- /dev/null +++ b/dashboards/avbb.dashboard.lookml @@ -0,0 +1,457 @@ +--- +- dashboard: avbb + title: "[GA4] AVBB Model" + layout: newspaper + preferred_viewer: dashboards-next + description: '' + preferred_slug: g2ZthRxhtAWMiEf9V19Hzs + elements: + + - name: " box" + type: text + title_text: '' + subtitle_text: '' + body_text: "
\n\t
\n\t\t\n\t

\n\n
" + row: 0 + col: 0 + width: 24 + height: 4 + + - name: " (4)" + type: text + title_text: '' + subtitle_text: '' + body_text: "
\n\t
\n\n
" + row: 0 + col: 0 + width: 20 + height: 2 + + + + + + - title: Feature Attribution for Revenue + name: Feature Attribution for Revenue + model: ga4 + explore: model_explanation + type: looker_bar + fields: [model_explanation.attribution, model_explanation.feature] + sorts: [model_explanation.attribution desc] + limit: 500 + column_limit: 50 + x_axis_gridlines: false + y_axis_gridlines: true + show_view_names: false + show_y_axis_labels: true + show_y_axis_ticks: true + y_axis_tick_density: default + y_axis_tick_density_custom: 5 + show_x_axis_label: true + show_x_axis_ticks: true + y_axis_scale_mode: linear + x_axis_reversed: false + y_axis_reversed: false + plot_size_by_field: false + trellis: '' + stacking: '' + limit_displayed_rows: false + legend_position: center + point_style: none + show_value_labels: true + label_density: 25 + x_axis_scale: auto + y_axis_combined: true + ordering: none + show_null_labels: false + show_totals_labels: false + show_silhouette: false + totals_color: "#808080" + x_axis_zoom: true + y_axis_zoom: true + label_value_format: '0.000' + advanced_vis_config: |- + { + chart: {}, + series: [{ + name: 'Feature' + }] + } + defaults_version: 1 + listen: {} + row: 2 + col: 0 + width: 24 + height: 8 + - title: Category Attribution for Revenue + name: Category Attribution for Revenue + model: ga4 + explore: category_attribution + type: looker_grid + fields: [category_attribution.processed_input, category_attribution.category, + category_attribution.weight, category_attribution.standard_error, category_attribution.p_value] + filters: + category_attribution.category: "-NULL" + sorts: [weight_order desc] + limit: 500 + column_limit: 50 + dynamic_fields: + - category: table_calculation + expression: abs(${category_attribution.weight}) + label: Weight order + value_format: + value_format_name: + _kind_hint: dimension + table_calculation: weight_order + _type_hint: number + show_view_names: false + show_row_numbers: true + transpose: false + truncate_text: true + hide_totals: false + hide_row_totals: false + size_to_fit: true + table_theme: white + limit_displayed_rows: false + enable_conditional_formatting: false + header_text_alignment: left + header_font_size: '12' + rows_font_size: '12' + conditional_formatting_include_totals: false + conditional_formatting_include_nulls: false + show_sql_query_menu_options: false + show_totals: true + show_row_totals: true + truncate_header: false + minimum_column_width: 75 + series_cell_visualizations: + category_attribution.p_value: + is_active: false + category_attribution.weight: + is_active: false + value_display: true + series_value_format: + category_attribution.weight: '0.000' + category_attribution.p_value: '0.0000' + category_attribution.standard_error: '0.0000' + x_axis_gridlines: false + y_axis_gridlines: true + show_y_axis_labels: true + show_y_axis_ticks: true + y_axis_tick_density: default + y_axis_tick_density_custom: 5 + show_x_axis_label: true + show_x_axis_ticks: true + y_axis_scale_mode: linear + x_axis_reversed: false + y_axis_reversed: false + plot_size_by_field: false + trellis: '' + stacking: '' + legend_position: center + point_style: none + show_value_labels: false + label_density: 25 + x_axis_scale: auto + y_axis_combined: true + ordering: none + show_null_labels: false + show_totals_labels: false + show_silhouette: false + totals_color: "#808080" + defaults_version: 1 + hidden_fields: [weight_order] + listen: + Processed Input: category_attribution.processed_input + row: 19 + col: 0 + width: 24 + height: 7 + - title: Top Variables + name: Top Variables + model: ga4 + explore: category_attribution + type: looker_column + fields: [category_attribution.processed_input, category_attribution.weight, category_attribution.category, + category_attribution.standard_error, category_attribution.p_value] + filters: + category_attribution.category: "-NULL" + sorts: [weight_order desc] + limit: 500 + column_limit: 50 + dynamic_fields: + - category: table_calculation + expression: abs(${category_attribution.weight}) + label: Weight order + value_format: + value_format_name: + _kind_hint: dimension + table_calculation: weight_order + _type_hint: number + x_axis_gridlines: false + y_axis_gridlines: true + show_view_names: false + show_y_axis_labels: true + show_y_axis_ticks: true + y_axis_tick_density: default + y_axis_tick_density_custom: 5 + show_x_axis_label: true + show_x_axis_ticks: true + y_axis_scale_mode: linear + x_axis_reversed: false + y_axis_reversed: false + plot_size_by_field: false + trellis: '' + stacking: '' + limit_displayed_rows: true + legend_position: center + point_style: none + show_value_labels: false + label_density: 25 + x_axis_scale: auto + y_axis_combined: true + ordering: none + show_null_labels: false + show_totals_labels: false + show_silhouette: false + totals_color: "#808080" + x_axis_zoom: true + y_axis_zoom: true + limit_displayed_rows_values: + show_hide: show + first_last: first + num_rows: '10' + show_row_numbers: true + transpose: false + truncate_text: true + hide_totals: false + hide_row_totals: false + size_to_fit: true + table_theme: white + enable_conditional_formatting: false + header_text_alignment: left + header_font_size: '12' + rows_font_size: '12' + conditional_formatting_include_totals: false + conditional_formatting_include_nulls: false + show_sql_query_menu_options: false + show_totals: true + show_row_totals: true + truncate_header: false + minimum_column_width: 75 + series_cell_visualizations: + category_attribution.p_value: + is_active: false + category_attribution.weight: + is_active: false + value_display: true + series_value_format: + category_attribution.weight: '0.000' + category_attribution.p_value: '0.0000' + category_attribution.standard_error: '0.0000' + defaults_version: 1 + hidden_fields: [weight_order, category_attribution.standard_error, category_attribution.p_value, + category_attribution.processed_input] + show_null_points: true + listen: + Processed Input: category_attribution.processed_input + row: 13 + col: 0 + width: 24 + height: 6 + - name: '' + type: text + title_text: '' + subtitle_text: '' + body_text: "## **Instructions** : \n\nThe top variables show the elasticities\ + \ for each specific category. You can use the filter at the top to understand\ + \ which are the campaigns, devices, sources or mediums that where more important\ + \ to drive revenue. \n" + row: 10 + col: 0 + width: 24 + height: 3 + - name: " (2)" + type: text + title_text: '' + subtitle_text: '' + body_text: | + *** + + ## Aggregated Value Based Bidding + row: 0 + col: 0 + width: 24 + height: 2 + - title: Mean Absolute Error + name: Mean Absolute Error + model: ga4 + explore: evaluation + type: single_value + fields: [evaluation.MAE] + sorts: [evaluation.MAE] + limit: 500 + column_limit: 50 + custom_color_enabled: true + show_single_value_title: true + show_comparison: false + comparison_type: value + comparison_reverse_colors: false + show_comparison_label: true + enable_conditional_formatting: true + conditional_formatting_include_totals: false + conditional_formatting_include_nulls: false + single_value_title: Mean Absolute Error + value_format: '0.0000' + conditional_formatting: [{type: not null, value: !!null '', background_color: "#1A73E8", + font_color: !!null '', color_application: {collection_id: 7c56cc21-66e4-41c9-81ce-a60e1c3967b2, + palette_id: 56d0c358-10a0-4fd6-aa0b-b117bef527ab}, bold: false, italic: false, + strikethrough: false, fields: !!null ''}] + defaults_version: 1 + listen: {} + row: 28 + col: 0 + width: 8 + height: 6 + - title: MSLE + name: MSLE + model: ga4 + explore: evaluation + type: single_value + fields: [evaluation.MSLE] + sorts: [evaluation.MSLE] + limit: 500 + column_limit: 50 + custom_color_enabled: true + show_single_value_title: true + show_comparison: false + comparison_type: value + comparison_reverse_colors: false + show_comparison_label: true + enable_conditional_formatting: true + conditional_formatting_include_totals: false + conditional_formatting_include_nulls: false + single_value_title: Mean Squared Log error + value_format: '0.000000' + conditional_formatting: [{type: not null, value: !!null '', background_color: "#F9AB00", + font_color: "#FFFF", color_application: {collection_id: 7c56cc21-66e4-41c9-81ce-a60e1c3967b2, + palette_id: 56d0c358-10a0-4fd6-aa0b-b117bef527ab}, bold: false, italic: false, + strikethrough: false, fields: !!null ''}] + defaults_version: 1 + listen: {} + row: 28 + col: 8 + width: 8 + height: 6 + - title: R2 Score + name: R2 Score + model: ga4 + explore: evaluation + type: single_value + fields: [evaluation.r_squared] + sorts: [evaluation.r_squared] + limit: 500 + column_limit: 50 + custom_color_enabled: true + show_single_value_title: true + show_comparison: false + comparison_type: value + comparison_reverse_colors: false + show_comparison_label: true + enable_conditional_formatting: true + conditional_formatting_include_totals: false + conditional_formatting_include_nulls: false + single_value_title: R2 Score (Explained Variance) + value_format: '0.000000' + conditional_formatting: [{type: not null, value: !!null '', background_color: "#EA4335", + font_color: "#FFFF", color_application: {collection_id: 7c56cc21-66e4-41c9-81ce-a60e1c3967b2, + palette_id: 56d0c358-10a0-4fd6-aa0b-b117bef527ab}, bold: false, italic: false, + strikethrough: false, fields: !!null ''}] + defaults_version: 1 + listen: {} + row: 28 + col: 16 + width: 8 + height: 6 + - name: " (3)" + type: text + title_text: '' + subtitle_text: '' + body_text: |+ + *** + + ## Model Metrics + + row: 26 + col: 0 + width: 24 + height: 2 + filters: + - name: Processed Input + title: Processed Input + type: field_filter + default_value: '' + allow_multiple_values: true + required: false + ui_config: + type: checkboxes + display: popover + model: ga4 + explore: category_attribution + listens_to_filters: [] + field: category_attribution.processed_input \ No newline at end of file diff --git a/dashboards/behavior.dashboard.lookml b/dashboards/behavior.dashboard.lookml index 769401b..1280ef6 100644 --- a/dashboards/behavior.dashboard.lookml +++ b/dashboards/behavior.dashboard.lookml @@ -649,7 +649,7 @@ \ href=\"/dashboards-next/ga4::propensity_model\">\n\n\n\nPropensity Model\n\n
" + >\n\nModels\n\n" row: 0 col: 0 width: 24 @@ -692,4 +692,4 @@ model: ga4 explore: sessions listens_to_filters: [] - field: sessions.landing_page + field: sessions.landing_page \ No newline at end of file diff --git a/dashboards/campaign_impact.dashboard.lookml b/dashboards/campaign_impact.dashboard.lookml index 0fa8662..a0164a6 100644 --- a/dashboards/campaign_impact.dashboard.lookml +++ b/dashboards/campaign_impact.dashboard.lookml @@ -558,4 +558,4 @@ model: ga4 explore: sessions listens_to_filters: [] - field: sessions.audience_selector + field: sessions.audience_selector \ No newline at end of file diff --git a/dashboards/custom_goal_conversions.dashboard.lookml b/dashboards/custom_goal_conversions.dashboard.lookml index 99b38e5..5a52106 100644 --- a/dashboards/custom_goal_conversions.dashboard.lookml +++ b/dashboards/custom_goal_conversions.dashboard.lookml @@ -947,4 +947,4 @@ model: ga4 explore: sessions listens_to_filters: [] - field: sessions.audience_selector + field: sessions.audience_selector \ No newline at end of file diff --git a/dashboards/event_funnel.dashboard.lookml b/dashboards/event_funnel.dashboard.lookml index 5bd3dd4..f4e171c 100644 --- a/dashboards/event_funnel.dashboard.lookml +++ b/dashboards/event_funnel.dashboard.lookml @@ -329,4 +329,4 @@ model: ga4 explore: sessions listens_to_filters: [] - field: sessions.audience_selector + field: sessions.audience_selector \ No newline at end of file diff --git a/dashboards/overview.dashboard.lookml b/dashboards/overview.dashboard.lookml index 1698e1c..491060b 100644 --- a/dashboards/overview.dashboard.lookml +++ b/dashboards/overview.dashboard.lookml @@ -1339,7 +1339,7 @@ \ href=\"/dashboards-next/ga4::propensity_model\">\n\n\n\nPropensity Model\n\n" + >\n\nModels\n\n" row: 0 col: 0 width: 24 @@ -1372,4 +1372,4 @@ model: ga4 explore: sessions listens_to_filters: [] - field: sessions.landing_page + field: sessions.landing_page \ No newline at end of file diff --git a/dashboards/page_funnel.dashboard.lookml b/dashboards/page_funnel.dashboard.lookml index 6cd70b2..0d017ab 100644 --- a/dashboards/page_funnel.dashboard.lookml +++ b/dashboards/page_funnel.dashboard.lookml @@ -341,4 +341,4 @@ model: ga4 explore: sessions listens_to_filters: [] - field: sessions.audience_selector + field: sessions.audience_selector \ No newline at end of file diff --git a/dashboards/performance_metrics_model.dashboard.lookml b/dashboards/performance_metrics_model.dashboard.lookml index 41ce2a6..82c593f 100644 --- a/dashboards/performance_metrics_model.dashboard.lookml +++ b/dashboards/performance_metrics_model.dashboard.lookml @@ -45,12 +45,11 @@ \ href=\"/dashboards-next/ga4::propensity_model\">\n\n\n\nPropensity Model\n\n" + >\n\nModels\n\n" row: 0 col: 0 width: 24 height: 4 - - name: " (4)" type: text title_text: '' @@ -62,14 +61,22 @@ \ href=\"/dashboards-next/ga4::propensity_model\">\n\n\n\nModel Overview\n\n\nPropensity Model\n\n\n\n\nPerformance Metrics\n\n" + >\n\nPropensity Performance\n\n\n\n\nARIMA Event Model\n\n\n\n\nAggregated Value Based Bidding\n\n" row: 0 col: 0 - width: 9 + width: 20 height: 2 @@ -378,4 +385,4 @@ model: ga4 explore: sessions listens_to_filters: [] - field: sessions.session_date + field: sessions.session_date \ No newline at end of file diff --git a/dashboards/propensity_model.dashboard.lookml b/dashboards/propensity_model.dashboard.lookml index 9380598..209697b 100644 --- a/dashboards/propensity_model.dashboard.lookml +++ b/dashboards/propensity_model.dashboard.lookml @@ -45,7 +45,7 @@ \ href=\"/dashboards-next/ga4::propensity_model\">\n\n\n\nPropensity Model\n\n" + >\n\nModels\n\n" row: 0 col: 0 width: 24 @@ -61,14 +61,22 @@ \ href=\"/dashboards-next/ga4::propensity_model\">\n\n\n\nModel Overview\n\n\nPropensity Model\n\n\n\n\nPerformance Metrics\n\n" + >\n\nPropensity Performance\n\n\n\n\nARIMA Event Model\n\n\n\n\nAggregated Value Based Bidding\n\n" row: 0 col: 0 - width: 9 + width: 20 height: 2 - type: button name: button_984 @@ -199,7 +207,7 @@ type: single_value fields: [future_purchase_prediction.count] filters: - future_purchase_prediction.pred_probability_bucket: Low + future_purchase_prediction.pred_probability_bucket: "< 0.1,>= 0.1 and < 0.2,>= 0.2 and < 0.3" events.total_purchase_revenue_usd: NOT NULL limit: 500 column_limit: 50 @@ -212,7 +220,7 @@ enable_conditional_formatting: true conditional_formatting_include_totals: false conditional_formatting_include_nulls: false - single_value_title: Low + single_value_title: 2nd Decile conditional_formatting: [{type: not null, value: !!null '', background_color: "#B31412", font_color: !!null '', color_application: {collection_id: test, palette_id: test-sequential-0}, bold: false, italic: false, strikethrough: false, fields: !!null ''}] @@ -231,7 +239,7 @@ type: single_value fields: [future_purchase_prediction.count] filters: - future_purchase_prediction.pred_probability_bucket: Medium + future_purchase_prediction.pred_probability_bucket: ">= 0.3 and < 0.4,>= 0.4 and < 0.5,>= 0.5 and < 0.6,>= 0.6 and < 0.7" events.total_purchase_revenue_usd: NOT NULL limit: 500 column_limit: 50 @@ -244,7 +252,7 @@ enable_conditional_formatting: true conditional_formatting_include_totals: false conditional_formatting_include_nulls: false - single_value_title: Medium + single_value_title: 5th Decile conditional_formatting: [{type: not null, value: !!null '', background_color: "#1A73E8", font_color: !!null '', color_application: {collection_id: test, palette_id: test-sequential-0}, bold: false, italic: false, strikethrough: false, fields: !!null ''}] @@ -263,7 +271,7 @@ type: single_value fields: [future_purchase_prediction.count] filters: - future_purchase_prediction.pred_probability_bucket: High + future_purchase_prediction.pred_probability_bucket: ">= 0.7 and < 0.8,>= 0.8 and < 0.9,>= 0.9" events.total_purchase_revenue_usd: NOT NULL limit: 500 column_limit: 50 @@ -277,7 +285,7 @@ conditional_formatting_include_totals: false conditional_formatting_include_nulls: false custom_color: "#fcf9ff" - single_value_title: High + single_value_title: 7th Decile conditional_formatting: [{type: not null, value: !!null '', background_color: "#F9AB00", font_color: "#ffff", color_application: {collection_id: test, palette_id: test-sequential-0}, bold: false, italic: false, strikethrough: false, fields: !!null ''}] @@ -326,15 +334,8 @@ show_null_points: true interpolation: linear color_application: - collection_id: test - custom: - id: c28209c2-d983-51aa-8c75-9d2ec0df1d2a - label: Custom - type: discrete - colors: - - "#F9AB00" - - "#B31412" - - "#1A73E8" + collection_id: b43731d5-dc87-4a8e-b807-635bef3948e7 + palette_id: fb7bb53e-b77b-4ab6-8274-9d420d3d73f3 options: steps: 5 y_axes: [{label: Person Count, orientation: left, series: [{axisId: incremental_prediction.count, @@ -398,15 +399,8 @@ show_null_points: true interpolation: linear color_application: - collection_id: test - custom: - id: cbc56d8d-286f-24c7-8a19-d4d3de13c2f8 - label: Custom - type: discrete - colors: - - "#F9AB00" - - "#B31412" - - "#1A73E8" + collection_id: b43731d5-dc87-4a8e-b807-635bef3948e7 + palette_id: fb7bb53e-b77b-4ab6-8274-9d420d3d73f3 options: steps: 5 y_axes: [{label: Revenue (USD), orientation: left, series: [{axisId: incremental_prediction.count, @@ -447,4 +441,4 @@ model: ga4 explore: sessions listens_to_filters: [] - field: sessions.session_date + field: sessions.session_date \ No newline at end of file diff --git a/explores/sessions.explore.lkml b/explores/sessions.explore.lkml index 5eea1dd..b0e3e5f 100644 --- a/explores/sessions.explore.lkml +++ b/explores/sessions.explore.lkml @@ -1,5 +1,6 @@ include: "/views/*.view.lkml" include: "/views/*/*.view.lkml" +include: "/views/*/*/*.view.lkml" include: "/attributes/*.lkml" explore: sessions { @@ -104,12 +105,23 @@ explore: sessions { sql_on: ${sessions.session_attribution_medium} = ${others.medium};; relationship: many_to_one } - - join: attribution_sources { sql: ;; relationship: one_to_one view_label: "Acquisition" } + join: forecasting { + type: full_outer + sql_on:${forecasting.forecast_timestamp}=${events.event_time_date} ;;#${events.event_name}=${forecasting.events_event_name} AND + relationship: one_to_one + view_label: "ARIMA" + } + #join: arima_join { + # type: inner + # sql_on: ${forecasting.forecast_timestamp}=${arima_join.date_join} OR + # ${sessions.session_date}=${arima_join.date_join};; + # relationship: many_to_one + # view_label: "ARIMA" + #} } diff --git a/views/bqml/arima_event_model/forecasting.view.lkml b/views/bqml/arima_event_model/forecasting.view.lkml new file mode 100644 index 0000000..bbf42e8 --- /dev/null +++ b/views/bqml/arima_event_model/forecasting.view.lkml @@ -0,0 +1,62 @@ +include: "/views/bqml/*/*.view.lkml" +view: forecasting { + derived_table: { + sql_trigger_value: ${model_arima.SQL_TABLE_NAME} ;; + sql: SELECT * FROM ML.EXPLAIN_FORECAST(MODEL ${model_arima.SQL_TABLE_NAME}, + STRUCT(60 AS horizon, 0.8 AS confidence_level)) ;; + } + dimension: forecast_timestamp + { + primary_key: yes + type:date + sql:${TABLE}.time_series_timestamp ;; + } + dimension: events_event_name + { + label:"Forecasted Event" + type:string + sql:${TABLE}.events_event_name;; + } + dimension: forecast_value_num { + type: number + hidden: no + sql:${TABLE}.time_series_data ;; + } + dimension: se { + type: number + hidden: no + sql:${TABLE}.standard_error;; + } + dimension: upper { + type: number + hidden: no + sql: ${TABLE}.prediction_interval_upper_bound;; + } + dimension: lower { + type: number + hidden: no + sql:${TABLE}.prediction_interval_lower_bound ;; + } + measure: forecast_value + { + type:sum_distinct + sql_distinct_key: ${events_event_name};; + sql:${forecast_value_num};; + } + measure: standard_error + { + type: sum_distinct + sql_distinct_key: ${events_event_name};; + sql:${se};; + } + measure: prediction_interval_lower_bound { + type:sum_distinct + sql_distinct_key: ${events_event_name};; + sql:${lower};; + } + measure: prediction_interval_upper_bound { + type:sum_distinct + sql_distinct_key: ${events_event_name};; + sql: ${upper};; + } +} diff --git a/views/bqml/arima_event_model/model_arima.view.lkml b/views/bqml/arima_event_model/model_arima.view.lkml new file mode 100644 index 0000000..2503780 --- /dev/null +++ b/views/bqml/arima_event_model/model_arima.view.lkml @@ -0,0 +1,55 @@ +include: "/views/*.view.lkml" +include: "/views/bqml/*/*.view.lkml" +view: model_arima { + #extension: required + derived_table: { + sql_trigger_value: ${training_input_arima.SQL_TABLE_NAME};; + sql_create: CREATE OR REPLACE MODEL ${SQL_TABLE_NAME} + OPTIONS( + MODEL_TYPE='ARIMA_PLUS', + time_series_timestamp_col='sessions_session_date', + time_series_data_col='sum_of_session_event_count', + time_series_id_col='events_event_name', + auto_arima=true) AS + SELECT * + FROM ${training_input_arima.SQL_TABLE_NAME};; + } + dimension: ts { + type: string + hidden: yes + } + dimension: ev_count { + type: number + hidden: yes + } + dimension: events_event_name { + type: string + hidden: yes + } + + } + #explore: train_data_arima {fields:[ts,ev_count]} + explore: model_evaluation {hidden:yes} + # + explore: optimal_model_coeff {hidden:yes} + #explore: forecasting {} + view: optimal_model_coeff{ + derived_table: { + sql: SELECT * FROM ML.ARIMA_COEFFICIENTS(MODEL ${model_arima.SQL_TABLE_NAME});; + } + dimension: ar_coefficients {type:number sql:${TABLE}.ar_coefficients;;} + dimension: ma_coefficients {type:number sql:${TABLE}.ma_coefficients;;} + dimension: intercept_or_drift {type:number sql:${TABLE}.intercept_or_drift;;} + } + view: model_evaluation { + derived_table: { + sql: SELECT * FROM ML.ARIMA_EVALUATE(MODEL ${model_arima.SQL_TABLE_NAME});; + } + dimension: events_event_name {type:string sql:${TABLE}.events_event_name ;;} + dimension: has_drift {type:string sql:${TABLE}.has_drift ;;} + dimension: non_seasonal_p {type:number sql:${TABLE}.non_seasonal_p ;; } + dimension: non_seasonal_q {type:number sql:${TABLE}.non_seasonal_q ;; } + dimension: non_seasonal_d {type:number sql:${TABLE}.non_seasonal_d ;; } + dimension: log_likelihood {type:number sql:${TABLE}.log_likelihood ;; } + dimension: AIC{type:number sql:${TABLE}.AIC ;; } + } diff --git a/views/bqml/arima_event_model/training_input_arima.view.lkml b/views/bqml/arima_event_model/training_input_arima.view.lkml new file mode 100644 index 0000000..104e532 --- /dev/null +++ b/views/bqml/arima_event_model/training_input_arima.view.lkml @@ -0,0 +1,18 @@ +view: training_input_arima { + derived_table: { + sql_trigger_value: ${incremental_prediction.SQL_TABLE_NAME} ;; + sql:SELECT + (DATE(TIMESTAMP_MICROS(events.event_timestamp) )) AS sessions_session_date, + events.event_name AS events_event_name, + COUNT(DISTINCT sessions.sl_key ) AS sum_of_session_event_count +FROM ${sessions.SQL_TABLE_NAME} AS sessions +LEFT JOIN UNNEST(sessions.event_data) as events with offset as event_row +WHERE ((( TIMESTAMP_MICROS(events.event_timestamp) ) >= ((TIMESTAMP_ADD(TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY), INTERVAL -89 DAY))) AND ( TIMESTAMP_MICROS(events.event_timestamp) ) < ((TIMESTAMP_ADD(TIMESTAMP_ADD(TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY), INTERVAL -89 DAY), INTERVAL 90 DAY))))) +GROUP BY 1,2 ORDER BY 1 DESC;; + } + dimension: session_date_arima { + hidden: yes + type: date + sql: ${TABLE}.sessions_session_date ;; + } + } diff --git a/views/bqml/avbb/training_data_avbb.view.lkml b/views/bqml/avbb/training_data_avbb.view.lkml new file mode 100644 index 0000000..3788e28 --- /dev/null +++ b/views/bqml/avbb/training_data_avbb.view.lkml @@ -0,0 +1,127 @@ +include: "/views/sessions/*.view.lkml" +include: "/views/*/*.view.lkml" +view: training_data_avbb { + derived_table: { + sql_trigger_value: ${forecasting.SQL_TABLE_NAME} ;; + sql:SELECT sessions.sl_key, + session_attribution.source, + session_attribution.medium, + session_attribution.campaign, + device_data.device__category as device, + events.event_name AS events_event_name, + device_data.device__is_limited_ad_tracking as lim_ad_track, + SUM(TIMESTAMP_DIFF(session_data.session_end,session_data.session_start,second)/86400.0) as session_duration, + SUM(session_data.session_page_view_count) as session_count, + COALESCE(SUM(event_data[SAFE_OFFSET(0)].user_ltv.revenue),0.0) as label + FROM ${sessions.SQL_TABLE_NAME} as sessions + LEFT JOIN UNNEST(sessions.event_data) as events with offset as event_row GROUP BY 1,2,3,4,5,6,7 ;; + } + dimension: sl_key { + hidden: yes + type: string + sql: ${TABLE}.sl_key ;; + } +} + + +view: avbb_model { + derived_table: { + sql_trigger_value: ${training_data_avbb.SQL_TABLE_NAME} ;; + sql_create: CREATE OR REPLACE MODEL ${SQL_TABLE_NAME} +OPTIONS + ( MODEL_TYPE='LINEAR_REG', + CALCULATE_P_VALUES=TRUE, + MAX_ITERATIONS=5, + CATEGORY_ENCODING_METHOD='DUMMY_ENCODING', + ENABLE_GLOBAL_EXPLAIN=TRUE, + DATA_SPLIT_METHOD='AUTO_SPLIT') AS + SELECT source, + medium, + campaign, + device, + events_event_name, + LN(session_duration) as session_duration, + session_count, + lim_ad_track, + LN(label) as label from ${training_data_avbb.SQL_TABLE_NAME} WHERE label>0 AND session_duration>0 + ;; + } +} + +view: model_explanation { + derived_table: { + sql_trigger_value: ${training_data_avbb.SQL_TABLE_NAME} ;; + sql: SELECT * FROM + ML.GLOBAL_EXPLAIN(MODEL ${avbb_model.SQL_TABLE_NAME}) ;; + } + dimension: feature { + type: string + sql: ${TABLE}.feature ;; + } + dimension: attribution { + type: number + sql: ${TABLE}.attribution ;; + } +} + +explore: model_explanation { + hidden: yes +} + +view: category_attribution { + derived_table: { + + sql_trigger_value: ${model_explanation.SQL_TABLE_NAME} ;; + sql: SELECT * FROM ML.ADVANCED_WEIGHTS( + MODEL ${avbb_model.SQL_TABLE_NAME}, + STRUCT(TRUE AS standardize)) + WHERE p_value<0.05 ;; + } + + dimension: processed_input { + type: string + sql: ${TABLE}.processed_input;; + } + dimension: category { + type: string + sql: ${TABLE}.category ;; + } + dimension: weight { + type: number + sql: ${TABLE}.weight ;; + } + dimension: standard_error { + type: number + sql: ${TABLE}.standard_error ;; + } + dimension: p_value { + type: number + sql: ${TABLE}.p_value ;; + } + +} +explore: category_attribution { + hidden: yes +} + +view: evaluation { + derived_table: { + sql_trigger_value: ${category_attribution.SQL_TABLE_NAME} ;; + sql: SELECT * FROM ML.EVALUATE(MODEL ${avbb_model.SQL_TABLE_NAME});; + } + dimension: MAE { + type: number + sql: ${TABLE}.mean_absolute_error ;; + } + dimension: MSLE { + type: number + sql: ${TABLE}.mean_squared_log_error ;; + } + dimension: r_squared { + type: number + sql: ${TABLE}.r2_score ;; + } +} +explore: evaluation { + hidden: yes +} diff --git a/views/events.view.lkml b/views/events.view.lkml index 40ef97b..8afd754 100644 --- a/views/events.view.lkml +++ b/views/events.view.lkml @@ -9,6 +9,7 @@ ## - event_path include: "event_data_dimensions/*.view" +include: "bqml/arima_event_model/*.view" view: events { extends: [event_data_event_params, event_data_user_properties, goals, page_data, event_path] diff --git a/views/sessions/session_tags.view.lkml b/views/sessions/session_tags.view.lkml index 8940171..5072e5a 100644 --- a/views/sessions/session_tags.view.lkml +++ b/views/sessions/session_tags.view.lkml @@ -6,17 +6,26 @@ view: session_tags{ cluster_keys: ["sl_key","session_date"] #datagroup_trigger: ga4_default_datagroup sql_trigger_value: ${session_list_with_event_history.SQL_TABLE_NAME} ;; - sql:select distinct sl.sl_key, sl.session_date as session_date - , first_value(case when ep.key = 'medium' then ep.value.string_value end) over (partition by sl.sl_key order by sl.event_timestamp desc) medium - , first_value(case when ep.key = 'source' then ep.value.string_value end) over (partition by sl.sl_key order by sl.event_timestamp desc) source - , first_value(case when ep.key = 'campaign' then ep.value.string_value end) over (partition by sl.sl_key order by sl.event_timestamp desc) campaign - , first_value(case when ep.key = 'page_referrer' then ep.value.string_value end) over (partition by sl.sl_key order by sl.event_timestamp desc) page_referrer -from ${session_list_with_event_history.SQL_TABLE_NAME} AS sl - , UNNEST(sl.event_params) AS ep -where sl.event_name in ('page_view') -and {% incrementcondition %} session_date {% endincrementcondition %} --- NULL medium is direct, filtering out nulls to ensure last non-direct. - ;; + sql:SELECT DISTINCT sl.sl_key, sl.session_date + , CASE WHEN key = 'medium' THEN value.string_value END AS medium + , CASE WHEN key = 'source' THEN value.string_value END AS source + , CASE WHEN key = 'campaign' THEN value.string_value END AS campaign + , CASE WHEN key = 'page_referrer' THEN value.string_value END AS page_referrer +FROM ( + SELECT sl_key, session_date, key, value,event_timestamp + FROM ${session_list_with_event_history.SQL_TABLE_NAME} sl3 + CROSS JOIN UNNEST(sl3.event_params) AS sl1 + WHERE event_name in ('page_view') + AND key IN ('medium','source','campaign','page_referrer') + AND sl_key IS NOT NULL +) AS sl +JOIN ( + SELECT sl2.sl_key, sl2.session_date, MIN(event_timestamp) AS min_event_timestamp + FROM ${session_list_with_event_history.SQL_TABLE_NAME} AS sl2 + GROUP BY sl2.sl_key, sl2.session_date +) AS min_events ON sl.sl_key = min_events.sl_key AND sl.session_date = min_events.session_date +WHERE sl.event_timestamp = min_events.min_event_timestamp +and {% incrementcondition %} session_date {% endincrementcondition %};; } dimension: session_date { type: date