"
+ row: 0
+ col: 0
+ width: 20
+ height: 2
+
+
+
+ - title: Model Performance Metrics
+ name: Model Performance Metrics
+ model: ga4
+ explore: future_purchase_model_evaluation
+ type: looker_grid
+ fields: [future_purchase_model_evaluation.accuracy, future_purchase_model_evaluation.f1_score,
+ future_purchase_model_evaluation.recall, future_purchase_model_evaluation.log_loss,
+ future_purchase_model_evaluation.roc_auc]
+ sorts: [future_purchase_model_evaluation.accuracy]
+ limit: 500
+ column_limit: 50
+ 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: true
+ header_text_alignment: left
+ header_font_size: '12'
+ rows_font_size: '12'
+ conditional_formatting_include_totals: false
+ conditional_formatting_include_nulls: false
+ color_application:
+ collection_id: legacy
+ palette_id: looker_classic
+ show_sql_query_menu_options: false
+ show_totals: true
+ show_row_totals: true
+ truncate_header: false
+ minimum_column_width: 75
+ series_text_format:
+ future_purchase_model_evaluation.accuracy:
+ bg_color: "#39ff1c"
+ conditional_formatting: [{type: along a scale..., value: !!null '', background_color: "#62bad4",
+ font_color: !!null '', color_application: {collection_id: legacy, palette_id: legacy_diverging2,
+ options: {steps: 5}}, bold: false, italic: false, strikethrough: false,
+ fields: !!null ''}]
+ series_value_format:
+ future_purchase_model_evaluation.log_loss:
+ name: percent_3
+ decimals: '3'
+ format_string: "#,##0.000%"
+ label: Percent (3)
+ label_prefix: Percent
+ future_purchase_model_evaluation.roc_auc:
+ name: percent_3
+ decimals: '3'
+ format_string: "#,##0.000%"
+ label: Percent (3)
+ label_prefix: Percent
+ hidden_fields: []
+ hidden_points_if_no: []
+ theme: traditional
+ layout: fixed
+ minWidthForIndexColumns: true
+ showTooltip: false
+ showHighlight: false
+ columnOrder: {}
+ defaults_version: 1
+ y_axes: []
+ listen: {}
+ row: 6
+ col: 8
+ width: 14
+ height: 4
+ - title: Training Iterations
+ name: Training Iterations
+ model: ga4
+ explore: future_purchase_model_training_info
+ type: looker_grid
+ fields: [future_purchase_model_training_info.duration_ms, future_purchase_model_training_info.eval_loss,
+ future_purchase_model_training_info.iteration, future_purchase_model_training_info.learning_rate,
+ future_purchase_model_training_info.training_run]
+ sorts: [future_purchase_model_training_info.duration_ms]
+ limit: 500
+ column_limit: 50
+ 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
+ defaults_version: 1
+ y_axes: []
+ listen: {}
+ row: 13
+ col: 0
+ width: 22
+ height: 4
+ - title: Confusion Matrix
+ name: Confusion Matrix
+ model: ga4
+ explore: confusion_matrix
+ type: marketplace_viz_report_table::report_table-marketplace
+ fields: [confusion_matrix.Expected_label, confusion_matrix.Predicted_0, confusion_matrix.Predicted_1]
+ sorts: [confusion_matrix.Expected_label]
+ limit: 500
+ column_limit: 50
+ dynamic_fields:
+ - args:
+ - confusion_matrix.Predicted_1
+ calculation_type: percent_of_column_sum
+ category: table_calculation
+ based_on: confusion_matrix.Predicted_1
+ label: Percent of Confusion Matrix Predicted 1
+ source_field: confusion_matrix.Predicted_1
+ table_calculation: percent_of_confusion_matrix_predicted_1
+ value_format:
+ value_format_name: percent_0
+ _kind_hint: dimension
+ _type_hint: number
+ is_disabled: true
+ hidden_fields: []
+ hidden_points_if_no: []
+ show_view_names: false
+ theme: traditional
+ customTheme: ''
+ layout: auto
+ minWidthForIndexColumns: true
+ headerFontSize: 12
+ bodyFontSize: 12
+ showTooltip: true
+ showHighlight: true
+ columnOrder: {}
+ rowSubtotals: false
+ colSubtotals: false
+ spanRows: true
+ spanCols: true
+ calculateOthers: true
+ sortColumnsBy: pivots
+ useViewName: false
+ useHeadings: false
+ useShortName: false
+ useUnit: false
+ groupVarianceColumns: false
+ genericLabelForSubtotals: false
+ indexColumn: false
+ transposeTable: false
+ label|confusion_matrix.Expected_label: Expected Label
+ heading|confusion_matrix.Expected_label: ''
+ hide|confusion_matrix.Expected_label: false
+ label|confusion_matrix.Predicted_0: Predicted 0
+ heading|confusion_matrix.Predicted_0: ''
+ hide|confusion_matrix.Predicted_0: false
+ label|confusion_matrix.Predicted_1: Predicted 1
+ heading|confusion_matrix.Predicted_1: ''
+ hide|confusion_matrix.Predicted_1: false
+ subtotalDepth: '1'
+ 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
+ hidden_pivots: {}
+ defaults_version: 0
+ truncate_column_names: false
+ y_axes: []
+ listen: {}
+ row: 2
+ col: 8
+ width: 14
+ height: 4
+ - title: Feature Importance
+ name: Feature Importance
+ model: ga4
+ explore: feature_importance
+ type: looker_grid
+ fields: [feature_importance.feature, feature_importance.attribution]
+ sorts: [feature_importance.attribution desc]
+ limit: 500
+ column_limit: 50
+ query_timezone: America/Ciudad_Juarez
+ 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: true
+ header_text_alignment: left
+ header_font_size: '12'
+ rows_font_size: '12'
+ conditional_formatting_include_totals: false
+ conditional_formatting_include_nulls: false
+ color_application:
+ collection_id: legacy
+ palette_id: looker_classic
+ show_sql_query_menu_options: false
+ show_totals: true
+ show_row_totals: true
+ truncate_header: false
+ minimum_column_width: 75
+ conditional_formatting: [{type: along a scale..., value: !!null '', background_color: "#62bad4",
+ font_color: !!null '', color_application: {collection_id: legacy, palette_id: legacy_diverging2,
+ options: {steps: 5, reverse: false}}, bold: false, italic: false, strikethrough: false,
+ fields: !!null ''}]
+ 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: true
+ y_axis_reversed: false
+ plot_size_by_field: false
+ x_axis_zoom: true
+ y_axis_zoom: true
+ trellis: ''
+ stacking: normal
+ 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: []
+ hidden_points_if_no: []
+ leftAxisLabelVisible: false
+ leftAxisLabel: ''
+ rightAxisLabelVisible: false
+ rightAxisLabel: ''
+ smoothedBars: false
+ orientation: automatic
+ labelPosition: left
+ percentType: total
+ percentPosition: inline
+ valuePosition: right
+ labelColorEnabled: false
+ labelColor: "#FFF"
+ up_color: false
+ down_color: false
+ total_color: false
+ y_axes: []
+ listen: {}
+ row: 2
+ col: 0
+ width: 8
+ height: 11
+ - type: button
+ name: button_1013
+ rich_content_json: '{"text":"Go to top","description":"This button is for redirecting
+ back to the top of the page","newTab":false,"alignment":"center","size":"medium","style":"FILLED","color":"#1A73E8","href":"#top"}'
+ row: 17
+ col: 0
+ width: 24
+ height: 1
+ - name: " (Copy)"
+ type: text
+ title_text: " (Copy)"
+ subtitle_text: ''
+ body_text: '[{"type":"h1","children":[{"text":"Propensity Model Details"}],"align":"center"}]'
+ rich_content_json: '{"format":"slate"}'
+ row: 0
+ col: 0
+ width: 22
+ height: 2
+ filters:
+ - name: Session Date
+ title: Session Date
+ type: field_filter
+ default_value: 90 day
+ allow_multiple_values: true
+ required: true
+ ui_config:
+ type: relative_timeframes
+ display: inline
+ options: []
+ model: ga4
+ explore: sessions
+ listens_to_filters: []
+ field: sessions.session_date
\ No newline at end of file
diff --git a/dashboards/propensity_model.dashboard.lookml b/dashboards/propensity_model.dashboard.lookml
new file mode 100644
index 0000000..209697b
--- /dev/null
+++ b/dashboards/propensity_model.dashboard.lookml
@@ -0,0 +1,444 @@
+- dashboard: propensity_model
+ title: "[GA4] Propensity Model"
+ layout: newspaper
+ preferred_viewer: dashboards-next
+ description: ''
+ preferred_slug: 0CHozsw7cHwlmrT9MKujag
+ elements:
+ - name: " (3)"
+ type: text
+ title_text: ''
+ subtitle_text: ''
+ body_text: "
"
+ row: 0
+ col: 0
+ width: 24
+ height: 4
+ - name: " (4)"
+ type: text
+ title_text: ''
+ subtitle_text: ''
+ body_text: "
\n\t
"
+ row: 0
+ col: 0
+ width: 20
+ height: 2
+ - type: button
+ name: button_984
+ rich_content_json: '{"text":"Go to top","description":"This button is for redirecting
+ back to the top of the page","newTab":false,"alignment":"center","size":"medium","style":"FILLED","color":"#1A73E8","href":"#top"}'
+ row: 37
+ col: 0
+ width: 24
+ height: 1
+ - name: ''
+ type: text
+ title_text: ''
+ subtitle_text: ''
+ body_text: '[{"type":"h1","children":[{"text":"Prediction Statistics"}],"align":"center"}]'
+ rich_content_json: '{"format":"slate"}'
+ row: 0
+ col: 0
+ width: 22
+ height: 2
+ - title: Prediction Split by Revenue (USD)
+ name: Prediction Split by Revenue (USD)
+ model: ga4
+ explore: sessions
+ type: looker_grid
+ fields: [future_purchase_prediction.pred_probability_bucket, purchase_average_usd,
+ events.total_purchase_revenue_usd, future_purchase_prediction.count]
+ fill_fields: [future_purchase_prediction.pred_probability_bucket]
+ filters:
+ future_purchase_prediction.user_pseudo_id: NOT NULL
+ sorts: [future_purchase_prediction.pred_probability_bucket desc]
+ limit: 500
+ column_limit: 50
+ dynamic_fields:
+ - measure: sum_of_ecommerce_purchase_revenue_in_usd
+ based_on: events.ecommerce__purchase_revenue_in_usd
+ expression: ''
+ label: Sum of Ecommerce Purchase Revenue In USD
+ type: sum
+ _kind_hint: measure
+ _type_hint: number
+ - category: measure
+ expression: ''
+ label: Purchase Average (USD)
+ based_on: events.ecommerce__purchase_revenue_in_usd
+ _kind_hint: measure
+ measure: purchase_average_usd
+ type: average
+ _type_hint: number
+ query_timezone: America/Ciudad_Juarez
+ 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_labels:
+ future_purchase_prediction.pred_probability_bucket: Probability Bucket
+ series_cell_visualizations:
+ purchase_average_usd:
+ is_active: true
+ palette:
+ palette_id: 6a5ea9e4-0c4e-7ef3-7e2d-e03007a150eb
+ collection_id: test
+ custom_colors:
+ - "#F9AB00"
+ - "#B31412"
+ - "#1A73E8"
+ events.total_purchase_revenue_usd:
+ is_active: false
+ palette:
+ palette_id: d93e9311-ec5a-f320-de6e-a1d6d68ecfc9
+ collection_id: test
+ custom_colors:
+ - "#F9AB00"
+ - "#1A73E8"
+ - "#B31412"
+ hidden_pivots: {}
+ 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
+ listen:
+ Session Date: sessions.session_date
+ row: 4
+ col: 0
+ width: 22
+ height: 4
+ - title: Low Prob user_ids
+ name: Low Prob user_ids
+ model: ga4
+ explore: sessions
+ type: single_value
+ fields: [future_purchase_prediction.count]
+ filters:
+ 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
+ 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: 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 ''}]
+ defaults_version: 1
+ hidden_pivots: {}
+ listen:
+ Session Date: sessions.session_date
+ row: 2
+ col: 15
+ width: 7
+ height: 2
+ - title: Medium Prob cust_ids
+ name: Medium Prob cust_ids
+ model: ga4
+ explore: sessions
+ type: single_value
+ fields: [future_purchase_prediction.count]
+ filters:
+ 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
+ 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: 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 ''}]
+ defaults_version: 1
+ hidden_pivots: {}
+ listen:
+ Session Date: sessions.session_date
+ row: 2
+ col: 8
+ width: 7
+ height: 2
+ - title: High Prob cust_ids
+ name: High Prob cust_ids
+ model: ga4
+ explore: sessions
+ type: single_value
+ fields: [future_purchase_prediction.count]
+ filters:
+ 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
+ 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
+ custom_color: "#fcf9ff"
+ 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 ''}]
+ defaults_version: 1
+ listen:
+ Session Date: sessions.session_date
+ row: 2
+ col: 0
+ width: 8
+ height: 2
+ - title: Rolling 90 day Person Count by Predicted Bucket Across Weeks
+ name: Rolling 90 day Person Count by Predicted Bucket Across Weeks
+ model: ga4
+ explore: incremental_prediction
+ type: looker_line
+ fields: [incremental_prediction.week, incremental_prediction.pred_probability_bucket,
+ incremental_prediction.count]
+ pivots: [incremental_prediction.pred_probability_bucket]
+ sorts: [incremental_prediction.pred_probability_bucket, incremental_prediction.week,
+ incremental_prediction.count desc 0]
+ limit: 500
+ column_limit: 50
+ query_timezone: America/Ciudad_Juarez
+ 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: false
+ 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
+ color_application:
+ 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,
+ id: High - incremental_prediction.count, name: High}, {axisId: incremental_prediction.count,
+ id: Low - incremental_prediction.count, name: Low}, {axisId: incremental_prediction.count,
+ id: Medium - incremental_prediction.count, name: Medium}], showLabels: true,
+ showValues: true, unpinAxis: false, tickDensity: default, tickDensityCustom: 5,
+ type: linear}]
+ x_axis_zoom: true
+ y_axis_zoom: true
+ hide_legend: false
+ swap_axes: false
+ ordering: none
+ show_null_labels: false
+ show_totals_labels: false
+ show_silhouette: false
+ totals_color: "#808080"
+ defaults_version: 1
+ hidden_fields: []
+ hidden_points_if_no: []
+ hidden_pivots: {}
+ listen: {}
+ row: 8
+ col: 0
+ width: 22
+ height: 6
+ - title: Rolling 90 day Revenue (USD) by Predicted Bucket Across Weeks
+ name: Rolling 90 day Revenue (USD) by Predicted Bucket Across Weeks
+ model: ga4
+ explore: incremental_prediction
+ type: looker_line
+ fields: [incremental_prediction.week, incremental_prediction.pred_probability_bucket,
+ incremental_prediction.total_purchase_revenue_usd]
+ pivots: [incremental_prediction.pred_probability_bucket]
+ sorts: [incremental_prediction.pred_probability_bucket, incremental_prediction.week]
+ limit: 500
+ column_limit: 50
+ query_timezone: America/Ciudad_Juarez
+ 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: false
+ 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
+ color_application:
+ 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,
+ id: High - incremental_prediction.count, name: High}, {axisId: incremental_prediction.count,
+ id: Low - incremental_prediction.count, name: Low}, {axisId: incremental_prediction.count,
+ id: Medium - incremental_prediction.count, name: Medium}], showLabels: true,
+ showValues: true, unpinAxis: false, tickDensity: default, tickDensityCustom: 5,
+ type: linear}]
+ x_axis_zoom: true
+ y_axis_zoom: true
+ hide_legend: false
+ swap_axes: false
+ ordering: none
+ show_null_labels: false
+ show_totals_labels: false
+ show_silhouette: false
+ totals_color: "#808080"
+ defaults_version: 1
+ hidden_fields: []
+ hidden_points_if_no: []
+ hidden_pivots: {}
+ listen: {}
+ row: 14
+ col: 0
+ width: 22
+ height: 6
+ filters:
+ - name: Session Date
+ title: Session Date
+ type: field_filter
+ default_value: 90 day
+ allow_multiple_values: true
+ required: true
+ ui_config:
+ type: relative_timeframes
+ display: inline
+ options: []
+ model: ga4
+ explore: sessions
+ listens_to_filters: []
+ field: sessions.session_date
\ No newline at end of file
diff --git a/explores/.gitkeep b/explores/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/explores/sessions.explore.lkml b/explores/sessions.explore.lkml
new file mode 100644
index 0000000..b0e3e5f
--- /dev/null
+++ b/explores/sessions.explore.lkml
@@ -0,0 +1,127 @@
+include: "/views/*.view.lkml"
+include: "/views/*/*.view.lkml"
+include: "/views/*/*/*.view.lkml"
+include: "/attributes/*.lkml"
+
+explore: sessions {
+ label: "GA4 Sessions Beta"
+ description: "Explores Google Analytics sessions data."
+
+ join: audience_cohorts {
+ type: left_outer
+ sql_on: ${sessions.audience_trait} = ${audience_cohorts.audience_trait} ;;
+ relationship: many_to_one
+ }
+
+ join: events {
+ view_label: "Events"
+ sql: LEFT JOIN UNNEST(${sessions.event_data}) as events with offset as event_row ;;
+ relationship: one_to_many
+ }
+
+ join: event_data_items {
+ view_label: "Events"
+ sql: LEFT JOIN UNNEST(${events.items}) as event_data_items ;;
+ relationship: one_to_many
+ required_joins: [events]
+ }
+
+ join: user_previous_session {
+ view_label: "GA4 Sessions"
+ sql_on: ${sessions.sl_key} = ${user_previous_session.sl_key} ;;
+ relationship: one_to_one
+ }
+ join: user_first_session {
+ view_label: "GA4 Sessions"
+ sql_on: ${sessions.sl_key} = ${user_first_session.sl_key} ;;
+ relationship: one_to_one
+ }
+
+ join: user_segment {
+ type: left_outer
+ sql_on: ${sessions.user_pseudo_id} = ${user_segment.user_pseudo_id} ;;
+ relationship: many_to_one
+ }
+
+ join: future_purchase_prediction {
+ view_label: "Propensity to Purchase"
+ relationship: one_to_one
+ # sql_on: ${sessions.sl_key} = ${future_purchase_prediction.sl_key} ;;
+ sql_on: ${sessions.user_pseudo_id} = ${future_purchase_prediction.user_pseudo_id} ;;
+ }
+
+ join: paid_shopping {
+ fields: []
+ sql_on: ${sessions.session_attribution_source}=${paid_shopping.channel}
+ or REGEXP_CONTAINS(${sessions.session_attribution_campaign}, r"^(.*(([^a-df-z]|^)shop|shopping).*)$") = true
+ and REGEXP_CONTAINS(${sessions.session_attribution_medium}, r"^(.*cp.*|ppc|paid.*)$") = true;;
+ relationship: many_to_one
+ }
+ join: paid_social {
+ fields: []
+ sql_on: ${sessions.session_attribution_source}=${paid_social.channel} and
+ REGEXP_CONTAINS(${sessions.session_attribution_medium}, r"^(.*cp.*|ppc|paid.*)$") = true ;;
+ relationship: many_to_one
+ }
+
+ join: paid_video {
+ fields: []
+ sql_on: ${sessions.session_attribution_source}=${paid_video.channel} and
+ REGEXP_CONTAINS(${sessions.session_attribution_medium}, r"^(.*cp.*|ppc|paid.*)$") = true;;
+ relationship: many_to_one
+ }
+ join: paid_search {
+ fields: []
+ sql_on: ${sessions.session_attribution_source}=${paid_search.channel}
+ and REGEXP_CONTAINS(${sessions.session_attribution_medium}, r"^(.*cp.*|ppc|paid.*)$") = true;;
+ relationship: many_to_one
+ }
+ join: organic_shopping {
+ fields: []
+ sql_on: ${sessions.session_attribution_source}=${organic_shopping.channel}
+ or REGEXP_CONTAINS(${sessions.session_attribution_campaign}, r"^(.*(([^a-df-z]|^)shop|shopping).*)$") = true;;
+ relationship: many_to_one
+ }
+ join: organic_social {
+ fields: []
+ sql_on: ${sessions.session_attribution_source}=${organic_social.channel}
+ or REGEXP_CONTAINS(${sessions.session_attribution_medium}, r"(social|social-network|social-media|sm|social network|social media)") = true;;
+ relationship: many_to_one
+ }
+ join: organic_video {
+ fields: []
+ sql_on: ${sessions.session_attribution_source}=${organic_video.channel}
+ or REGEXP_CONTAINS(${sessions.session_attribution_medium}, r"^(.*video.*)$") = true;;
+ relationship: many_to_one
+ }
+ join: organic_search {
+ fields: []
+ sql_on: ${sessions.session_attribution_source}=${organic_video.channel}
+ or ${sessions.session_attribution_medium} = 'organic';;
+ relationship: many_to_one
+ }
+ join: others {
+ fields: []
+ 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/manifest.lkml b/manifest.lkml
new file mode 100644
index 0000000..72593b8
--- /dev/null
+++ b/manifest.lkml
@@ -0,0 +1,40 @@
+project_name: "ga_four"
+
+## Connection Constants:
+constant: GA4_CONNECTION {
+ value: ""
+ export: override_required
+}
+
+constant: GA4_SCHEMA {
+ value: "ga4_export"
+ export: override_optional
+}
+
+constant: GA4_TABLE_VARIABLE {
+ value: "events_*"
+ export: override_optional
+}
+constant: EVENT_COUNT {
+ value: ""
+ export: override_optional
+}
+constant: model_step_prediction {
+ value: "60"
+ #export: override_optional
+}
+
+constant: GA4_BQML_train_months {
+ value: "12"
+ # export: override_optional
+}
+
+constant: GA4_BQML_test_months {
+ value: "3"
+ # export: override_optional
+}
+
+constant: GA4_BQML_future_synth_months {
+ value: "12"
+ # export: override_optional
+}
diff --git a/marketplace.json b/marketplace.json
new file mode 100644
index 0000000..f138f36
--- /dev/null
+++ b/marketplace.json
@@ -0,0 +1,29 @@
+{
+ "label": "Google Analytics 4 - Web Analytics",
+ "category_label": "Models",
+ "branding": {
+ "image_uri": "https://marketplace-api.looker.com/block-icons/icon-google-analytics-new.png",
+ "tagline": "Analyze and activate web-traffic data in BigQuery from GA4."
+ },
+ "constants": {
+ "GA4_CONNECTION": {
+ "label": "Connection Name",
+ "value_constraint": "connection"
+ },
+ "GA4_SCHEMA": {
+ "label": "GA4 Schema"
+ },
+ "GA4_TABLE_VARIABLE": {
+ "label": "GA4 Table Variable"
+ },
+ "EVENT_COUNT": {
+ "label": "Event Count Limit"
+ }
+ },
+ "models": [
+ {
+ "name": "ga4",
+ "connection_constant": "GA4_CONNECTION"
+ }
+ ]
+}
diff --git a/models/ga4.model.lkml b/models/ga4.model.lkml
new file mode 100644
index 0000000..bde80f9
--- /dev/null
+++ b/models/ga4.model.lkml
@@ -0,0 +1,24 @@
+connection: "@{GA4_CONNECTION}"
+
+include: "/dashboards/*.dashboard"
+include: "/explores/*.explore.lkml"
+include: "/views/**/*.view.lkml"
+
+label: "Google Analytics 4"
+
+
+datagroup: ga4_main_datagroup {
+ sql_trigger: SELECT CURRENT_DATE();;
+ max_cache_age: "3 hour"
+}
+
+datagroup: ga4_default_datagroup {
+ sql_trigger: SELECT FLOOR(((TIMESTAMP_DIFF(CURRENT_TIMESTAMP(),'1970-01-01 00:00:00',SECOND)) - 60*60*1)/(60*60*24));;
+ max_cache_age: "3 hour"
+}
+
+datagroup: ga4_attribution_channel {
+ sql_trigger: SELECT 1 ;;
+}
+
+persist_with: ga4_main_datagroup
diff --git a/views/.gitkeep b/views/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/views/attribution_sources.view.lkml b/views/attribution_sources.view.lkml
new file mode 100644
index 0000000..2766a4e
--- /dev/null
+++ b/views/attribution_sources.view.lkml
@@ -0,0 +1,12 @@
+include: "/views/attribution_sources/*.view.lkml"
+view: attribution_sources {
+dimension: attribution_source_channel {
+ group_label: "Session Traffic Source"
+ label: "Channel"
+ type: string
+ sql: COALESCE(${paid_shopping.source},
+ ${paid_social.source},${paid_search.source},
+ ${paid_video.source},${organic_shopping.source},${organic_social.source},
+ ${organic_video.source},${organic_search.source},${others.source},"Other");;
+}
+}
diff --git a/views/attribution_sources/organic_search.view.lkml b/views/attribution_sources/organic_search.view.lkml
new file mode 100644
index 0000000..1093e9d
--- /dev/null
+++ b/views/attribution_sources/organic_search.view.lkml
@@ -0,0 +1,150 @@
+view: organic_search {
+ derived_table: {
+ datagroup_trigger:attribution_channel
+ sql: select '360.cn' as channel, 'Organic Search'as source UNION ALL
+ select 'babylon' as channel, 'Organic Search'as source UNION ALL
+ select 'centrum.cz' as channel, 'Organic Search'as source UNION ALL
+ select 'conduit' as channel, 'Organic Search'as source UNION ALL
+ select 'duckduckgo' as channel, 'Organic Search'as source UNION ALL
+ select 'excite.com' as channel, 'Organic Search'as source UNION ALL
+ select 'google.com' as channel, 'Organic Search'as source UNION ALL
+ select 'it.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'mail.google.com' as channel, 'Organic Search'as source UNION ALL
+ select 'najdi' as channel, 'Organic Search'as source UNION ALL
+ select 'onet' as channel, 'Organic Search'as source UNION ALL
+ select 'rambler' as channel, 'Organic Search'as source UNION ALL
+ select 'search.smt.docomo.ne.jp' as channel, 'Organic Search'as source UNION ALL
+ select 'sogou.com' as channel, 'Organic Search'as source UNION ALL
+ select 'tr.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'vn.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'yandex' as channel, 'Organic Search'as source UNION ALL
+ select 'alice' as channel, 'Organic Search'as source UNION ALL
+ select 'baidu' as channel, 'Organic Search'as source UNION ALL
+ select 'ch.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'cse.google.com' as channel, 'Organic Search'as source UNION ALL
+ select 'ecosia.org' as channel, 'Organic Search'as source UNION ALL
+ select 'fi.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'googlemybusiness' as channel, 'Organic Search'as source UNION ALL
+ select 'kvasir' as channel, 'Organic Search'as source UNION ALL
+ select 'mail.rambler.ru' as channel, 'Organic Search'as source UNION ALL
+ select 'naver' as channel, 'Organic Search'as source UNION ALL
+ select 'onet.pl' as channel, 'Organic Search'as source UNION ALL
+ select 'rambler.ru' as channel, 'Organic Search'as source UNION ALL
+ select 'search.ukr.net' as channel, 'Organic Search'as source UNION ALL
+ select 'sp-web.search.auone.jp' as channel, 'Organic Search'as source UNION ALL
+ select 'tut.by' as channel, 'Organic Search'as source UNION ALL
+ select 'wap.sogou.com' as channel, 'Organic Search'as source UNION ALL
+ select 'yandex.by' as channel, 'Organic Search'as source UNION ALL
+ select 'aol' as channel, 'Organic Search'as source UNION ALL
+ select 'biglobe' as channel, 'Organic Search'as source UNION ALL
+ select 'cl.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'daum' as channel, 'Organic Search'as source UNION ALL
+ select 'email.seznam.cz' as channel, 'Organic Search'as source UNION ALL
+ select 'firmy.cz' as channel, 'Organic Search'as source UNION ALL
+ select 'hk.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'lite.qwant.com' as channel, 'Organic Search'as source UNION ALL
+ select 'mail.yandex.ru' as channel, 'Organic Search'as source UNION ALL
+ select 'naver.com' as channel, 'Organic Search'as source UNION ALL
+ select 'pe.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'se.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'secureurl.ukr.net' as channel, 'Organic Search'as source UNION ALL
+ select 'startsiden' as channel, 'Organic Search'as source UNION ALL
+ select 'tw.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'webmaster.yandex.ru' as channel, 'Organic Search'as source UNION ALL
+ select 'yandex.com' as channel, 'Organic Search'as source UNION ALL
+ select 'ar.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'biglobe.co.jp' as channel, 'Organic Search'as source UNION ALL
+ select 'cn.bing.com' as channel, 'Organic Search'as source UNION ALL
+ select 'daum.net' as channel, 'Organic Search'as source UNION ALL
+ select 'eniro' as channel, 'Organic Search'as source UNION ALL
+ select 'fr.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'id.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'lycos' as channel, 'Organic Search'as source UNION ALL
+ select 'malaysia.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'news.google.com' as channel, 'Organic Search'as source UNION ALL
+ select 'ph.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'search-results' as channel, 'Organic Search'as source UNION ALL
+ select 'seznam' as channel, 'Organic Search'as source UNION ALL
+ select 'startsiden.no' as channel, 'Organic Search'as source UNION ALL
+ select 'uk.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'websearch.rakuten.co.jp' as channel, 'Organic Search'as source UNION ALL
+ select 'yandex.com.tr' as channel, 'Organic Search'as source UNION ALL
+ select 'ask' as channel, 'Organic Search'as source UNION ALL
+ select 'biglobe.ne.jp' as channel, 'Organic Search'as source UNION ALL
+ select 'cnn' as channel, 'Organic Search'as source UNION ALL
+ select 'de.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'es.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'globo' as channel, 'Organic Search'as source UNION ALL
+ select 'in.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'm.baidu.com' as channel, 'Organic Search'as source UNION ALL
+ select 'msn' as channel, 'Organic Search'as source UNION ALL
+ select 'nl.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'pl.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'search.aol.co.uk' as channel, 'Organic Search'as source UNION ALL
+ select 'seznam.cz' as channel, 'Organic Search'as source UNION ALL
+ select 'suche.aol.de' as channel, 'Organic Search'as source UNION ALL
+ select 'ukr' as channel, 'Organic Search'as source UNION ALL
+ select 'yahoo' as channel, 'Organic Search'as source UNION ALL
+ select 'yandex.fr' as channel, 'Organic Search'as source UNION ALL
+ select 'at.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'bing' as channel, 'Organic Search'as source UNION ALL
+ select 'co.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'dk.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'espanol.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'go.mail.ru' as channel, 'Organic Search'as source UNION ALL
+ select 'incredimail' as channel, 'Organic Search'as source UNION ALL
+ select 'm.naver.com' as channel, 'Organic Search'as source UNION ALL
+ select 'msn.com' as channel, 'Organic Search'as source UNION ALL
+ select 'no.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'qwant' as channel, 'Organic Search'as source UNION ALL
+ select 'search.aol.com' as channel, 'Organic Search'as source UNION ALL
+ select 'sg.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'terra' as channel, 'Organic Search'as source UNION ALL
+ select 'us.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'yahoo.co.jp' as channel, 'Organic Search'as source UNION ALL
+ select 'yandex.kz' as channel, 'Organic Search'as source UNION ALL
+ select 'au.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'br.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'comcast' as channel, 'Organic Search'as source UNION ALL
+ select 'dogpile' as channel, 'Organic Search'as source UNION ALL
+ select 'exalead.com' as channel, 'Organic Search'as source UNION ALL
+ select 'google' as channel, 'Organic Search'as source UNION ALL
+ select 'm.search.naver.com' as channel, 'Organic Search'as source UNION ALL
+ select 'mx.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'ntp.msn.com' as channel, 'Organic Search'as source UNION ALL
+ select 'qwant.com' as channel, 'Organic Search'as source UNION ALL
+ select 'search.google.com' as channel, 'Organic Search'as source UNION ALL
+ select 'so.com' as channel, 'Organic Search'as source UNION ALL
+ select 'th.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'virgilio' as channel, 'Organic Search'as source UNION ALL
+ select 'yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'yandex.ru' as channel, 'Organic Search'as source UNION ALL
+ select 'auone' as channel, 'Organic Search'as source UNION ALL
+ select 'ca.search.yahoo.com' as channel, 'Organic Search'as source UNION ALL
+ select 'dogpile.com' as channel, 'Organic Search'as source UNION ALL
+ select 'google-play' as channel, 'Organic Search'as source UNION ALL
+ select 'm.sogou.com' as channel, 'Organic Search'as source ;;
+ }
+
+ measure: count {
+ type: count
+ drill_fields: [detail*]
+ }
+
+ dimension: channel {
+ type: string
+ sql: ${TABLE}.channel ;;
+ }
+
+ dimension: source {
+ type: string
+ sql: ${TABLE}.source ;;
+ }
+
+ set: detail {
+ fields: [
+ channel,
+ source
+ ]
+ }
+}
diff --git a/views/attribution_sources/organic_shopping.view.lkml b/views/attribution_sources/organic_shopping.view.lkml
new file mode 100644
index 0000000..3f34109
--- /dev/null
+++ b/views/attribution_sources/organic_shopping.view.lkml
@@ -0,0 +1,77 @@
+view: organic_shopping {
+ derived_table: {
+ datagroup_trigger:attribution_channel
+ sql: select 'Google Shopping' as channel, 'Organic Shopping'as source UNION ALL
+ select 'alibaba.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'cr.shopping.naver.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'etsy' as channel, 'Organic Shopping'as source UNION ALL
+ select 'mercadolibre.com.mx' as channel, 'Organic Shopping'as source UNION ALL
+ select 'one.walmart.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'shopify.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'store.shopping.yahoo.co.jp' as channel, 'Organic Shopping'as source UNION ALL
+ select 'IGShopping' as channel, 'Organic Shopping'as source UNION ALL
+ select 'amazon' as channel, 'Organic Shopping'as source UNION ALL
+ select 'cr2.shopping.naver.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'etsy.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'message.alibaba.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'order.shopping.yahoo.co.jp' as channel, 'Organic Shopping'as source UNION ALL
+ select 'shopping.naver.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'stripe' as channel, 'Organic Shopping'as source UNION ALL
+ select 'aax-us-east.amazon-adsystem.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'amazon.co.uk' as channel, 'Organic Shopping'as source UNION ALL
+ select 'ebay' as channel, 'Organic Shopping'as source UNION ALL
+ select 'm.alibaba.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'msearch.shopping.naver.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'partners.shopify.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'shopping.yahoo.co.jp' as channel, 'Organic Shopping'as source UNION ALL
+ select 'stripe.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'aax.amazon-adsystem.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'amazon.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'ebay.co.uk' as channel, 'Organic Shopping'as source UNION ALL
+ select 'm.shopping.naver.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'nl.shopping.net' as channel, 'Organic Shopping'as source UNION ALL
+ select 's3.amazonaws.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'shopping.yahoo.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'uk.shopping.net' as channel, 'Organic Shopping'as source UNION ALL
+ select 'alibaba' as channel, 'Organic Shopping'as source UNION ALL
+ select 'apps.shopify.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'ebay.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'mercadolibre' as channel, 'Organic Shopping'as source UNION ALL
+ select 'no.shopping.net' as channel, 'Organic Shopping'as source UNION ALL
+ select 'se.shopping.net' as channel, 'Organic Shopping'as source UNION ALL
+ select 'shopzilla' as channel, 'Organic Shopping'as source UNION ALL
+ select 'walmart' as channel, 'Organic Shopping'as source UNION ALL
+ select 'checkout.shopify.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'ebay.com.au' as channel, 'Organic Shopping'as source UNION ALL
+ select 'mercadolibre.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'offer.alibaba.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'shop.app' as channel, 'Organic Shopping'as source UNION ALL
+ select 'shopzilla.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'walmart.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'checkout.stripe.com' as channel, 'Organic Shopping'as source UNION ALL
+ select 'ebay.de' as channel, 'Organic Shopping'as source UNION ALL
+ select 'mercadolibre.com.ar' as channel, 'Organic Shopping'as source ;;
+ }
+
+ measure: count {
+ type: count
+ drill_fields: [detail*]
+ }
+
+ dimension: channel {
+ type: string
+ sql: ${TABLE}.channel ;;
+ }
+
+ dimension: source {
+ type: string
+ sql: ${TABLE}.source ;;
+ }
+
+ set: detail {
+ fields: [
+ channel,
+ source
+ ]
+ }
+}
diff --git a/views/attribution_sources/organic_social.view.lkml b/views/attribution_sources/organic_social.view.lkml
new file mode 100644
index 0000000..15de03b
--- /dev/null
+++ b/views/attribution_sources/organic_social.view.lkml
@@ -0,0 +1,498 @@
+view: organic_social {
+ derived_table: {
+ datagroup_trigger:attribution_channel
+ sql: select '43things' as channel, 'Organic Social' as source UNION ALL
+ select 'ameblo.jp' as channel, 'Organic Social' as source UNION ALL
+ select 'askubuntu.com' as channel, 'Organic Social' as source UNION ALL
+ select 'biip.no' as channel, 'Organic Social' as source UNION ALL
+ select 'bloglines' as channel, 'Organic Social' as source UNION ALL
+ select 'business.facebook.com' as channel, 'Organic Social' as source UNION ALL
+ select 'cellufun.com' as channel, 'Organic Social' as source UNION ALL
+ select 'couchsurfing.org' as channel, 'Organic Social' as source UNION ALL
+ select 'diigo.com' as channel, 'Organic Social' as source UNION ALL
+ select 'edublogs.org' as channel, 'Organic Social' as source UNION ALL
+ select 'feministing.com' as channel, 'Organic Social' as source UNION ALL
+ select 'forums.webosnation.com' as channel, 'Organic Social' as source UNION ALL
+ select 'gamerdna' as channel, 'Organic Social' as source UNION ALL
+ select 'googlegroups.com' as channel, 'Organic Social' as source UNION ALL
+ select 'hr.com' as channel, 'Organic Social' as source UNION ALL
+ select 'instagram.com' as channel, 'Organic Social' as source UNION ALL
+ select 'kaneva' as channel, 'Organic Social' as source UNION ALL
+ select 'livedoorblog' as channel, 'Organic Social' as source UNION ALL
+ select 'messages.google.com' as channel, 'Organic Social' as source UNION ALL
+ select 'mylife' as channel, 'Organic Social' as source UNION ALL
+ select 'odnoklassniki.ua' as channel, 'Organic Social' as source UNION ALL
+ select 'pingsta.com' as channel, 'Organic Social' as source UNION ALL
+ select 'pinterest.pt' as channel, 'Organic Social' as source UNION ALL
+ select 'quechup.com' as channel, 'Organic Social' as source UNION ALL
+ select 'scoop.it' as channel, 'Organic Social' as source UNION ALL
+ select 'slideshare.net' as channel, 'Organic Social' as source UNION ALL
+ select 'stardoll.com' as channel, 'Organic Social' as source UNION ALL
+ select 'tiktok.com' as channel, 'Organic Social' as source UNION ALL
+ select 'twitter' as channel, 'Organic Social' as source UNION ALL
+ select 'web.skype.com' as channel, 'Organic Social' as source UNION ALL
+ select 'xanga.com' as channel, 'Organic Social' as source UNION ALL
+ select '43things.com' as channel, 'Organic Social' as source UNION ALL
+ select 'americantowns' as channel, 'Organic Social' as source UNION ALL
+ select 'asmallworld.com' as channel, 'Organic Social' as source UNION ALL
+ select 'biswap.org' as channel, 'Organic Social' as source UNION ALL
+ select 'bloglines.com' as channel, 'Organic Social' as source UNION ALL
+ select 'buzzfeed' as channel, 'Organic Social' as source UNION ALL
+ select 'centerblog.net' as channel, 'Organic Social' as source UNION ALL
+ select 'cozycot' as channel, 'Organic Social' as source UNION ALL
+ select 'discover.hubpages.com' as channel, 'Organic Social' as source UNION ALL
+ select 'elftown' as channel, 'Organic Social' as source UNION ALL
+ select 'filmaffinity' as channel, 'Organic Social' as source UNION ALL
+ select 'forums.wpcentral.com' as channel, 'Organic Social' as source UNION ALL
+ select 'gamerdna.com' as channel, 'Organic Social' as source UNION ALL
+ select 'googleplus' as channel, 'Organic Social' as source UNION ALL
+ select 'hu.pinterest.com' as channel, 'Organic Social' as source UNION ALL
+ select 'instapaper' as channel, 'Organic Social' as source UNION ALL
+ select 'kaneva.com' as channel, 'Organic Social' as source UNION ALL
+ select 'livejournal' as channel, 'Organic Social' as source UNION ALL
+ select 'messages.yahoo.co.jp' as channel, 'Organic Social' as source UNION ALL
+ select 'mylife.com' as channel, 'Organic Social' as source UNION ALL
+ select 'okwave.jp' as channel, 'Organic Social' as source UNION ALL
+ select 'pinterest' as channel, 'Organic Social' as source UNION ALL
+ select 'pinterest.ru' as channel, 'Organic Social' as source UNION ALL
+ select 'quora' as channel, 'Organic Social' as source UNION ALL
+ select 'screenrant' as channel, 'Organic Social' as source UNION ALL
+ select 'smartnews.com' as channel, 'Organic Social' as source UNION ALL
+ select 'stickam' as channel, 'Organic Social' as source UNION ALL
+ select 'tinyurl' as channel, 'Organic Social' as source UNION ALL
+ select 'twitter.com' as channel, 'Organic Social' as source UNION ALL
+ select 'webshots' as channel, 'Organic Social' as source UNION ALL
+ select 'xing' as channel, 'Organic Social' as source UNION ALL
+ select '51.com' as channel, 'Organic Social' as source UNION ALL
+ select 'americantowns.com' as channel, 'Organic Social' as source UNION ALL
+ select 'athlinks' as channel, 'Organic Social' as source UNION ALL
+ select 'bit.ly' as channel, 'Organic Social' as source UNION ALL
+ select 'blogs.com' as channel, 'Organic Social' as source UNION ALL
+ select 'buzzfeed.com' as channel, 'Organic Social' as source UNION ALL
+ select 'chat.zalo.me' as channel, 'Organic Social' as source UNION ALL
+ select 'cozycot.com' as channel, 'Organic Social' as source UNION ALL
+ select 'disqus' as channel, 'Organic Social' as source UNION ALL
+ select 'elftown.com' as channel, 'Organic Social' as source UNION ALL
+ select 'filmaffinity.com' as channel, 'Organic Social' as source UNION ALL
+ select 'fotki' as channel, 'Organic Social' as source UNION ALL
+ select 'gather.com' as channel, 'Organic Social' as source UNION ALL
+ select 'govloop' as channel, 'Organic Social' as source UNION ALL
+ select 'hubculture' as channel, 'Organic Social' as source UNION ALL
+ select 'instapaper.com' as channel, 'Organic Social' as source UNION ALL
+ select 'kin.naver.com' as channel, 'Organic Social' as source UNION ALL
+ select 'livejournal.com' as channel, 'Organic Social' as source UNION ALL
+ select 'messenger' as channel, 'Organic Social' as source UNION ALL
+ select 'mymodernmet' as channel, 'Organic Social' as source UNION ALL
+ select 'old.reddit.com' as channel, 'Organic Social' as source UNION ALL
+ select 'pinterest.at' as channel, 'Organic Social' as source UNION ALL
+ select 'pinterest.se' as channel, 'Organic Social' as source UNION ALL
+ select 'quora.com' as channel, 'Organic Social' as source UNION ALL
+ select 'screenrant.com' as channel, 'Organic Social' as source UNION ALL
+ select 'snapchat' as channel, 'Organic Social' as source UNION ALL
+ select 'stickam.com' as channel, 'Organic Social' as source UNION ALL
+ select 'tinyurl.com' as channel, 'Organic Social' as source UNION ALL
+ select 'twoo.com' as channel, 'Organic Social' as source UNION ALL
+ select 'webshots.com' as channel, 'Organic Social' as source UNION ALL
+ select 'xing.com' as channel, 'Organic Social' as source UNION ALL
+ select '5ch.net' as channel, 'Organic Social' as source UNION ALL
+ select 'amp.reddit.com' as channel, 'Organic Social' as source UNION ALL
+ select 'athlinks.com' as channel, 'Organic Social' as source UNION ALL
+ select 'blackcareernetwork.com' as channel, 'Organic Social' as source UNION ALL
+ select 'blogsome' as channel, 'Organic Social' as source UNION ALL
+ select 'buzznet' as channel, 'Organic Social' as source UNION ALL
+ select 'chegg.com' as channel, 'Organic Social' as source UNION ALL
+ select 'cross.tv' as channel, 'Organic Social' as source UNION ALL
+ select 'disqus.com' as channel, 'Organic Social' as source UNION ALL
+ select 'epicurious.com' as channel, 'Organic Social' as source UNION ALL
+ select 'flickr' as channel, 'Organic Social' as source UNION ALL
+ select 'fotki.com' as channel, 'Organic Social' as source UNION ALL
+ select 'geni.com' as channel, 'Organic Social' as source UNION ALL
+ select 'govloop.com' as channel, 'Organic Social' as source UNION ALL
+ select 'hubculture.com' as channel, 'Organic Social' as source UNION ALL
+ select 'internations.org' as channel, 'Organic Social' as source UNION ALL
+ select 'l.facebook.com' as channel, 'Organic Social' as source UNION ALL
+ select 'lm.facebook.com' as channel, 'Organic Social' as source UNION ALL
+ select 'messenger.com' as channel, 'Organic Social' as source UNION ALL
+ select 'mymodernmet.com' as channel, 'Organic Social' as source UNION ALL
+ select 'oneworldgroup.org' as channel, 'Organic Social' as source UNION ALL
+ select 'pinterest.ca' as channel, 'Organic Social' as source UNION ALL
+ select 'pixiv.net' as channel, 'Organic Social' as source UNION ALL
+ select 'qzone.qq.com' as channel, 'Organic Social' as source UNION ALL
+ select 'scribd' as channel, 'Organic Social' as source UNION ALL
+ select 'snapchat.com' as channel, 'Organic Social' as source UNION ALL
+ select 'studivz.net' as channel, 'Organic Social' as source UNION ALL
+ select 'toolbox' as channel, 'Organic Social' as source UNION ALL
+ select 'typepad' as channel, 'Organic Social' as source UNION ALL
+ select 'wechat' as channel, 'Organic Social' as source UNION ALL
+ select 'yahoo-mbga.jp' as channel, 'Organic Social' as source UNION ALL
+ select 'Hatena' as channel, 'Organic Social' as source UNION ALL
+ select 'ancestry.com' as channel, 'Organic Social' as source UNION ALL
+ select 'away.vk.com' as channel, 'Organic Social' as source UNION ALL
+ select 'blackplanet' as channel, 'Organic Social' as source UNION ALL
+ select 'blogsome.com' as channel, 'Organic Social' as source UNION ALL
+ select 'buzznet.com' as channel, 'Organic Social' as source UNION ALL
+ select 'chicagonow' as channel, 'Organic Social' as source UNION ALL
+ select 'crunchyroll' as channel, 'Organic Social' as source UNION ALL
+ select 'dogster' as channel, 'Organic Social' as source UNION ALL
+ select 'everforo.com' as channel, 'Organic Social' as source UNION ALL
+ select 'flickr.com' as channel, 'Organic Social' as source UNION ALL
+ select 'fotolog' as channel, 'Organic Social' as source UNION ALL
+ select 'getpocket.com' as channel, 'Organic Social' as source UNION ALL
+ select 'gowalla' as channel, 'Organic Social' as source UNION ALL
+ select 'hubpages.com' as channel, 'Organic Social' as source UNION ALL
+ select 'interpals.net' as channel, 'Organic Social' as source UNION ALL
+ select 'l.instagram.com' as channel, 'Organic Social' as source UNION ALL
+ select 'lnkd.in' as channel, 'Organic Social' as source UNION ALL
+ select 'mix.com' as channel, 'Organic Social' as source UNION ALL
+ select 'myspace' as channel, 'Organic Social' as source UNION ALL
+ select 'onstartups' as channel, 'Organic Social' as source UNION ALL
+ select 'pinterest.ch' as channel, 'Organic Social' as source UNION ALL
+ select 'pl.pinterest.com' as channel, 'Organic Social' as source UNION ALL
+ select 'ravelry' as channel, 'Organic Social' as source UNION ALL
+ select 'scribd.com' as channel, 'Organic Social' as source UNION ALL
+ select 'sociallife.com.br' as channel, 'Organic Social' as source UNION ALL
+ select 'suomi24.fi' as channel, 'Organic Social' as source UNION ALL
+ select 'toolbox.com' as channel, 'Organic Social' as source UNION ALL
+ select 'typepad.com' as channel, 'Organic Social' as source UNION ALL
+ select 'wechat.com' as channel, 'Organic Social' as source UNION ALL
+ select 'yammer' as channel, 'Organic Social' as source UNION ALL
+ select 'ImageShack' as channel, 'Organic Social' as source UNION ALL
+ select 'anobii' as channel, 'Organic Social' as source UNION ALL
+ select 'awe.sm' as channel, 'Organic Social' as source UNION ALL
+ select 'blackplanet.com' as channel, 'Organic Social' as source UNION ALL
+ select 'blogspot' as channel, 'Organic Social' as source UNION ALL
+ select 'cafe.naver.com' as channel, 'Organic Social' as source UNION ALL
+ select 'chicagonow.com' as channel, 'Organic Social' as source UNION ALL
+ select 'crunchyroll.com' as channel, 'Organic Social' as source UNION ALL
+ select 'dogster.com' as channel, 'Organic Social' as source UNION ALL
+ select 'exblog.jp' as channel, 'Organic Social' as source UNION ALL
+ select 'flipboard' as channel, 'Organic Social' as source UNION ALL
+ select 'fotolog.com' as channel, 'Organic Social' as source UNION ALL
+ select 'glassboard' as channel, 'Organic Social' as source UNION ALL
+ select 'gowalla.com' as channel, 'Organic Social' as source UNION ALL
+ select 'hyves.net' as channel, 'Organic Social' as source UNION ALL
+ select 'intherooms' as channel, 'Organic Social' as source UNION ALL
+ select 'l.messenger.com' as channel, 'Organic Social' as source UNION ALL
+ select 'm.blog.naver.com' as channel, 'Organic Social' as source UNION ALL
+ select 'mixi.jp' as channel, 'Organic Social' as source UNION ALL
+ select 'myspace.com' as channel, 'Organic Social' as source UNION ALL
+ select 'onstartups.com' as channel, 'Organic Social' as source UNION ALL
+ select 'pinterest.cl' as channel, 'Organic Social' as source UNION ALL
+ select 'playahead.se' as channel, 'Organic Social' as source UNION ALL
+ select 'ravelry.com' as channel, 'Organic Social' as source UNION ALL
+ select 'scvngr' as channel, 'Organic Social' as source UNION ALL
+ select 'socialvibe' as channel, 'Organic Social' as source UNION ALL
+ select 'superuser' as channel, 'Organic Social' as source UNION ALL
+ select 'touch.facebook.com' as channel, 'Organic Social' as source UNION ALL
+ select 'unblog.fr' as channel, 'Organic Social' as source UNION ALL
+ select 'weebly' as channel, 'Organic Social' as source UNION ALL
+ select 'yammer.com' as channel, 'Organic Social' as source UNION ALL
+ select 'academia.edu' as channel, 'Organic Social' as source UNION ALL
+ select 'anobii.com' as channel, 'Organic Social' as source UNION ALL
+ select 'b.hatena.ne.jp' as channel, 'Organic Social' as source UNION ALL
+ select 'blip.fm' as channel, 'Organic Social' as source UNION ALL
+ select 'blogspot.com' as channel, 'Organic Social' as source UNION ALL
+ select 'cafemom' as channel, 'Organic Social' as source UNION ALL
+ select 'chiebukuro.yahoo.co.jp' as channel, 'Organic Social' as source UNION ALL
+ select 'cyworld' as channel, 'Organic Social' as source UNION ALL
+ select 'dol2day' as channel, 'Organic Social' as source UNION ALL
+ select 'extole' as channel, 'Organic Social' as source UNION ALL
+ select 'flipboard.com' as channel, 'Organic Social' as source UNION ALL
+ select 'foursquare' as channel, 'Organic Social' as source UNION ALL
+ select 'glassboard.com' as channel, 'Organic Social' as source UNION ALL
+ select 'gree.jp' as channel, 'Organic Social' as source UNION ALL
+ select 'hyves.nl' as channel, 'Organic Social' as source UNION ALL
+ select 'intherooms.com' as channel, 'Organic Social' as source UNION ALL
+ select 'last.fm' as channel, 'Organic Social' as source UNION ALL
+ select 'm.cafe.naver.com' as channel, 'Organic Social' as source UNION ALL
+ select 'mobile.facebook.com' as channel, 'Organic Social' as source UNION ALL
+ select 'netvibes' as channel, 'Organic Social' as source UNION ALL
+ select 'opendiary' as channel, 'Organic Social' as source UNION ALL
+ select 'pinterest.co.kr' as channel, 'Organic Social' as source UNION ALL
+ select 'plurk' as channel, 'Organic Social' as source UNION ALL
+ select 'reddit' as channel, 'Organic Social' as source UNION ALL
+ select 'scvngr.com' as channel, 'Organic Social' as source UNION ALL
+ select 'socialvibe.com' as channel, 'Organic Social' as source UNION ALL
+ select 'superuser.com' as channel, 'Organic Social' as source UNION ALL
+ select 'tr.pinterest.com' as channel, 'Organic Social' as source UNION ALL
+ select 'urbanspoon.com' as channel, 'Organic Social' as source UNION ALL
+ select 'weebly.com' as channel, 'Organic Social' as source UNION ALL
+ select 'yelp' as channel, 'Organic Social' as source UNION ALL
+ select 'activerain' as channel, 'Organic Social' as source UNION ALL
+ select 'answerbag' as channel, 'Organic Social' as source UNION ALL
+ select 'baby-gaga' as channel, 'Organic Social' as source UNION ALL
+ select 'blog.com' as channel, 'Organic Social' as source UNION ALL
+ select 'blogster' as channel, 'Organic Social' as source UNION ALL
+ select 'cafemom.com' as channel, 'Organic Social' as source UNION ALL
+ select 'classmates' as channel, 'Organic Social' as source UNION ALL
+ select 'cyworld.com' as channel, 'Organic Social' as source UNION ALL
+ select 'dol2day.com' as channel, 'Organic Social' as source UNION ALL
+ select 'extole.com' as channel, 'Organic Social' as source UNION ALL
+ select 'folkdirect' as channel, 'Organic Social' as source UNION ALL
+ select 'foursquare.com' as channel, 'Organic Social' as source UNION ALL
+ select 'glassdoor' as channel, 'Organic Social' as source UNION ALL
+ select 'groups.google.com' as channel, 'Organic Social' as source UNION ALL
+ select 'ibibo' as channel, 'Organic Social' as source UNION ALL
+ select 'irc-galleria.net' as channel, 'Organic Social' as source UNION ALL
+ select 'librarything' as channel, 'Organic Social' as source UNION ALL
+ select 'm.facebook.com' as channel, 'Organic Social' as source UNION ALL
+ select 'mocospace' as channel, 'Organic Social' as source UNION ALL
+ select 'netvibes.com' as channel, 'Organic Social' as source UNION ALL
+ select 'opendiary.com' as channel, 'Organic Social' as source UNION ALL
+ select 'pinterest.co.uk' as channel, 'Organic Social' as source UNION ALL
+ select 'plurk.com' as channel, 'Organic Social' as source UNION ALL
+ select 'reddit.com' as channel, 'Organic Social' as source UNION ALL
+ select 'secondlife' as channel, 'Organic Social' as source UNION ALL
+ select 'spaces.live.com' as channel, 'Organic Social' as source UNION ALL
+ select 'sweeva' as channel, 'Organic Social' as source UNION ALL
+ select 'travellerspoint' as channel, 'Organic Social' as source UNION ALL
+ select 'ushareit.com' as channel, 'Organic Social' as source UNION ALL
+ select 'weibo' as channel, 'Organic Social' as source UNION ALL
+ select 'yelp.co.uk' as channel, 'Organic Social' as source UNION ALL
+ select 'activerain.com' as channel, 'Organic Social' as source UNION ALL
+ select 'answerbag.com' as channel, 'Organic Social' as source UNION ALL
+ select 'baby-gaga.com' as channel, 'Organic Social' as source UNION ALL
+ select 'blog.feedspot.com' as channel, 'Organic Social' as source UNION ALL
+ select 'blogster.com' as channel, 'Organic Social' as source UNION ALL
+ select 'camospace' as channel, 'Organic Social' as source UNION ALL
+ select 'classmates.com' as channel, 'Organic Social' as source UNION ALL
+ select 'cz.pinterest.com' as channel, 'Organic Social' as source UNION ALL
+ select 'doostang' as channel, 'Organic Social' as source UNION ALL
+ select 'facebook' as channel, 'Organic Social' as source UNION ALL
+ select 'folkdirect.com' as channel, 'Organic Social' as source UNION ALL
+ select 'free.facebook.com' as channel, 'Organic Social' as source UNION ALL
+ select 'glassdoor.com' as channel, 'Organic Social' as source UNION ALL
+ select 'gulli.com' as channel, 'Organic Social' as source UNION ALL
+ select 'ibibo.com' as channel, 'Organic Social' as source UNION ALL
+ select 'is.gd' as channel, 'Organic Social' as source UNION ALL
+ select 'librarything.com' as channel, 'Organic Social' as source UNION ALL
+ select 'm.kin.naver.com' as channel, 'Organic Social' as source UNION ALL
+ select 'mocospace.com' as channel, 'Organic Social' as source UNION ALL
+ select 'news.ycombinator.com' as channel, 'Organic Social' as source UNION ALL
+ select 'oshiete.goo.ne.jp' as channel, 'Organic Social' as source UNION ALL
+ select 'pinterest.com' as channel, 'Organic Social' as source UNION ALL
+ select 'plus.google.com' as channel, 'Organic Social' as source UNION ALL
+ select 'redux' as channel, 'Organic Social' as source UNION ALL
+ select 'secondlife.com' as channel, 'Organic Social' as source UNION ALL
+ select 'spoke' as channel, 'Organic Social' as source UNION ALL
+ select 'sweeva.com' as channel, 'Organic Social' as source UNION ALL
+ select 'travellerspoint.com' as channel, 'Organic Social' as source UNION ALL
+ select 'ushi.cn' as channel, 'Organic Social' as source UNION ALL
+ select 'weibo.com' as channel, 'Organic Social' as source UNION ALL
+ select 'yelp.com' as channel, 'Organic Social' as source UNION ALL
+ select 'activeworlds' as channel, 'Organic Social' as source UNION ALL
+ select 'answers.yahoo.com' as channel, 'Organic Social' as source UNION ALL
+ select 'babyblog.ru' as channel, 'Organic Social' as source UNION ALL
+ select 'blog.goo.ne.jp' as channel, 'Organic Social' as source UNION ALL
+ select 'blurtit' as channel, 'Organic Social' as source UNION ALL
+ select 'camospace.com' as channel, 'Organic Social' as source UNION ALL
+ select 'classquest' as channel, 'Organic Social' as source UNION ALL
+ select 'd.hatena.ne.jp' as channel, 'Organic Social' as source UNION ALL
+ select 'doostang.com' as channel, 'Organic Social' as source UNION ALL
+ select 'facebook.com' as channel, 'Organic Social' as source UNION ALL
+ select 'foodservice' as channel, 'Organic Social' as source UNION ALL
+ select 'friendfeed' as channel, 'Organic Social' as source UNION ALL
+ select 'godtube' as channel, 'Organic Social' as source UNION ALL
+ select 'gutefrage.net' as channel, 'Organic Social' as source UNION ALL
+ select 'id.pinterest.com' as channel, 'Organic Social' as source UNION ALL
+ select 'italki' as channel, 'Organic Social' as source UNION ALL
+ select 'lifestream.aol.com' as channel, 'Organic Social' as source UNION ALL
+ select 'm.vk.com' as channel, 'Organic Social' as source UNION ALL
+ select 'mouthshut' as channel, 'Organic Social' as source UNION ALL
+ select 'newsshowcase' as channel, 'Organic Social' as source UNION ALL
+ select 'out.reddit.com' as channel, 'Organic Social' as source UNION ALL
+ select 'pinterest.com.au' as channel, 'Organic Social' as source UNION ALL
+ select 'plus.url.google.com' as channel, 'Organic Social' as source UNION ALL
+ select 'redux.com' as channel, 'Organic Social' as source UNION ALL
+ select 'serverfault' as channel, 'Organic Social' as source UNION ALL
+ select 'spoke.com' as channel, 'Organic Social' as source UNION ALL
+ select 't.co' as channel, 'Organic Social' as source UNION ALL
+ select 'tripadvisor' as channel, 'Organic Social' as source UNION ALL
+ select 'vampirefreaks' as channel, 'Organic Social' as source UNION ALL
+ select 'wer-weiss-was.de' as channel, 'Organic Social' as source UNION ALL
+ select 'youroom.in' as channel, 'Organic Social' as source UNION ALL
+ select 'activeworlds.com' as channel, 'Organic Social' as source UNION ALL
+ select 'aolanswers' as channel, 'Organic Social' as source UNION ALL
+ select 'badoo' as channel, 'Organic Social' as source UNION ALL
+ select 'blog.naver.com' as channel, 'Organic Social' as source UNION ALL
+ select 'blurtit.com' as channel, 'Organic Social' as source UNION ALL
+ select 'canalblog.com' as channel, 'Organic Social' as source UNION ALL
+ select 'classquest.com' as channel, 'Organic Social' as source UNION ALL
+ select 'dailystrength.org' as channel, 'Organic Social' as source UNION ALL
+ select 'dopplr' as channel, 'Organic Social' as source UNION ALL
+ select 'faceparty' as channel, 'Organic Social' as source UNION ALL
+ select 'foodservice.com' as channel, 'Organic Social' as source UNION ALL
+ select 'friendfeed.com' as channel, 'Organic Social' as source UNION ALL
+ select 'godtube.com' as channel, 'Organic Social' as source UNION ALL
+ select 'habbo' as channel, 'Organic Social' as source UNION ALL
+ select 'identi.ca' as channel, 'Organic Social' as source UNION ALL
+ select 'italki.com' as channel, 'Organic Social' as source UNION ALL
+ select 'line' as channel, 'Organic Social' as source UNION ALL
+ select 'm.yelp.com' as channel, 'Organic Social' as source UNION ALL
+ select 'mouthshut.com' as channel, 'Organic Social' as source UNION ALL
+ select 'nexopia' as channel, 'Organic Social' as source UNION ALL
+ select 'over-blog.com' as channel, 'Organic Social' as source UNION ALL
+ select 'pinterest.com.mx' as channel, 'Organic Social' as source UNION ALL
+ select 'pocket.co' as channel, 'Organic Social' as source UNION ALL
+ select 'renren' as channel, 'Organic Social' as source UNION ALL
+ select 'serverfault.com' as channel, 'Organic Social' as source UNION ALL
+ select 'spruz' as channel, 'Organic Social' as source UNION ALL
+ select 't.me' as channel, 'Organic Social' as source UNION ALL
+ select 'tripadvisor.com' as channel, 'Organic Social' as source UNION ALL
+ select 'vampirefreaks.com' as channel, 'Organic Social' as source UNION ALL
+ select 'weread' as channel, 'Organic Social' as source UNION ALL
+ select 'za.pinterest.com' as channel, 'Organic Social' as source UNION ALL
+ select 'addthis' as channel, 'Organic Social' as source UNION ALL
+ select 'aolanswers.com' as channel, 'Organic Social' as source UNION ALL
+ select 'badoo.com' as channel, 'Organic Social' as source UNION ALL
+ select 'blog.yahoo.co.jp' as channel, 'Organic Social' as source UNION ALL
+ select 'bookmarks.yahoo.co.jp' as channel, 'Organic Social' as source UNION ALL
+ select 'care.com' as channel, 'Organic Social' as source UNION ALL
+ select 'co.pinterest.com' as channel, 'Organic Social' as source UNION ALL
+ select 'deluxe.com' as channel, 'Organic Social' as source UNION ALL
+ select 'dopplr.com' as channel, 'Organic Social' as source UNION ALL
+ select 'faceparty.com' as channel, 'Organic Social' as source UNION ALL
+ select 'forums.androidcentral.com' as channel, 'Organic Social' as source UNION ALL
+ select 'fruehstueckstreff.org' as channel, 'Organic Social' as source UNION ALL
+ select 'goldenline.pl' as channel, 'Organic Social' as source UNION ALL
+ select 'habbo.com' as channel, 'Organic Social' as source UNION ALL
+ select 'ig' as channel, 'Organic Social' as source UNION ALL
+ select 'jammerdirect' as channel, 'Organic Social' as source UNION ALL
+ select 'line.me' as channel, 'Organic Social' as source UNION ALL
+ select 'mbga.jp' as channel, 'Organic Social' as source UNION ALL
+ select 'movabletype' as channel, 'Organic Social' as source UNION ALL
+ select 'ngopost.org' as channel, 'Organic Social' as source UNION ALL
+ select 'overblog.com' as channel, 'Organic Social' as source UNION ALL
+ select 'pinterest.de' as channel, 'Organic Social' as source UNION ALL
+ select 'posterous' as channel, 'Organic Social' as source UNION ALL
+ select 'renren.com' as channel, 'Organic Social' as source UNION ALL
+ select 'shareit' as channel, 'Organic Social' as source UNION ALL
+ select 'spruz.com' as channel, 'Organic Social' as source UNION ALL
+ select 'tagged' as channel, 'Organic Social' as source UNION ALL
+ select 'trombi' as channel, 'Organic Social' as source UNION ALL
+ select 'vampirerave' as channel, 'Organic Social' as source UNION ALL
+ select 'weread.com' as channel, 'Organic Social' as source UNION ALL
+ select 'zalo' as channel, 'Organic Social' as source UNION ALL
+ select 'addthis.com' as channel, 'Organic Social' as source UNION ALL
+ select 'apps.facebook.com' as channel, 'Organic Social' as source UNION ALL
+ select 'bebo' as channel, 'Organic Social' as source UNION ALL
+ select 'blogg.no' as channel, 'Organic Social' as source UNION ALL
+ select 'bookmarks.yahoo.com' as channel, 'Organic Social' as source UNION ALL
+ select 'care2' as channel, 'Organic Social' as source UNION ALL
+ select 'cocolog-nifty' as channel, 'Organic Social' as source UNION ALL
+ select 'deviantart' as channel, 'Organic Social' as source UNION ALL
+ select 'douban' as channel, 'Organic Social' as source UNION ALL
+ select 'fandom.com' as channel, 'Organic Social' as source UNION ALL
+ select 'forums.crackberry.com' as channel, 'Organic Social' as source UNION ALL
+ select 'fubar' as channel, 'Organic Social' as source UNION ALL
+ select 'goldstar' as channel, 'Organic Social' as source UNION ALL
+ select 'hi5' as channel, 'Organic Social' as source UNION ALL
+ select 'imageshack.com' as channel, 'Organic Social' as source UNION ALL
+ select 'jammerdirect.com' as channel, 'Organic Social' as source UNION ALL
+ select 'linkedin' as channel, 'Organic Social' as source UNION ALL
+ select 'medium.com' as channel, 'Organic Social' as source UNION ALL
+ select 'movabletype.com' as channel, 'Organic Social' as source UNION ALL
+ select 'niconico' as channel, 'Organic Social' as source UNION ALL
+ select 'paper.li' as channel, 'Organic Social' as source UNION ALL
+ select 'pinterest.es' as channel, 'Organic Social' as source UNION ALL
+ select 'posterous.com' as channel, 'Organic Social' as source UNION ALL
+ select 'researchgate.net' as channel, 'Organic Social' as source UNION ALL
+ select 'sharethis' as channel, 'Organic Social' as source UNION ALL
+ select 'ssense.com' as channel, 'Organic Social' as source UNION ALL
+ select 'tagged.com' as channel, 'Organic Social' as source UNION ALL
+ select 'trombi.com' as channel, 'Organic Social' as source UNION ALL
+ select 'vampirerave.com' as channel, 'Organic Social' as source UNION ALL
+ select 'whatsapp' as channel, 'Organic Social' as source UNION ALL
+ select 'zoo.gr' as channel, 'Organic Social' as source UNION ALL
+ select 'airg.ca' as channel, 'Organic Social' as source UNION ALL
+ select 'ar.pinterest.com' as channel, 'Organic Social' as source UNION ALL
+ select 'bebo.com' as channel, 'Organic Social' as source UNION ALL
+ select 'bloggang.com' as channel, 'Organic Social' as source UNION ALL
+ select 'br.pinterest.com' as channel, 'Organic Social' as source UNION ALL
+ select 'care2.com' as channel, 'Organic Social' as source UNION ALL
+ select 'cocolog-nifty.com' as channel, 'Organic Social' as source UNION ALL
+ select 'deviantart.com' as channel, 'Organic Social' as source UNION ALL
+ select 'douban.com' as channel, 'Organic Social' as source UNION ALL
+ select 'fanpop' as channel, 'Organic Social' as source UNION ALL
+ select 'forums.imore.com' as channel, 'Organic Social' as source UNION ALL
+ select 'fubar.com' as channel, 'Organic Social' as source UNION ALL
+ select 'goldstar.com' as channel, 'Organic Social' as source UNION ALL
+ select 'hi5.com' as channel, 'Organic Social' as source UNION ALL
+ select 'imageshack.us' as channel, 'Organic Social' as source UNION ALL
+ select 'jappy.com' as channel, 'Organic Social' as source UNION ALL
+ select 'linkedin.com' as channel, 'Organic Social' as source UNION ALL
+ select 'meetin.org' as channel, 'Organic Social' as source UNION ALL
+ select 'mubi' as channel, 'Organic Social' as source UNION ALL
+ select 'nicovideo.jp' as channel, 'Organic Social' as source UNION ALL
+ select 'partyflock.nl' as channel, 'Organic Social' as source UNION ALL
+ select 'pinterest.fr' as channel, 'Organic Social' as source UNION ALL
+ select 'pro.homeadvisor.com' as channel, 'Organic Social' as source UNION ALL
+ select 'reunion' as channel, 'Organic Social' as source UNION ALL
+ select 'sharethis.com' as channel, 'Organic Social' as source UNION ALL
+ select 'stackapps' as channel, 'Organic Social' as source UNION ALL
+ select 'taggedmail' as channel, 'Organic Social' as source UNION ALL
+ select 'tudou' as channel, 'Organic Social' as source UNION ALL
+ select 'vg.no' as channel, 'Organic Social' as source UNION ALL
+ select 'whatsapp.com' as channel, 'Organic Social' as source UNION ALL
+ select 'zooppa' as channel, 'Organic Social' as source UNION ALL
+ select 'allnurses.com' as channel, 'Organic Social' as source UNION ALL
+ select 'artstation.com' as channel, 'Organic Social' as source UNION ALL
+ select 'beforeitsnews' as channel, 'Organic Social' as source UNION ALL
+ select 'blogger' as channel, 'Organic Social' as source UNION ALL
+ select 'brightkite' as channel, 'Organic Social' as source UNION ALL
+ select 'caringbridge.org' as channel, 'Organic Social' as source UNION ALL
+ select 'copainsdavant.linternaute.com' as channel, 'Organic Social' as source UNION ALL
+ select 'dianping' as channel, 'Organic Social' as source UNION ALL
+ select 'draft.blogger.com' as channel, 'Organic Social' as source UNION ALL
+ select 'fanpop.com' as channel, 'Organic Social' as source UNION ALL
+ select 'forums.nexopia.com' as channel, 'Organic Social' as source UNION ALL
+ select 'gaiaonline' as channel, 'Organic Social' as source UNION ALL
+ select 'goo.gl' as channel, 'Organic Social' as source UNION ALL
+ select 'hootsuite' as channel, 'Organic Social' as source UNION ALL
+ select 'imvu' as channel, 'Organic Social' as source UNION ALL
+ select 'jappy.de' as channel, 'Organic Social' as source UNION ALL
+ select 'listal' as channel, 'Organic Social' as source UNION ALL
+ select 'meetup' as channel, 'Organic Social' as source UNION ALL
+ select 'mubi.com' as channel, 'Organic Social' as source UNION ALL
+ select 'nightlifelink' as channel, 'Organic Social' as source UNION ALL
+ select 'photobucket' as channel, 'Organic Social' as source UNION ALL
+ select 'pinterest.it' as channel, 'Organic Social' as source UNION ALL
+ select 'pulse.yahoo.com' as channel, 'Organic Social' as source UNION ALL
+ select 'reunion.com' as channel, 'Organic Social' as source UNION ALL
+ select 'shvoong.com' as channel, 'Organic Social' as source UNION ALL
+ select 'stackapps.com' as channel, 'Organic Social' as source UNION ALL
+ select 'taggedmail.com' as channel, 'Organic Social' as source UNION ALL
+ select 'tudou.com' as channel, 'Organic Social' as source UNION ALL
+ select 'video.ibm.com' as channel, 'Organic Social' as source UNION ALL
+ select 'wiki.answers.com' as channel, 'Organic Social' as source UNION ALL
+ select 'zooppa.com' as channel, 'Organic Social' as source UNION ALL
+ select 'allrecipes.com' as channel, 'Organic Social' as source UNION ALL
+ select 'askubuntu' as channel, 'Organic Social' as source UNION ALL
+ select 'beforeitsnews.com' as channel, 'Organic Social' as source UNION ALL
+ select 'blogger.com' as channel, 'Organic Social' as source UNION ALL
+ select 'brightkite.com' as channel, 'Organic Social' as source UNION ALL
+ select 'catster' as channel, 'Organic Social' as source ;;
+ }
+
+ measure: count {
+ type: count
+ drill_fields: [detail*]
+ }
+
+ dimension: channel {
+ type: string
+ sql: ${TABLE}.channel ;;
+ }
+
+ dimension: source {
+ type: string
+ sql: ${TABLE}.source ;;
+ }
+
+ set: detail {
+ fields: [
+ channel,
+ source
+ ]
+ }
+}
diff --git a/views/attribution_sources/organic_video.view.lkml b/views/attribution_sources/organic_video.view.lkml
new file mode 100644
index 0000000..7d35623
--- /dev/null
+++ b/views/attribution_sources/organic_video.view.lkml
@@ -0,0 +1,73 @@
+view: organic_video {
+ derived_table: {
+ datagroup_trigger:attribution_channel
+ sql: select 'blog.twitch.tv' as channel, 'Organic Video' as source UNION ALL
+ select 'dailymotion.com' as channel, 'Organic Video' as source UNION ALL
+ select 'help.netflix.com' as channel, 'Organic Video' as source UNION ALL
+ select 'justin.tv' as channel, 'Organic Video' as source UNION ALL
+ select 'player.vimeo.com' as channel, 'Organic Video' as source UNION ALL
+ select 'vimeo' as channel, 'Organic Video' as source UNION ALL
+ select 'crackle' as channel, 'Organic Video' as source UNION ALL
+ select 'dashboard.twitch.tv' as channel, 'Organic Video' as source UNION ALL
+ select 'hulu' as channel, 'Organic Video' as source UNION ALL
+ select 'm.twitch.tv' as channel, 'Organic Video' as source UNION ALL
+ select 'ted' as channel, 'Organic Video' as source UNION ALL
+ select 'vimeo.com' as channel, 'Organic Video' as source UNION ALL
+ select 'crackle.com' as channel, 'Organic Video' as source UNION ALL
+ select 'disneyplus' as channel, 'Organic Video' as source UNION ALL
+ select 'hulu.com' as channel, 'Organic Video' as source UNION ALL
+ select 'm.youtube.com' as channel, 'Organic Video' as source UNION ALL
+ select 'ted.com' as channel, 'Organic Video' as source UNION ALL
+ select 'wistia' as channel, 'Organic Video' as source UNION ALL
+ select 'curiositystream' as channel, 'Organic Video' as source UNION ALL
+ select 'disneyplus.com' as channel, 'Organic Video' as source UNION ALL
+ select 'id.twitch.tv' as channel, 'Organic Video' as source UNION ALL
+ select 'music.youtube.com' as channel, 'Organic Video' as source UNION ALL
+ select 'twitch' as channel, 'Organic Video' as source UNION ALL
+ select 'wistia.com' as channel, 'Organic Video' as source UNION ALL
+ select 'curiositystream.com' as channel, 'Organic Video' as source UNION ALL
+ select 'fast.wistia.net' as channel, 'Organic Video' as source UNION ALL
+ select 'iq.com' as channel, 'Organic Video' as source UNION ALL
+ select 'netflix' as channel, 'Organic Video' as source UNION ALL
+ select 'twitch.tv' as channel, 'Organic Video' as source UNION ALL
+ select 'youku' as channel, 'Organic Video' as source UNION ALL
+ select 'd.tube' as channel, 'Organic Video' as source UNION ALL
+ select 'help.hulu.com' as channel, 'Organic Video' as source UNION ALL
+ select 'iqiyi' as channel, 'Organic Video' as source UNION ALL
+ select 'netflix.com' as channel, 'Organic Video' as source UNION ALL
+ select 'utreon' as channel, 'Organic Video' as source UNION ALL
+ select 'youku.com' as channel, 'Organic Video' as source UNION ALL
+ select 'iqiyi.com' as channel, 'Organic Video' as source UNION ALL
+ select 'player.twitch.tv' as channel, 'Organic Video' as source UNION ALL
+ select 'utreon.com' as channel, 'Organic Video' as source UNION ALL
+ select 'youtube' as channel, 'Organic Video' as source UNION ALL
+ select 'dailymotion' as channel, 'Organic Video' as source UNION ALL
+ select 'jobs.netflix.com' as channel, 'Organic Video' as source UNION ALL
+ select 'veoh' as channel, 'Organic Video' as source UNION ALL
+ select 'youtube.com' as channel, 'Organic Video' as source UNION ALL
+ select 'veoh.com' as channel, 'Organic Video' as source UNION ALL
+ select 'viadeo.journaldunet.com' as channel, 'Organic Video' as source ;;
+ }
+
+ measure: count {
+ type: count
+ drill_fields: [detail*]
+ }
+
+ dimension: channel {
+ type: string
+ sql: ${TABLE}.channel ;;
+ }
+
+ dimension: source {
+ type: string
+ sql: ${TABLE}.source ;;
+ }
+
+ set: detail {
+ fields: [
+ channel,
+ source
+ ]
+ }
+}
diff --git a/views/attribution_sources/others.view.lkml b/views/attribution_sources/others.view.lkml
new file mode 100644
index 0000000..c0d29e1
--- /dev/null
+++ b/views/attribution_sources/others.view.lkml
@@ -0,0 +1,37 @@
+view: others {
+ derived_table: {
+ datagroup_trigger:attribution_channel
+ sql: select '(direct)' as medium, 'Direct' as source UNION ALL
+select '(direct)(none)' as medium, 'Direct' as source UNION ALL
+ select 'referral' as medium, 'Referral' as source UNION ALL
+ select 'audio' as medium, 'Audio' as source UNION ALL
+ select 'sms' as medium, 'SMS' as source UNION ALL
+ select 'mobile' as medium, 'Mobile' as source UNION ALL
+ select 'push' as medium, 'Mobile Push Notifications' as source UNION ALL
+ select 'affiliate' as medium, 'Affiliates' as source UNION ALL
+ select 'email' as medium, 'Email' as source UNION ALL
+ select 'cross network' as medium, 'Cross Network' as source;;
+ }
+
+ measure: count {
+ type: count
+ drill_fields: [detail*]
+ }
+
+ dimension: medium {
+ type: string
+ sql: ${TABLE}.medium ;;
+ }
+
+ dimension: source {
+ type: string
+ sql: ${TABLE}.source ;;
+ }
+
+ set: detail {
+ fields: [
+ medium,
+ source
+ ]
+ }
+}
diff --git a/views/attribution_sources/paid_search.view.lkml b/views/attribution_sources/paid_search.view.lkml
new file mode 100644
index 0000000..c152199
--- /dev/null
+++ b/views/attribution_sources/paid_search.view.lkml
@@ -0,0 +1,157 @@
+view: paid_search {
+ derived_table: {
+ datagroup_trigger:attribution_channel
+ sql: select '360.cn'as channel, 'Paid Search' as source UNION ALL
+ select 'babylon'as channel, 'Paid Search' as source UNION ALL
+ select 'centrum.cz'as channel, 'Paid Search' as source UNION ALL
+ select 'conduit'as channel, 'Paid Search' as source UNION ALL
+ select 'duckduckgo'as channel, 'Paid Search' as source UNION ALL
+ select 'excite.com'as channel, 'Paid Search' as source UNION ALL
+ select 'google.com'as channel, 'Paid Search' as source UNION ALL
+ select 'it.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'mail.google.com'as channel, 'Paid Search' as source UNION ALL
+ select 'najdi'as channel, 'Paid Search' as source UNION ALL
+ select 'onet'as channel, 'Paid Search' as source UNION ALL
+ select 'rambler'as channel, 'Paid Search' as source UNION ALL
+ select 'search.smt.docomo.ne.jp'as channel, 'Paid Search' as source UNION ALL
+ select 'sogou.com'as channel, 'Paid Search' as source UNION ALL
+ select 'tr.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'vn.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'yandex'as channel, 'Paid Search' as source UNION ALL
+ select 'alice'as channel, 'Paid Search' as source UNION ALL
+ select 'baidu'as channel, 'Paid Search' as source UNION ALL
+ select 'ch.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'cse.google.com'as channel, 'Paid Search' as source UNION ALL
+ select 'ecosia.org'as channel, 'Paid Search' as source UNION ALL
+ select 'fi.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'googlemybusiness'as channel, 'Paid Search' as source UNION ALL
+ select 'kvasir'as channel, 'Paid Search' as source UNION ALL
+ select 'mail.rambler.ru'as channel, 'Paid Search' as source UNION ALL
+ select 'naver'as channel, 'Paid Search' as source UNION ALL
+ select 'onet.pl'as channel, 'Paid Search' as source UNION ALL
+ select 'rambler.ru'as channel, 'Paid Search' as source UNION ALL
+ select 'search.ukr.net'as channel, 'Paid Search' as source UNION ALL
+ select 'sp-web.search.auone.jp'as channel, 'Paid Search' as source UNION ALL
+ select 'tut.by'as channel, 'Paid Search' as source UNION ALL
+ select 'wap.sogou.com'as channel, 'Paid Search' as source UNION ALL
+ select 'yandex.by'as channel, 'Paid Search' as source UNION ALL
+ select 'aol'as channel, 'Paid Search' as source UNION ALL
+ select 'biglobe'as channel, 'Paid Search' as source UNION ALL
+ select 'cl.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'daum'as channel, 'Paid Search' as source UNION ALL
+ select 'email.seznam.cz'as channel, 'Paid Search' as source UNION ALL
+ select 'firmy.cz'as channel, 'Paid Search' as source UNION ALL
+ select 'hk.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'lite.qwant.com'as channel, 'Paid Search' as source UNION ALL
+ select 'mail.yandex.ru'as channel, 'Paid Search' as source UNION ALL
+ select 'naver.com'as channel, 'Paid Search' as source UNION ALL
+ select 'pe.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'se.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'secureurl.ukr.net'as channel, 'Paid Search' as source UNION ALL
+ select 'startsiden'as channel, 'Paid Search' as source UNION ALL
+ select 'tw.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'webmaster.yandex.ru'as channel, 'Paid Search' as source UNION ALL
+ select 'yandex.com'as channel, 'Paid Search' as source UNION ALL
+ select 'ar.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'biglobe.co.jp'as channel, 'Paid Search' as source UNION ALL
+ select 'cn.bing.com'as channel, 'Paid Search' as source UNION ALL
+ select 'daum.net'as channel, 'Paid Search' as source UNION ALL
+ select 'eniro'as channel, 'Paid Search' as source UNION ALL
+ select 'fr.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'id.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'lycos'as channel, 'Paid Search' as source UNION ALL
+ select 'malaysia.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'news.google.com'as channel, 'Paid Search' as source UNION ALL
+ select 'ph.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'search-results'as channel, 'Paid Search' as source UNION ALL
+ select 'seznam'as channel, 'Paid Search' as source UNION ALL
+ select 'startsiden.no'as channel, 'Paid Search' as source UNION ALL
+ select 'uk.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'websearch.rakuten.co.jp'as channel, 'Paid Search' as source UNION ALL
+ select 'yandex.com.tr'as channel, 'Paid Search' as source UNION ALL
+ select 'ask'as channel, 'Paid Search' as source UNION ALL
+ select 'biglobe.ne.jp'as channel, 'Paid Search' as source UNION ALL
+ select 'cnn'as channel, 'Paid Search' as source UNION ALL
+ select 'de.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'es.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'globo'as channel, 'Paid Search' as source UNION ALL
+ select 'in.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'm.baidu.com'as channel, 'Paid Search' as source UNION ALL
+ select 'msn'as channel, 'Paid Search' as source UNION ALL
+ select 'nl.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'pl.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'search.aol.co.uk'as channel, 'Paid Search' as source UNION ALL
+ select 'seznam.cz'as channel, 'Paid Search' as source UNION ALL
+ select 'suche.aol.de'as channel, 'Paid Search' as source UNION ALL
+ select 'ukr'as channel, 'Paid Search' as source UNION ALL
+ select 'yahoo'as channel, 'Paid Search' as source UNION ALL
+ select 'yandex.fr'as channel, 'Paid Search' as source UNION ALL
+ select 'at.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'bing'as channel, 'Paid Search' as source UNION ALL
+ select 'co.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'dk.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'espanol.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'go.mail.ru'as channel, 'Paid Search' as source UNION ALL
+ select 'incredimail'as channel, 'Paid Search' as source UNION ALL
+ select 'm.naver.com'as channel, 'Paid Search' as source UNION ALL
+ select 'msn.com'as channel, 'Paid Search' as source UNION ALL
+ select 'no.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'qwant'as channel, 'Paid Search' as source UNION ALL
+ select 'search.aol.com'as channel, 'Paid Search' as source UNION ALL
+ select 'sg.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'terra'as channel, 'Paid Search' as source UNION ALL
+ select 'us.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'yahoo.co.jp'as channel, 'Paid Search' as source UNION ALL
+ select 'yandex.kz'as channel, 'Paid Search' as source UNION ALL
+ select 'au.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'br.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'comcast'as channel, 'Paid Search' as source UNION ALL
+ select 'dogpile'as channel, 'Paid Search' as source UNION ALL
+ select 'exalead.com'as channel, 'Paid Search' as source UNION ALL
+ select 'google'as channel, 'Paid Search' as source UNION ALL
+ select 'm.search.naver.com'as channel, 'Paid Search' as source UNION ALL
+ select 'mx.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'ntp.msn.com'as channel, 'Paid Search' as source UNION ALL
+ select 'qwant.com'as channel, 'Paid Search' as source UNION ALL
+ select 'search.google.com'as channel, 'Paid Search' as source UNION ALL
+ select 'so.com'as channel, 'Paid Search' as source UNION ALL
+ select 'th.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'virgilio'as channel, 'Paid Search' as source UNION ALL
+ select 'yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'yandex.ru'as channel, 'Paid Search' as source UNION ALL
+ select 'auone'as channel, 'Paid Search' as source UNION ALL
+ select 'ca.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'dogpile.com'as channel, 'Paid Search' as source UNION ALL
+ select 'google-play'as channel, 'Paid Search' as source UNION ALL
+ select 'm.sogou.com'as channel, 'Paid Search' as source UNION ALL
+ select 'nz.search.yahoo.com'as channel, 'Paid Search' as source UNION ALL
+ select 'rakuten'as channel, 'Paid Search' as source UNION ALL
+ select 'sogou'as channel, 'Paid Search' as source UNION ALL
+ select 'yandex.ua'as channel, 'Paid Search' as source UNION ALL
+ select 'avg'as channel, 'Paid Search' as source UNION ALL
+ select 'rakuten.co.jp'as channel, 'Paid Search' as source UNION ALL
+ select 'yandex.uz'as channel, 'Paid Search' as source ;;
+ }
+
+ measure: count {
+ type: count
+ drill_fields: [detail*]
+ }
+
+ dimension: channel {
+ type: string
+ sql: ${TABLE}.channel ;;
+ }
+
+ dimension: source {
+ type: string
+ sql: ${TABLE}.source ;;
+ }
+
+ set: detail {
+ fields: [
+ channel,
+ source
+ ]
+ }
+}
diff --git a/views/attribution_sources/paid_shopping.view.lkml b/views/attribution_sources/paid_shopping.view.lkml
new file mode 100644
index 0000000..e0aa8f6
--- /dev/null
+++ b/views/attribution_sources/paid_shopping.view.lkml
@@ -0,0 +1,70 @@
+view: paid_shopping
+{
+ derived_table: {
+ datagroup_trigger:attribution_channel
+ sql: select 'Google Shopping' as channel, 'Paid Channel' as source UNION ALL
+ select 'IGShopping' as channel, 'Paid Channel' as source UNION ALL
+ select 'aax-us-east.amazon-adsystem.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'aax.amazon-adsystem.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'alibaba' as channel, 'Paid Channel' as source UNION ALL
+ select 'alibaba.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'amazon' as channel, 'Paid Channel' as source UNION ALL
+ select 'amazon.co.uk' as channel, 'Paid Channel' as source UNION ALL
+ select 'amazon.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'apps.shopify.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'checkout.shopify.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'checkout.stripe.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'cr.shopping.naver.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'cr2.shopping.naver.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'ebay' as channel, 'Paid Channel' as source UNION ALL
+ select 'ebay.co.uk' as channel, 'Paid Channel' as source UNION ALL
+ select 'ebay.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'ebay.com.au' as channel, 'Paid Channel' as source UNION ALL
+ select 'ebay.de' as channel, 'Paid Channel' as source UNION ALL
+ select 'etsy' as channel, 'Paid Channel' as source UNION ALL
+ select 'etsy.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'm.alibaba.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'm.shopping.naver.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'mercadolibre' as channel, 'Paid Channel' as source UNION ALL
+ select 'mercadolibre.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'mercadolibre.com.ar' as channel, 'Paid Channel' as source UNION ALL
+ select 'mercadolibre.com.mx' as channel, 'Paid Channel' as source UNION ALL
+ select 'one.walmart.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'order.shopping.yahoo.co.jp' as channel, 'Paid Channel' as source UNION ALL
+ select 'partners.shopify.com' as channel, 'Paid Channel' as source UNION ALL
+ select 's3.amazonaws.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'se.shopping.net' as channel, 'Paid Channel' as source UNION ALL
+ select 'shop.app' as channel, 'Paid Channel' as source UNION ALL
+ select 'shopify' as channel, 'Paid Channel' as source UNION ALL
+ select 'shopify.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'shopping.naver.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'shopping.yahoo.co.jp' as channel, 'Paid Channel' as source UNION ALL
+ select 'shopping.yahoo.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'shopzilla' as channel, 'Paid Channel' as source UNION ALL
+ select 'shopzilla.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'simplycodes.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'store.shopping.yahoo.co.jp' as channel, 'Paid Channel' as source UNION ALL
+ select 'stripe' as channel, 'Paid Channel' as source UNION ALL
+ select 'stripe.com' as channel, 'Paid Channel' as source UNION ALL
+ select 'uk.shopping.net' as channel, 'Paid Channel' as source UNION ALL
+ select 'walmart' as channel, 'Paid Channel' as source UNION ALL
+ select 'walmart.com' as channel, 'Paid Channel' as source ;;
+ }
+
+ dimension: channel {
+ type: string
+ sql: ${TABLE}.channel ;;
+ }
+
+ dimension: source {
+ type: string
+ sql: ${TABLE}.source ;;
+ }
+
+ set: detail {
+ fields: [
+ channel,
+ source
+ ]
+ }
+}
diff --git a/views/attribution_sources/paid_social.view.lkml b/views/attribution_sources/paid_social.view.lkml
new file mode 100644
index 0000000..276e29f
--- /dev/null
+++ b/views/attribution_sources/paid_social.view.lkml
@@ -0,0 +1,499 @@
+view: paid_social {
+ derived_table: {
+ datagroup_trigger:attribution_channel
+ sql: select '43things' as channel, 'Paid Social' as source UNION ALL
+ select 'ameblo.jp' as channel, 'Paid Social' as source UNION ALL
+ select 'askubuntu.com' as channel, 'Paid Social' as source UNION ALL
+ select 'biip.no' as channel, 'Paid Social' as source UNION ALL
+ select 'bloglines' as channel, 'Paid Social' as source UNION ALL
+ select 'business.facebook.com' as channel, 'Paid Social' as source UNION ALL
+ select 'cellufun.com' as channel, 'Paid Social' as source UNION ALL
+ select 'couchsurfing.org' as channel, 'Paid Social' as source UNION ALL
+ select 'diigo.com' as channel, 'Paid Social' as source UNION ALL
+ select 'edublogs.org' as channel, 'Paid Social' as source UNION ALL
+ select 'feministing.com' as channel, 'Paid Social' as source UNION ALL
+ select 'forums.webosnation.com' as channel, 'Paid Social' as source UNION ALL
+ select 'gamerdna' as channel, 'Paid Social' as source UNION ALL
+ select 'googlegroups.com' as channel, 'Paid Social' as source UNION ALL
+ select 'hr.com' as channel, 'Paid Social' as source UNION ALL
+ select 'instagram.com' as channel, 'Paid Social' as source UNION ALL
+ select 'kaneva' as channel, 'Paid Social' as source UNION ALL
+ select 'livedoorblog' as channel, 'Paid Social' as source UNION ALL
+ select 'messages.google.com' as channel, 'Paid Social' as source UNION ALL
+ select 'mylife' as channel, 'Paid Social' as source UNION ALL
+ select 'odnoklassniki.ua' as channel, 'Paid Social' as source UNION ALL
+ select 'pingsta.com' as channel, 'Paid Social' as source UNION ALL
+ select 'pinterest.pt' as channel, 'Paid Social' as source UNION ALL
+ select 'quechup.com' as channel, 'Paid Social' as source UNION ALL
+ select 'scoop.it' as channel, 'Paid Social' as source UNION ALL
+ select 'slideshare.net' as channel, 'Paid Social' as source UNION ALL
+ select 'stardoll.com' as channel, 'Paid Social' as source UNION ALL
+ select 'tiktok.com' as channel, 'Paid Social' as source UNION ALL
+ select 'twitter' as channel, 'Paid Social' as source UNION ALL
+ select 'web.skype.com' as channel, 'Paid Social' as source UNION ALL
+ select 'xanga.com' as channel, 'Paid Social' as source UNION ALL
+ select '43things.com' as channel, 'Paid Social' as source UNION ALL
+ select 'americantowns' as channel, 'Paid Social' as source UNION ALL
+ select 'asmallworld.com' as channel, 'Paid Social' as source UNION ALL
+ select 'biswap.org' as channel, 'Paid Social' as source UNION ALL
+ select 'bloglines.com' as channel, 'Paid Social' as source UNION ALL
+ select 'buzzfeed' as channel, 'Paid Social' as source UNION ALL
+ select 'centerblog.net' as channel, 'Paid Social' as source UNION ALL
+ select 'cozycot' as channel, 'Paid Social' as source UNION ALL
+ select 'discover.hubpages.com' as channel, 'Paid Social' as source UNION ALL
+ select 'elftown' as channel, 'Paid Social' as source UNION ALL
+ select 'filmaffinity' as channel, 'Paid Social' as source UNION ALL
+ select 'forums.wpcentral.com' as channel, 'Paid Social' as source UNION ALL
+ select 'gamerdna.com' as channel, 'Paid Social' as source UNION ALL
+ select 'googleplus' as channel, 'Paid Social' as source UNION ALL
+ select 'hu.pinterest.com' as channel, 'Paid Social' as source UNION ALL
+ select 'instapaper' as channel, 'Paid Social' as source UNION ALL
+ select 'kaneva.com' as channel, 'Paid Social' as source UNION ALL
+ select 'livejournal' as channel, 'Paid Social' as source UNION ALL
+ select 'messages.yahoo.co.jp' as channel, 'Paid Social' as source UNION ALL
+ select 'mylife.com' as channel, 'Paid Social' as source UNION ALL
+ select 'okwave.jp' as channel, 'Paid Social' as source UNION ALL
+ select 'pinterest' as channel, 'Paid Social' as source UNION ALL
+ select 'pinterest.ru' as channel, 'Paid Social' as source UNION ALL
+ select 'quora' as channel, 'Paid Social' as source UNION ALL
+ select 'screenrant' as channel, 'Paid Social' as source UNION ALL
+ select 'smartnews.com' as channel, 'Paid Social' as source UNION ALL
+ select 'stickam' as channel, 'Paid Social' as source UNION ALL
+ select 'tinyurl' as channel, 'Paid Social' as source UNION ALL
+ select 'twitter.com' as channel, 'Paid Social' as source UNION ALL
+ select 'webshots' as channel, 'Paid Social' as source UNION ALL
+ select 'xing' as channel, 'Paid Social' as source UNION ALL
+ select '51.com' as channel, 'Paid Social' as source UNION ALL
+ select 'americantowns.com' as channel, 'Paid Social' as source UNION ALL
+ select 'athlinks' as channel, 'Paid Social' as source UNION ALL
+ select 'bit.ly' as channel, 'Paid Social' as source UNION ALL
+ select 'blogs.com' as channel, 'Paid Social' as source UNION ALL
+ select 'buzzfeed.com' as channel, 'Paid Social' as source UNION ALL
+ select 'chat.zalo.me' as channel, 'Paid Social' as source UNION ALL
+ select 'cozycot.com' as channel, 'Paid Social' as source UNION ALL
+ select 'disqus' as channel, 'Paid Social' as source UNION ALL
+ select 'elftown.com' as channel, 'Paid Social' as source UNION ALL
+ select 'filmaffinity.com' as channel, 'Paid Social' as source UNION ALL
+ select 'fotki' as channel, 'Paid Social' as source UNION ALL
+ select 'gather.com' as channel, 'Paid Social' as source UNION ALL
+ select 'govloop' as channel, 'Paid Social' as source UNION ALL
+ select 'hubculture' as channel, 'Paid Social' as source UNION ALL
+ select 'instapaper.com' as channel, 'Paid Social' as source UNION ALL
+ select 'kin.naver.com' as channel, 'Paid Social' as source UNION ALL
+ select 'livejournal.com' as channel, 'Paid Social' as source UNION ALL
+ select 'messenger' as channel, 'Paid Social' as source UNION ALL
+ select 'mymodernmet' as channel, 'Paid Social' as source UNION ALL
+ select 'old.reddit.com' as channel, 'Paid Social' as source UNION ALL
+ select 'pinterest.at' as channel, 'Paid Social' as source UNION ALL
+ select 'pinterest.se' as channel, 'Paid Social' as source UNION ALL
+ select 'quora.com' as channel, 'Paid Social' as source UNION ALL
+ select 'screenrant.com' as channel, 'Paid Social' as source UNION ALL
+ select 'snapchat' as channel, 'Paid Social' as source UNION ALL
+ select 'stickam.com' as channel, 'Paid Social' as source UNION ALL
+ select 'tinyurl.com' as channel, 'Paid Social' as source UNION ALL
+ select 'twoo.com' as channel, 'Paid Social' as source UNION ALL
+ select 'webshots.com' as channel, 'Paid Social' as source UNION ALL
+ select 'xing.com' as channel, 'Paid Social' as source UNION ALL
+ select '5ch.net' as channel, 'Paid Social' as source UNION ALL
+ select 'amp.reddit.com' as channel, 'Paid Social' as source UNION ALL
+ select 'athlinks.com' as channel, 'Paid Social' as source UNION ALL
+ select 'blackcareernetwork.com' as channel, 'Paid Social' as source UNION ALL
+ select 'blogsome' as channel, 'Paid Social' as source UNION ALL
+ select 'buzznet' as channel, 'Paid Social' as source UNION ALL
+ select 'chegg.com' as channel, 'Paid Social' as source UNION ALL
+ select 'cross.tv' as channel, 'Paid Social' as source UNION ALL
+ select 'disqus.com' as channel, 'Paid Social' as source UNION ALL
+ select 'epicurious.com' as channel, 'Paid Social' as source UNION ALL
+ select 'flickr' as channel, 'Paid Social' as source UNION ALL
+ select 'fotki.com' as channel, 'Paid Social' as source UNION ALL
+ select 'geni.com' as channel, 'Paid Social' as source UNION ALL
+ select 'govloop.com' as channel, 'Paid Social' as source UNION ALL
+ select 'hubculture.com' as channel, 'Paid Social' as source UNION ALL
+ select 'internations.org' as channel, 'Paid Social' as source UNION ALL
+ select 'l.facebook.com' as channel, 'Paid Social' as source UNION ALL
+ select 'lm.facebook.com' as channel, 'Paid Social' as source UNION ALL
+ select 'messenger.com' as channel, 'Paid Social' as source UNION ALL
+ select 'mymodernmet.com' as channel, 'Paid Social' as source UNION ALL
+ select 'oneworldgroup.org' as channel, 'Paid Social' as source UNION ALL
+ select 'pinterest.ca' as channel, 'Paid Social' as source UNION ALL
+ select 'pixiv.net' as channel, 'Paid Social' as source UNION ALL
+ select 'qzone.qq.com' as channel, 'Paid Social' as source UNION ALL
+ select 'scribd' as channel, 'Paid Social' as source UNION ALL
+ select 'snapchat.com' as channel, 'Paid Social' as source UNION ALL
+ select 'studivz.net' as channel, 'Paid Social' as source UNION ALL
+ select 'toolbox' as channel, 'Paid Social' as source UNION ALL
+ select 'typepad' as channel, 'Paid Social' as source UNION ALL
+ select 'wechat' as channel, 'Paid Social' as source UNION ALL
+ select 'yahoo-mbga.jp' as channel, 'Paid Social' as source UNION ALL
+ select 'Hatena' as channel, 'Paid Social' as source UNION ALL
+ select 'ancestry.com' as channel, 'Paid Social' as source UNION ALL
+ select 'away.vk.com' as channel, 'Paid Social' as source UNION ALL
+ select 'blackplanet' as channel, 'Paid Social' as source UNION ALL
+ select 'blogsome.com' as channel, 'Paid Social' as source UNION ALL
+ select 'buzznet.com' as channel, 'Paid Social' as source UNION ALL
+ select 'chicagonow' as channel, 'Paid Social' as source UNION ALL
+ select 'crunchyroll' as channel, 'Paid Social' as source UNION ALL
+ select 'dogster' as channel, 'Paid Social' as source UNION ALL
+ select 'everforo.com' as channel, 'Paid Social' as source UNION ALL
+ select 'flickr.com' as channel, 'Paid Social' as source UNION ALL
+ select 'fotolog' as channel, 'Paid Social' as source UNION ALL
+ select 'getpocket.com' as channel, 'Paid Social' as source UNION ALL
+ select 'gowalla' as channel, 'Paid Social' as source UNION ALL
+ select 'hubpages.com' as channel, 'Paid Social' as source UNION ALL
+ select 'interpals.net' as channel, 'Paid Social' as source UNION ALL
+ select 'l.instagram.com' as channel, 'Paid Social' as source UNION ALL
+ select 'lnkd.in' as channel, 'Paid Social' as source UNION ALL
+ select 'mix.com' as channel, 'Paid Social' as source UNION ALL
+ select 'myspace' as channel, 'Paid Social' as source UNION ALL
+ select 'onstartups' as channel, 'Paid Social' as source UNION ALL
+ select 'pinterest.ch' as channel, 'Paid Social' as source UNION ALL
+ select 'pl.pinterest.com' as channel, 'Paid Social' as source UNION ALL
+ select 'ravelry' as channel, 'Paid Social' as source UNION ALL
+ select 'scribd.com' as channel, 'Paid Social' as source UNION ALL
+ select 'sociallife.com.br' as channel, 'Paid Social' as source UNION ALL
+ select 'suomi24.fi' as channel, 'Paid Social' as source UNION ALL
+ select 'toolbox.com' as channel, 'Paid Social' as source UNION ALL
+ select 'typepad.com' as channel, 'Paid Social' as source UNION ALL
+ select 'wechat.com' as channel, 'Paid Social' as source UNION ALL
+ select 'yammer' as channel, 'Paid Social' as source UNION ALL
+ select 'ImageShack' as channel, 'Paid Social' as source UNION ALL
+ select 'anobii' as channel, 'Paid Social' as source UNION ALL
+ select 'awe.sm' as channel, 'Paid Social' as source UNION ALL
+ select 'blackplanet.com' as channel, 'Paid Social' as source UNION ALL
+ select 'blogspot' as channel, 'Paid Social' as source UNION ALL
+ select 'cafe.naver.com' as channel, 'Paid Social' as source UNION ALL
+ select 'chicagonow.com' as channel, 'Paid Social' as source UNION ALL
+ select 'crunchyroll.com' as channel, 'Paid Social' as source UNION ALL
+ select 'dogster.com' as channel, 'Paid Social' as source UNION ALL
+ select 'exblog.jp' as channel, 'Paid Social' as source UNION ALL
+ select 'flipboard' as channel, 'Paid Social' as source UNION ALL
+ select 'fotolog.com' as channel, 'Paid Social' as source UNION ALL
+ select 'glassboard' as channel, 'Paid Social' as source UNION ALL
+ select 'gowalla.com' as channel, 'Paid Social' as source UNION ALL
+ select 'hyves.net' as channel, 'Paid Social' as source UNION ALL
+ select 'intherooms' as channel, 'Paid Social' as source UNION ALL
+ select 'l.messenger.com' as channel, 'Paid Social' as source UNION ALL
+ select 'm.blog.naver.com' as channel, 'Paid Social' as source UNION ALL
+ select 'mixi.jp' as channel, 'Paid Social' as source UNION ALL
+ select 'myspace.com' as channel, 'Paid Social' as source UNION ALL
+ select 'onstartups.com' as channel, 'Paid Social' as source UNION ALL
+ select 'pinterest.cl' as channel, 'Paid Social' as source UNION ALL
+ select 'playahead.se' as channel, 'Paid Social' as source UNION ALL
+ select 'ravelry.com' as channel, 'Paid Social' as source UNION ALL
+ select 'scvngr' as channel, 'Paid Social' as source UNION ALL
+ select 'socialvibe' as channel, 'Paid Social' as source UNION ALL
+ select 'superuser' as channel, 'Paid Social' as source UNION ALL
+ select 'touch.facebook.com' as channel, 'Paid Social' as source UNION ALL
+ select 'unblog.fr' as channel, 'Paid Social' as source UNION ALL
+ select 'weebly' as channel, 'Paid Social' as source UNION ALL
+ select 'yammer.com' as channel, 'Paid Social' as source UNION ALL
+ select 'academia.edu' as channel, 'Paid Social' as source UNION ALL
+ select 'anobii.com' as channel, 'Paid Social' as source UNION ALL
+ select 'b.hatena.ne.jp' as channel, 'Paid Social' as source UNION ALL
+ select 'blip.fm' as channel, 'Paid Social' as source UNION ALL
+ select 'blogspot.com' as channel, 'Paid Social' as source UNION ALL
+ select 'cafemom' as channel, 'Paid Social' as source UNION ALL
+ select 'chiebukuro.yahoo.co.jp' as channel, 'Paid Social' as source UNION ALL
+ select 'cyworld' as channel, 'Paid Social' as source UNION ALL
+ select 'dol2day' as channel, 'Paid Social' as source UNION ALL
+ select 'extole' as channel, 'Paid Social' as source UNION ALL
+ select 'flipboard.com' as channel, 'Paid Social' as source UNION ALL
+ select 'foursquare' as channel, 'Paid Social' as source UNION ALL
+ select 'glassboard.com' as channel, 'Paid Social' as source UNION ALL
+ select 'gree.jp' as channel, 'Paid Social' as source UNION ALL
+ select 'hyves.nl' as channel, 'Paid Social' as source UNION ALL
+ select 'intherooms.com' as channel, 'Paid Social' as source UNION ALL
+ select 'last.fm' as channel, 'Paid Social' as source UNION ALL
+ select 'm.cafe.naver.com' as channel, 'Paid Social' as source UNION ALL
+ select 'mobile.facebook.com' as channel, 'Paid Social' as source UNION ALL
+ select 'netvibes' as channel, 'Paid Social' as source UNION ALL
+ select 'opendiary' as channel, 'Paid Social' as source UNION ALL
+ select 'pinterest.co.kr' as channel, 'Paid Social' as source UNION ALL
+ select 'plurk' as channel, 'Paid Social' as source UNION ALL
+ select 'reddit' as channel, 'Paid Social' as source UNION ALL
+ select 'scvngr.com' as channel, 'Paid Social' as source UNION ALL
+ select 'socialvibe.com' as channel, 'Paid Social' as source UNION ALL
+ select 'superuser.com' as channel, 'Paid Social' as source UNION ALL
+ select 'tr.pinterest.com' as channel, 'Paid Social' as source UNION ALL
+ select 'urbanspoon.com' as channel, 'Paid Social' as source UNION ALL
+ select 'weebly.com' as channel, 'Paid Social' as source UNION ALL
+ select 'yelp' as channel, 'Paid Social' as source UNION ALL
+ select 'activerain' as channel, 'Paid Social' as source UNION ALL
+ select 'answerbag' as channel, 'Paid Social' as source UNION ALL
+ select 'baby-gaga' as channel, 'Paid Social' as source UNION ALL
+ select 'blog.com' as channel, 'Paid Social' as source UNION ALL
+ select 'blogster' as channel, 'Paid Social' as source UNION ALL
+ select 'cafemom.com' as channel, 'Paid Social' as source UNION ALL
+ select 'classmates' as channel, 'Paid Social' as source UNION ALL
+ select 'cyworld.com' as channel, 'Paid Social' as source UNION ALL
+ select 'dol2day.com' as channel, 'Paid Social' as source UNION ALL
+ select 'extole.com' as channel, 'Paid Social' as source UNION ALL
+ select 'folkdirect' as channel, 'Paid Social' as source UNION ALL
+ select 'foursquare.com' as channel, 'Paid Social' as source UNION ALL
+ select 'glassdoor' as channel, 'Paid Social' as source UNION ALL
+ select 'groups.google.com' as channel, 'Paid Social' as source UNION ALL
+ select 'ibibo' as channel, 'Paid Social' as source UNION ALL
+ select 'irc-galleria.net' as channel, 'Paid Social' as source UNION ALL
+ select 'librarything' as channel, 'Paid Social' as source UNION ALL
+ select 'm.facebook.com' as channel, 'Paid Social' as source UNION ALL
+ select 'mocospace' as channel, 'Paid Social' as source UNION ALL
+ select 'netvibes.com' as channel, 'Paid Social' as source UNION ALL
+ select 'opendiary.com' as channel, 'Paid Social' as source UNION ALL
+ select 'pinterest.co.uk' as channel, 'Paid Social' as source UNION ALL
+ select 'plurk.com' as channel, 'Paid Social' as source UNION ALL
+ select 'reddit.com' as channel, 'Paid Social' as source UNION ALL
+ select 'secondlife' as channel, 'Paid Social' as source UNION ALL
+ select 'spaces.live.com' as channel, 'Paid Social' as source UNION ALL
+ select 'sweeva' as channel, 'Paid Social' as source UNION ALL
+ select 'travellerspoint' as channel, 'Paid Social' as source UNION ALL
+ select 'ushareit.com' as channel, 'Paid Social' as source UNION ALL
+ select 'weibo' as channel, 'Paid Social' as source UNION ALL
+ select 'yelp.co.uk' as channel, 'Paid Social' as source UNION ALL
+ select 'activerain.com' as channel, 'Paid Social' as source UNION ALL
+ select 'answerbag.com' as channel, 'Paid Social' as source UNION ALL
+ select 'baby-gaga.com' as channel, 'Paid Social' as source UNION ALL
+ select 'blog.feedspot.com' as channel, 'Paid Social' as source UNION ALL
+ select 'blogster.com' as channel, 'Paid Social' as source UNION ALL
+ select 'camospace' as channel, 'Paid Social' as source UNION ALL
+ select 'classmates.com' as channel, 'Paid Social' as source UNION ALL
+ select 'cz.pinterest.com' as channel, 'Paid Social' as source UNION ALL
+ select 'doostang' as channel, 'Paid Social' as source UNION ALL
+ select 'facebook' as channel, 'Paid Social' as source UNION ALL
+ select 'folkdirect.com' as channel, 'Paid Social' as source UNION ALL
+ select 'free.facebook.com' as channel, 'Paid Social' as source UNION ALL
+ select 'glassdoor.com' as channel, 'Paid Social' as source UNION ALL
+ select 'gulli.com' as channel, 'Paid Social' as source UNION ALL
+ select 'ibibo.com' as channel, 'Paid Social' as source UNION ALL
+ select 'is.gd' as channel, 'Paid Social' as source UNION ALL
+ select 'librarything.com' as channel, 'Paid Social' as source UNION ALL
+ select 'm.kin.naver.com' as channel, 'Paid Social' as source UNION ALL
+ select 'mocospace.com' as channel, 'Paid Social' as source UNION ALL
+ select 'news.ycombinator.com' as channel, 'Paid Social' as source UNION ALL
+ select 'oshiete.goo.ne.jp' as channel, 'Paid Social' as source UNION ALL
+ select 'pinterest.com' as channel, 'Paid Social' as source UNION ALL
+ select 'plus.google.com' as channel, 'Paid Social' as source UNION ALL
+ select 'redux' as channel, 'Paid Social' as source UNION ALL
+ select 'secondlife.com' as channel, 'Paid Social' as source UNION ALL
+ select 'spoke' as channel, 'Paid Social' as source UNION ALL
+ select 'sweeva.com' as channel, 'Paid Social' as source UNION ALL
+ select 'travellerspoint.com' as channel, 'Paid Social' as source UNION ALL
+ select 'ushi.cn' as channel, 'Paid Social' as source UNION ALL
+ select 'weibo.com' as channel, 'Paid Social' as source UNION ALL
+ select 'yelp.com' as channel, 'Paid Social' as source UNION ALL
+ select 'activeworlds' as channel, 'Paid Social' as source UNION ALL
+ select 'answers.yahoo.com' as channel, 'Paid Social' as source UNION ALL
+ select 'babyblog.ru' as channel, 'Paid Social' as source UNION ALL
+ select 'blog.goo.ne.jp' as channel, 'Paid Social' as source UNION ALL
+ select 'blurtit' as channel, 'Paid Social' as source UNION ALL
+ select 'camospace.com' as channel, 'Paid Social' as source UNION ALL
+ select 'classquest' as channel, 'Paid Social' as source UNION ALL
+ select 'd.hatena.ne.jp' as channel, 'Paid Social' as source UNION ALL
+ select 'doostang.com' as channel, 'Paid Social' as source UNION ALL
+ select 'facebook.com' as channel, 'Paid Social' as source UNION ALL
+ select 'foodservice' as channel, 'Paid Social' as source UNION ALL
+ select 'friendfeed' as channel, 'Paid Social' as source UNION ALL
+ select 'godtube' as channel, 'Paid Social' as source UNION ALL
+ select 'gutefrage.net' as channel, 'Paid Social' as source UNION ALL
+ select 'id.pinterest.com' as channel, 'Paid Social' as source UNION ALL
+ select 'italki' as channel, 'Paid Social' as source UNION ALL
+ select 'lifestream.aol.com' as channel, 'Paid Social' as source UNION ALL
+ select 'm.vk.com' as channel, 'Paid Social' as source UNION ALL
+ select 'mouthshut' as channel, 'Paid Social' as source UNION ALL
+ select 'newsshowcase' as channel, 'Paid Social' as source UNION ALL
+ select 'out.reddit.com' as channel, 'Paid Social' as source UNION ALL
+ select 'pinterest.com.au' as channel, 'Paid Social' as source UNION ALL
+ select 'plus.url.google.com' as channel, 'Paid Social' as source UNION ALL
+ select 'redux.com' as channel, 'Paid Social' as source UNION ALL
+ select 'serverfault' as channel, 'Paid Social' as source UNION ALL
+ select 'spoke.com' as channel, 'Paid Social' as source UNION ALL
+ select 't.co' as channel, 'Paid Social' as source UNION ALL
+ select 'tripadvisor' as channel, 'Paid Social' as source UNION ALL
+ select 'vampirefreaks' as channel, 'Paid Social' as source UNION ALL
+ select 'wer-weiss-was.de' as channel, 'Paid Social' as source UNION ALL
+ select 'youroom.in' as channel, 'Paid Social' as source UNION ALL
+ select 'activeworlds.com' as channel, 'Paid Social' as source UNION ALL
+ select 'aolanswers' as channel, 'Paid Social' as source UNION ALL
+ select 'badoo' as channel, 'Paid Social' as source UNION ALL
+ select 'blog.naver.com' as channel, 'Paid Social' as source UNION ALL
+ select 'blurtit.com' as channel, 'Paid Social' as source UNION ALL
+ select 'canalblog.com' as channel, 'Paid Social' as source UNION ALL
+ select 'classquest.com' as channel, 'Paid Social' as source UNION ALL
+ select 'dailystrength.org' as channel, 'Paid Social' as source UNION ALL
+ select 'dopplr' as channel, 'Paid Social' as source UNION ALL
+ select 'faceparty' as channel, 'Paid Social' as source UNION ALL
+ select 'foodservice.com' as channel, 'Paid Social' as source UNION ALL
+ select 'friendfeed.com' as channel, 'Paid Social' as source UNION ALL
+ select 'godtube.com' as channel, 'Paid Social' as source UNION ALL
+ select 'habbo' as channel, 'Paid Social' as source UNION ALL
+ select 'identi.ca' as channel, 'Paid Social' as source UNION ALL
+ select 'italki.com' as channel, 'Paid Social' as source UNION ALL
+ select 'line' as channel, 'Paid Social' as source UNION ALL
+ select 'm.yelp.com' as channel, 'Paid Social' as source UNION ALL
+ select 'mouthshut.com' as channel, 'Paid Social' as source UNION ALL
+ select 'nexopia' as channel, 'Paid Social' as source UNION ALL
+ select 'over-blog.com' as channel, 'Paid Social' as source UNION ALL
+ select 'pinterest.com.mx' as channel, 'Paid Social' as source UNION ALL
+ select 'pocket.co' as channel, 'Paid Social' as source UNION ALL
+ select 'renren' as channel, 'Paid Social' as source UNION ALL
+ select 'serverfault.com' as channel, 'Paid Social' as source UNION ALL
+ select 'spruz' as channel, 'Paid Social' as source UNION ALL
+ select 't.me' as channel, 'Paid Social' as source UNION ALL
+ select 'tripadvisor.com' as channel, 'Paid Social' as source UNION ALL
+ select 'vampirefreaks.com' as channel, 'Paid Social' as source UNION ALL
+ select 'weread' as channel, 'Paid Social' as source UNION ALL
+ select 'za.pinterest.com' as channel, 'Paid Social' as source UNION ALL
+ select 'addthis' as channel, 'Paid Social' as source UNION ALL
+ select 'aolanswers.com' as channel, 'Paid Social' as source UNION ALL
+ select 'badoo.com' as channel, 'Paid Social' as source UNION ALL
+ select 'blog.yahoo.co.jp' as channel, 'Paid Social' as source UNION ALL
+ select 'bookmarks.yahoo.co.jp' as channel, 'Paid Social' as source UNION ALL
+ select 'care.com' as channel, 'Paid Social' as source UNION ALL
+ select 'co.pinterest.com' as channel, 'Paid Social' as source UNION ALL
+ select 'deluxe.com' as channel, 'Paid Social' as source UNION ALL
+ select 'dopplr.com' as channel, 'Paid Social' as source UNION ALL
+ select 'faceparty.com' as channel, 'Paid Social' as source UNION ALL
+ select 'forums.androidcentral.com' as channel, 'Paid Social' as source UNION ALL
+ select 'fruehstueckstreff.org' as channel, 'Paid Social' as source UNION ALL
+ select 'goldenline.pl' as channel, 'Paid Social' as source UNION ALL
+ select 'habbo.com' as channel, 'Paid Social' as source UNION ALL
+ select 'ig' as channel, 'Paid Social' as source UNION ALL
+ select 'jammerdirect' as channel, 'Paid Social' as source UNION ALL
+ select 'line.me' as channel, 'Paid Social' as source UNION ALL
+ select 'mbga.jp' as channel, 'Paid Social' as source UNION ALL
+ select 'movabletype' as channel, 'Paid Social' as source UNION ALL
+ select 'ngopost.org' as channel, 'Paid Social' as source UNION ALL
+ select 'overblog.com' as channel, 'Paid Social' as source UNION ALL
+ select 'pinterest.de' as channel, 'Paid Social' as source UNION ALL
+ select 'posterous' as channel, 'Paid Social' as source UNION ALL
+ select 'renren.com' as channel, 'Paid Social' as source UNION ALL
+ select 'shareit' as channel, 'Paid Social' as source UNION ALL
+ select 'spruz.com' as channel, 'Paid Social' as source UNION ALL
+ select 'tagged' as channel, 'Paid Social' as source UNION ALL
+ select 'trombi' as channel, 'Paid Social' as source UNION ALL
+ select 'vampirerave' as channel, 'Paid Social' as source UNION ALL
+ select 'weread.com' as channel, 'Paid Social' as source UNION ALL
+ select 'zalo' as channel, 'Paid Social' as source UNION ALL
+ select 'addthis.com' as channel, 'Paid Social' as source UNION ALL
+ select 'apps.facebook.com' as channel, 'Paid Social' as source UNION ALL
+ select 'bebo' as channel, 'Paid Social' as source UNION ALL
+ select 'blogg.no' as channel, 'Paid Social' as source UNION ALL
+ select 'bookmarks.yahoo.com' as channel, 'Paid Social' as source UNION ALL
+ select 'care2' as channel, 'Paid Social' as source UNION ALL
+ select 'cocolog-nifty' as channel, 'Paid Social' as source UNION ALL
+ select 'deviantart' as channel, 'Paid Social' as source UNION ALL
+ select 'douban' as channel, 'Paid Social' as source UNION ALL
+ select 'fandom.com' as channel, 'Paid Social' as source UNION ALL
+ select 'forums.crackberry.com' as channel, 'Paid Social' as source UNION ALL
+ select 'fubar' as channel, 'Paid Social' as source UNION ALL
+ select 'goldstar' as channel, 'Paid Social' as source UNION ALL
+ select 'hi5' as channel, 'Paid Social' as source UNION ALL
+ select 'imageshack.com' as channel, 'Paid Social' as source UNION ALL
+ select 'jammerdirect.com' as channel, 'Paid Social' as source UNION ALL
+ select 'linkedin' as channel, 'Paid Social' as source UNION ALL
+ select 'medium.com' as channel, 'Paid Social' as source UNION ALL
+ select 'movabletype.com' as channel, 'Paid Social' as source UNION ALL
+ select 'niconico' as channel, 'Paid Social' as source UNION ALL
+ select 'paper.li' as channel, 'Paid Social' as source UNION ALL
+ select 'pinterest.es' as channel, 'Paid Social' as source UNION ALL
+ select 'posterous.com' as channel, 'Paid Social' as source UNION ALL
+ select 'researchgate.net' as channel, 'Paid Social' as source UNION ALL
+ select 'sharethis' as channel, 'Paid Social' as source UNION ALL
+ select 'ssense.com' as channel, 'Paid Social' as source UNION ALL
+ select 'tagged.com' as channel, 'Paid Social' as source UNION ALL
+ select 'trombi.com' as channel, 'Paid Social' as source UNION ALL
+ select 'vampirerave.com' as channel, 'Paid Social' as source UNION ALL
+ select 'whatsapp' as channel, 'Paid Social' as source UNION ALL
+ select 'zoo.gr' as channel, 'Paid Social' as source UNION ALL
+ select 'airg.ca' as channel, 'Paid Social' as source UNION ALL
+ select 'ar.pinterest.com' as channel, 'Paid Social' as source UNION ALL
+ select 'bebo.com' as channel, 'Paid Social' as source UNION ALL
+ select 'bloggang.com' as channel, 'Paid Social' as source UNION ALL
+ select 'br.pinterest.com' as channel, 'Paid Social' as source UNION ALL
+ select 'care2.com' as channel, 'Paid Social' as source UNION ALL
+ select 'cocolog-nifty.com' as channel, 'Paid Social' as source UNION ALL
+ select 'deviantart.com' as channel, 'Paid Social' as source UNION ALL
+ select 'douban.com' as channel, 'Paid Social' as source UNION ALL
+ select 'fanpop' as channel, 'Paid Social' as source UNION ALL
+ select 'forums.imore.com' as channel, 'Paid Social' as source UNION ALL
+ select 'fubar.com' as channel, 'Paid Social' as source UNION ALL
+ select 'goldstar.com' as channel, 'Paid Social' as source UNION ALL
+ select 'hi5.com' as channel, 'Paid Social' as source UNION ALL
+ select 'imageshack.us' as channel, 'Paid Social' as source UNION ALL
+ select 'jappy.com' as channel, 'Paid Social' as source UNION ALL
+ select 'linkedin.com' as channel, 'Paid Social' as source UNION ALL
+ select 'meetin.org' as channel, 'Paid Social' as source UNION ALL
+ select 'mubi' as channel, 'Paid Social' as source UNION ALL
+ select 'nicovideo.jp' as channel, 'Paid Social' as source UNION ALL
+ select 'partyflock.nl' as channel, 'Paid Social' as source UNION ALL
+ select 'pinterest.fr' as channel, 'Paid Social' as source UNION ALL
+ select 'pro.homeadvisor.com' as channel, 'Paid Social' as source UNION ALL
+ select 'reunion' as channel, 'Paid Social' as source UNION ALL
+ select 'sharethis.com' as channel, 'Paid Social' as source UNION ALL
+ select 'stackapps' as channel, 'Paid Social' as source UNION ALL
+ select 'taggedmail' as channel, 'Paid Social' as source UNION ALL
+ select 'tudou' as channel, 'Paid Social' as source UNION ALL
+ select 'vg.no' as channel, 'Paid Social' as source UNION ALL
+ select 'whatsapp.com' as channel, 'Paid Social' as source UNION ALL
+ select 'zooppa' as channel, 'Paid Social' as source UNION ALL
+ select 'allnurses.com' as channel, 'Paid Social' as source UNION ALL
+ select 'artstation.com' as channel, 'Paid Social' as source UNION ALL
+ select 'beforeitsnews' as channel, 'Paid Social' as source UNION ALL
+ select 'blogger' as channel, 'Paid Social' as source UNION ALL
+ select 'brightkite' as channel, 'Paid Social' as source UNION ALL
+ select 'caringbridge.org' as channel, 'Paid Social' as source UNION ALL
+ select 'copainsdavant.linternaute.com' as channel, 'Paid Social' as source UNION ALL
+ select 'dianping' as channel, 'Paid Social' as source UNION ALL
+ select 'draft.blogger.com' as channel, 'Paid Social' as source UNION ALL
+ select 'fanpop.com' as channel, 'Paid Social' as source UNION ALL
+ select 'forums.nexopia.com' as channel, 'Paid Social' as source UNION ALL
+ select 'gaiaonline' as channel, 'Paid Social' as source UNION ALL
+ select 'goo.gl' as channel, 'Paid Social' as source UNION ALL
+ select 'hootsuite' as channel, 'Paid Social' as source UNION ALL
+ select 'imvu' as channel, 'Paid Social' as source UNION ALL
+ select 'jappy.de' as channel, 'Paid Social' as source UNION ALL
+ select 'listal' as channel, 'Paid Social' as source UNION ALL
+ select 'meetup' as channel, 'Paid Social' as source UNION ALL
+ select 'mubi.com' as channel, 'Paid Social' as source UNION ALL
+ select 'nightlifelink' as channel, 'Paid Social' as source UNION ALL
+ select 'photobucket' as channel, 'Paid Social' as source UNION ALL
+ select 'pinterest.it' as channel, 'Paid Social' as source UNION ALL
+ select 'pulse.yahoo.com' as channel, 'Paid Social' as source UNION ALL
+ select 'reunion.com' as channel, 'Paid Social' as source UNION ALL
+ select 'shvoong.com' as channel, 'Paid Social' as source UNION ALL
+ select 'stackapps.com' as channel, 'Paid Social' as source UNION ALL
+ select 'taggedmail.com' as channel, 'Paid Social' as source UNION ALL
+ select 'tudou.com' as channel, 'Paid Social' as source UNION ALL
+ select 'video.ibm.com' as channel, 'Paid Social' as source UNION ALL
+ select 'wiki.answers.com' as channel, 'Paid Social' as source UNION ALL
+ select 'zooppa.com' as channel, 'Paid Social' as source UNION ALL
+ select 'allrecipes.com' as channel, 'Paid Social' as source UNION ALL
+ select 'askubuntu' as channel, 'Paid Social' as source UNION ALL
+ select 'beforeitsnews.com' as channel, 'Paid Social' as source UNION ALL
+ select 'blogger.com' as channel, 'Paid Social' as source UNION ALL
+ select 'brightkite.com' as channel, 'Paid Social' as source UNION ALL
+ select 'catster' as channel, 'Paid Social' as source ;;
+ }
+
+ measure: count {
+ type: count
+ drill_fields: [detail*]
+ }
+
+ dimension: channel {
+ type: string
+ sql: ${TABLE}.channel ;;
+ }
+
+ dimension: source {
+ type: string
+ sql: ${TABLE}.source ;;
+ }
+
+ set: detail {
+ fields: [
+ channel,
+ source
+ ]
+ }
+
+ }
diff --git a/views/attribution_sources/paid_video.view.lkml b/views/attribution_sources/paid_video.view.lkml
new file mode 100644
index 0000000..4833b1c
--- /dev/null
+++ b/views/attribution_sources/paid_video.view.lkml
@@ -0,0 +1,64 @@
+view: paid_video {
+ derived_table: {
+ datagroup_trigger:attribution_channel
+ sql: select 'blog.twitch.tv' as channel, 'Paid Video'as source UNION ALL
+ select 'dailymotion.com' as channel, 'Paid Video'as source UNION ALL
+ select 'help.netflix.com' as channel, 'Paid Video'as source UNION ALL
+ select 'justin.tv' as channel, 'Paid Video'as source UNION ALL
+ select 'player.vimeo.com' as channel, 'Paid Video'as source UNION ALL
+ select 'vimeo' as channel, 'Paid Video'as source UNION ALL
+ select 'crackle' as channel, 'Paid Video'as source UNION ALL
+ select 'dashboard.twitch.tv' as channel, 'Paid Video'as source UNION ALL
+ select 'hulu' as channel, 'Paid Video'as source UNION ALL
+ select 'm.twitch.tv' as channel, 'Paid Video'as source UNION ALL
+ select 'ted' as channel, 'Paid Video'as source UNION ALL
+ select 'vimeo.com' as channel, 'Paid Video'as source UNION ALL
+ select 'crackle.com' as channel, 'Paid Video'as source UNION ALL
+ select 'disneyplus' as channel, 'Paid Video'as source UNION ALL
+ select 'hulu.com' as channel, 'Paid Video'as source UNION ALL
+ select 'm.youtube.com' as channel, 'Paid Video'as source UNION ALL
+ select 'ted.com' as channel, 'Paid Video'as source UNION ALL
+ select 'wistia' as channel, 'Paid Video'as source UNION ALL
+ select 'curiositystream' as channel, 'Paid Video'as source UNION ALL
+ select 'disneyplus.com' as channel, 'Paid Video'as source UNION ALL
+ select 'id.twitch.tv' as channel, 'Paid Video'as source UNION ALL
+ select 'music.youtube.com' as channel, 'Paid Video'as source UNION ALL
+ select 'twitch' as channel, 'Paid Video'as source UNION ALL
+ select 'wistia.com' as channel, 'Paid Video'as source UNION ALL
+ select 'curiositystream.com' as channel, 'Paid Video'as source UNION ALL
+ select 'fast.wistia.net' as channel, 'Paid Video'as source UNION ALL
+ select 'iq.com' as channel, 'Paid Video'as source UNION ALL
+ select 'netflix' as channel, 'Paid Video'as source UNION ALL
+ select 'twitch.tv' as channel, 'Paid Video'as source UNION ALL
+ select 'youku' as channel, 'Paid Video'as source UNION ALL
+ select 'd.tube' as channel, 'Paid Video'as source UNION ALL
+ select 'help.hulu.com' as channel, 'Paid Video'as source UNION ALL
+ select 'iqiyi' as channel, 'Paid Video'as source UNION ALL
+ select 'netflix.com' as channel, 'Paid Video'as source UNION ALL
+ select 'utreon' as channel, 'Paid Video'as source UNION ALL
+ select 'youku.com' as channel, 'Paid Video'as source UNION ALL
+ select 'dailymotion' as channel, 'Paid Video'as source ;;
+ }
+
+ measure: count {
+ type: count
+ drill_fields: [detail*]
+ }
+
+ dimension: channel {
+ type: string
+ sql: ${TABLE}.channel ;;
+ }
+
+ dimension: source {
+ type: string
+ sql: ${TABLE}.source ;;
+ }
+
+ set: detail {
+ fields: [
+ channel,
+ source
+ ]
+ }
+}
diff --git a/views/audience_cohorts.view.lkml b/views/audience_cohorts.view.lkml
new file mode 100644
index 0000000..4689e18
--- /dev/null
+++ b/views/audience_cohorts.view.lkml
@@ -0,0 +1,28 @@
+include: "/views/attribution_sources.view.lkml"
+view: audience_cohorts {
+ derived_table: {
+ explore_source: sessions {
+ column: audience_trait {}
+ column: total_sessions {}
+ derived_column: rank {
+ sql: ROW_NUMBER() OVER() ;;
+ }
+
+ bind_all_filters: yes
+ sorts: [sessions.total_sessions: desc]
+ }
+ }
+
+ dimension: audience_trait {
+ # Field used to JOIN back to ga_sessions via ga_sessions.audience_traits = audience_cohorts.audience_traits
+ hidden: yes
+ }
+
+ dimension: rank {
+ label: "Audience Trait: Rank by Traffic"
+ view_label: "Audience"
+ group_label: "Audience Cohorts"
+ description: "Dynamic rank for Audience Trait based on web traffic (Sessions). Includes all filters in current query and reranks on each new query."
+ type: number
+ }
+}
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/bqml/purchase_propensity/future_input.view.lkml b/views/bqml/purchase_propensity/future_input.view.lkml
new file mode 100644
index 0000000..0653a66
--- /dev/null
+++ b/views/bqml/purchase_propensity/future_input.view.lkml
@@ -0,0 +1,217 @@
+include: "/views/sessions/*.view.lkml"
+view: future_input {
+ derived_table: {
+ sql_trigger_value: ${testing_input.SQL_TABLE_NAME} ;;
+ # partition_keys: ["session_date"]
+ #cluster_keys: ["session_date"]
+ sql:
+ select * from
+ (WITH
+ visitors_labeled AS (
+ SELECT
+ user_pseudo_id,
+ MIN(
+ CASE
+ WHEN REGEXP_CONTAINS(event_name, 'purchase')
+ THEN event_timestamp END) AS event_session,
+ MIN(
+ CASE
+ WHEN REGEXP_CONTAINS(event_name, 'purchase')
+ THEN event_date END) AS event_date,
+ MAX(
+ CASE
+ WHEN REGEXP_CONTAINS(event_name, 'purchase')
+ THEN 1
+ ELSE 0 END) AS label
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_future_synth_months} MONTH)
+ GROUP BY
+ user_pseudo_id
+ ),
+ visitor_location AS (
+ SELECT
+ GA.user_pseudo_id,
+ MAX(geo.city) AS city,
+ MAX(geo.region) AS region,
+ MAX(geo.country) AS country
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ LEFT JOIN visitors_labeled AS Labels
+ ON GA.user_pseudo_id = Labels.user_pseudo_id
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_future_synth_months} MONTH)
+ AND (
+ GA.event_timestamp < IFNULL(event_session, 0)
+ OR event_session IS NULL)
+ GROUP BY
+ user_pseudo_id
+ ),
+ visitor_day_page_map AS (
+ SELECT
+ GA.user_pseudo_id,
+ EXTRACT(DAYOFWEEK FROM PARSE_DATE('%Y%m%d', GA.event_date)) AS day,
+ SUM(
+ CASE
+ WHEN event_name = 'page_view'
+ THEN 1
+ ELSE 0
+ END)
+ AS pages_viewed
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ LEFT JOIN visitors_labeled AS Labels
+ ON GA.user_pseudo_id = Labels.user_pseudo_id
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_future_synth_months} MONTH)
+ AND (
+ GA.event_timestamp < IFNULL(event_session, 0)
+ OR event_session IS NULL)
+ GROUP BY
+ 1, 2
+ ),
+ visitor_common_day AS (
+ SELECT
+ user_pseudo_id,
+ /* In the event of a tie, pick any of the top dates. */
+ CASE
+ WHEN ANY_VALUE(day) = 1 THEN 'Sunday'
+ WHEN ANY_VALUE(day) = 2 THEN 'Monday'
+ WHEN ANY_VALUE(day) = 3 THEN 'Tuesday'
+ WHEN ANY_VALUE(day) = 4 THEN 'Wednesday'
+ WHEN ANY_VALUE(day) = 5 THEN 'Thursday'
+ WHEN ANY_VALUE(day) = 6 THEN 'Friday'
+ WHEN ANY_VALUE(day) = 7 THEN 'Saturday'
+ END AS day
+ FROM
+ visitor_day_page_map AS day_page_map
+ WHERE day_page_map.pages_viewed = (
+ SELECT MAX(pages_viewed)
+ FROM visitor_day_page_map AS day_map
+ WHERE day_page_map.user_pseudo_id = day_map.user_pseudo_id)
+ GROUP BY 1
+ ),
+ event_cnts AS (
+ SELECT
+ GA.user_pseudo_id,
+ SUM(IF(event_name = 'user_engagement', 1, 0)) AS cnt_user_engagement,
+ SUM(IF(event_name = 'scroll', 1, 0)) AS cnt_scroll,
+ SUM(IF(event_name = 'session_start', 1, 0)) AS cnt_session_start
+ -- Uncomment, customize, and copy the line below to count specific events.
+ -- SUM(IF(event_name = 'my custom event', 1, 0)) AS cnt_my_custom_event
+ -- Don't forget to add a comma after 'cnt_session_start' when adding a new field.
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ LEFT JOIN visitors_labeled AS Labels
+ ON GA.user_pseudo_id = Labels.user_pseudo_id
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_future_synth_months} MONTH)
+ AND (
+ GA.event_timestamp < IFNULL(event_session, 0)
+ OR event_session IS NULL)
+ GROUP BY 1
+ ),
+ engagement AS (
+ SELECT
+ user_pseudo_id,
+ SAFE_DIVIDE(
+ SUM(session_engaged),
+ COUNT(DISTINCT session_id)
+ ) AS engagement_rate,
+ ROUND(SUM(engagement_time_msec)/1000) AS engagement_time_seconds,
+ COUNT(DISTINCT session_id) AS total_sessions
+ FROM (
+ SELECT
+ GA.user_pseudo_id,
+ (
+ SELECT value.int_value
+ FROM UNNEST(event_params)
+ WHERE key = 'ga_session_id'
+ ) AS session_id,
+ MAX((
+ SELECT value.int_value
+ FROM UNNEST(event_params)
+ WHERE key = 'session_engaged'
+ )) AS session_engaged,
+ MAX((
+ SELECT value.int_value
+ FROM UNNEST(event_params)
+ WHERE key = 'engagement_time_msec'
+ )) AS engagement_time_msec
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ LEFT JOIN visitors_labeled AS Labels
+ ON GA.user_pseudo_id = Labels.user_pseudo_id
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_future_synth_months} MONTH)
+ AND (
+ GA.event_timestamp < IFNULL(event_session, 0)
+ OR event_session IS NULL)
+ GROUP BY
+ user_pseudo_id,
+ session_id
+ )
+ GROUP BY user_pseudo_id
+ ),
+ user_model AS (
+ SELECT
+ GA.user_pseudo_id,
+ IFNULL(MAX(label), 0) AS will_purchase_in_future,
+ MAX(Visitor_location.country) AS visited_country,
+ MAX(Visitor_location.region) AS visited_region,
+ MAX(Visitor_location.city) AS visited_city,
+ MAX(Visitor_common_day.day) AS visited_dow,
+ SUM(
+ CASE
+ WHEN event_name = 'page_view'
+ THEN 1
+ ELSE 0 END) AS pageviews,
+ MAX(device.operating_system) AS device_operating_system,
+ MAX(device.operating_system_version) AS device_operating_system_version,
+ MAX(device.category) AS device_category,
+ MAX(device.web_info.browser) AS browser,
+ MAX(traffic_source.medium) AS medium,
+ MAX(traffic_source.source) AS source,
+ COUNT(DISTINCT event_name) AS events,
+ MAX(event_name) AS common_events,
+ MAX(device.mobile_brand_name) AS device_mobile_brand_name,
+ MAX(device.mobile_model_name) AS device_mobile_model_name,
+ MAX(device.language) AS device_language,
+ COUNT(DISTINCT EXTRACT(DAYOFWEEK FROM PARSE_DATE('%Y%m%d', GA.event_date)))
+ AS num_diff_days_visited,
+ IFNULL(MAX(Engagement.engagement_rate), 0) AS engagement_rate,
+ IFNULL(MAX(Engagement.engagement_time_seconds), 0) AS engagement_time_seconds,
+ IFNULL(MAX(Event_counts.cnt_user_engagement), 0) AS cnt_user_engagement,
+ IFNULL(MAX(Event_counts.cnt_scroll), 0) AS cnt_scroll,
+ IFNULL(MAX(Event_counts.cnt_session_start), 0) AS cnt_session_start
+ -- Uncomment the field below to add your additional feature to the model.
+ -- IFNULL(MAX(Event_counts.cnt_my_custom_event), 0) AS cnt_my_custom_event
+ -- Don't forget to add a comma after 'cnt_session_start' when adding a new field.
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ LEFT JOIN visitors_labeled AS Labels
+ ON GA.user_pseudo_id = Labels.user_pseudo_id
+ LEFT JOIN engagement AS Engagement
+ ON GA.user_pseudo_id = Engagement.user_pseudo_id
+ LEFT JOIN visitor_location AS Visitor_location
+ ON GA.user_pseudo_id = Visitor_location.user_pseudo_id
+ LEFT JOIN visitor_common_day AS Visitor_common_day
+ ON GA.user_pseudo_id = Visitor_common_day.user_pseudo_id
+ LEFT JOIN event_cnts AS Event_counts
+ ON GA.user_pseudo_id = Event_counts.user_pseudo_id
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_future_synth_months} MONTH)
+ AND (
+ GA.event_timestamp < IFNULL(event_session, 0)
+ OR event_session IS NULL)
+ AND platform IN ('WEB')
+ GROUP BY
+ GA.user_pseudo_id
+ )
+ SELECT
+ * EXCEPT(will_purchase_in_future)
+ FROM
+ user_model);;
+ }
+}
diff --git a/views/bqml/purchase_propensity/incremental_prediction.view.lkml b/views/bqml/purchase_propensity/incremental_prediction.view.lkml
new file mode 100644
index 0000000..5ebf769
--- /dev/null
+++ b/views/bqml/purchase_propensity/incremental_prediction.view.lkml
@@ -0,0 +1,95 @@
+include: "/explores/sessions.explore.lkml"
+include: "/views/*/*.view.lkml"
+include: "/views/bqml/*/*.view.lkml"
+include: "/views/*.view.lkml"
+
+explore: pred_history {}
+view: pred_history {
+ derived_table: {
+ explore_source: sessions {
+ column: pred_probability_bucket { field: future_purchase_prediction.pred_probability_bucket }
+ column: total_purchase_revenue_usd { field: events.total_purchase_revenue_usd }
+ column: count { field: future_purchase_prediction.count }
+ derived_column: week {
+ sql:DATE_TRUNC(current_date(), week);;
+ }
+ filters: {
+ field: future_purchase_prediction.user_pseudo_id
+ value: "NOT NULL"
+ }
+ filters: {
+ field: sessions.session_date
+ value: "90 days"
+ }
+ }
+ }
+ dimension: pred_probability_bucket {
+ label: "Propensity to Purchase Pred Probability Bucket"
+ description: ""
+ }
+ dimension: total_purchase_revenue_usd {
+ label: "Events Purchase Revenue (USD)"
+ description: ""
+ value_format: "$#,##0.00"
+ type: number
+ }
+ dimension: count {
+ label: "Propensity to Purchase Person Count"
+ description: ""
+ type: number
+ }
+ dimension: week {
+ # label: "Week of PDT creation"
+ description: "Week of PDT creation"
+ type: date
+ # sql: concat("Week",cast(EXTRACT(WEEK FROM current_date()) as string)) ;;
+ }
+ # dimension: week_num {
+ # # label: "Week of PDT creation"
+ # description: "Week num of PDT creation"
+ # type: number
+ # sql: EXTRACT(WEEK FROM current_date()) ;;
+ # }
+}
+
+explore: incremental_prediction {hidden:yes}
+view: incremental_prediction {
+ derived_table: {
+ #datagroup_trigger: bqml_datagroup
+ sql_trigger_value: ${future_purchase_model.SQL_TABLE_NAME} ;;
+ create_process: {
+ sql_step:
+ CREATE TABLE IF NOT EXISTS ${SQL_TABLE_NAME} (
+ pred_probability_bucket STRING,
+ total_purchase_revenue_usd FLOAT64,
+ count INT64,
+ week DATE
+ );;
+ sql_step:
+ Insert into ${SQL_TABLE_NAME}
+ SELECT
+ pred_probability_bucket,total_purchase_revenue_usd,count, week
+ FROM ${pred_history.SQL_TABLE_NAME}
+ where week not in (select distinct week from ${SQL_TABLE_NAME});;
+ }
+ }
+ dimension: week {
+ description: "Week of PDT creation"
+ # type: date
+ }
+ dimension: pred_probability_bucket {
+ label: "Pred History Propensity to Purchase Pred Probability Bucket"
+ description: "Pred History Propensity to Purchase Pred Probability Bucket"
+ }
+ measure: total_purchase_revenue_usd {
+ label: "Pred History Events Purchase Revenue (USD)"
+ description: "Pred History Events Purchase Revenue (USD)"
+ value_format: "$#,##0.00"
+ type: sum
+ }
+ measure: count {
+ label: "Pred History Propensity to Purchase Person Count"
+ description: "Pred History Propensity to Purchase Person Count"
+ type: sum
+ }
+}
diff --git a/views/bqml/purchase_propensity/predictions.view.lkml b/views/bqml/purchase_propensity/predictions.view.lkml
new file mode 100644
index 0000000..05af958
--- /dev/null
+++ b/views/bqml/purchase_propensity/predictions.view.lkml
@@ -0,0 +1,247 @@
+######################## TRAINING/TESTING INPUTS #############################
+include: "/views/bqml/purchase_propensity/*.view"
+include: "/views/sessions/*.view"
+
+######################## MODEL #############################
+
+view: future_purchase_model {
+ derived_table: {
+ sql_trigger_value: ${future_input.SQL_TABLE_NAME} ;;
+ sql_create:
+ CREATE OR REPLACE MODEL ${SQL_TABLE_NAME}
+ OPTIONS(
+ MODEL_TYPE = 'BOOSTED_TREE_CLASSIFIER',
+ BOOSTER_TYPE = 'GBTREE',
+ MAX_ITERATIONS = 100,
+ --LEARN_RATE = 0.1,
+ COLSAMPLE_BYLEVEL = 0.85,
+ COLSAMPLE_BYTREE = 0.85,
+ COLSAMPLE_BYNODE = 0.85,
+ SUBSAMPLE = 0.85,
+ --NUM_PARALLEL_TREE = 10,
+ DATA_SPLIT_METHOD = 'AUTO_SPLIT',
+ EARLY_STOP = FALSE,
+ ENABLE_GLOBAL_EXPLAIN = TRUE,
+ APPROX_GLOBAL_FEATURE_CONTRIB = TRUE,
+ INPUT_LABEL_COLS = ['will_purchase_in_future']
+ ) AS
+ SELECT
+ * EXCEPT(user_pseudo_id)
+ FROM ${training_input.SQL_TABLE_NAME};;
+ }
+}
+
+######################## TRAINING INFORMATION #############################
+explore: future_purchase_model_evaluation {hidden:yes}
+explore: future_purchase_model_training_info {hidden:yes}
+explore: roc_curve {hidden:yes}
+explore: confusion_matrix {hidden:yes}
+explore: feature_importance {hidden:yes}
+
+# VIEWS:
+view: future_purchase_model_evaluation {
+ derived_table: {
+ sql_trigger_value: ${future_purchase_model.SQL_TABLE_NAME} ;;
+ sql: SELECT * FROM ml.EVALUATE(
+ MODEL ${future_purchase_model.SQL_TABLE_NAME},
+ (SELECT * FROM ${testing_input.SQL_TABLE_NAME}));;
+ }
+ dimension: recall {type: number value_format_name:percent_2}
+ dimension: accuracy {type: number value_format_name:percent_2}
+ dimension: f1_score {type: number value_format_name:percent_3}
+ dimension: log_loss {type: number}
+ dimension: roc_auc {type: number}
+}
+
+view: roc_curve {
+ derived_table: {
+ sql_trigger_value: ${future_purchase_model.SQL_TABLE_NAME} ;;
+ sql: SELECT * FROM ml.ROC_CURVE(
+ MODEL ${future_purchase_model.SQL_TABLE_NAME},
+ (SELECT * FROM ${testing_input.SQL_TABLE_NAME}));;
+ }
+ dimension: threshold {
+ type: number
+ link: {
+ label: "Likely Customers to Purchase"
+ url: "/explore/bqml_ga_demo/ga_sessions?fields=ga_sessions.fullVisitorId,future_purchase_prediction.max_predicted_score&f[future_purchase_prediction.predicted_will_purchase_in_future]=%3E%3D{{value}}"
+ icon_url: "http://www.looker.com/favicon.ico"
+ }
+ }
+ dimension: recall {type: number value_format_name: percent_2}
+ dimension: false_positive_rate {type: number}
+ dimension: true_positives {type: number }
+ dimension: false_positives {type: number}
+ dimension: true_negatives {type: number}
+ dimension: false_negatives {type: number }
+ dimension: precision {
+ type: number
+ value_format_name: percent_2
+ sql: ${true_positives} / NULLIF((${true_positives} + ${false_positives}),0);;
+ }
+ measure: total_false_positives {
+ type: sum
+ sql: ${false_positives} ;;
+ }
+ measure: total_true_positives {
+ type: sum
+ sql: ${true_positives} ;;
+ }
+ dimension: threshold_accuracy {
+ type: number
+ value_format_name: percent_2
+ sql: 1.0*(${true_positives} + ${true_negatives}) / NULLIF((${true_positives} + ${true_negatives} + ${false_positives} + ${false_negatives}),0);;
+ }
+ dimension: threshold_f1 {
+ type: number
+ value_format_name: percent_3
+ sql: 2.0*${recall}*${precision} / NULLIF((${recall}+${precision}),0);;
+ }
+}
+
+view: confusion_matrix {
+ derived_table: {
+ sql_trigger_value: ${future_purchase_model.SQL_TABLE_NAME} ;;
+ sql: SELECT Expected_label,_0 as Predicted_0,_1 as Predicted_1 FROM ml.confusion_matrix(
+ MODEL ${future_purchase_model.SQL_TABLE_NAME},
+ (SELECT * FROM ${testing_input.SQL_TABLE_NAME}));;
+ }
+ dimension: Expected_label {type:string}
+ dimension: Predicted_0 {type: number}
+ dimension: Predicted_1 {type: number}
+}
+
+view: future_purchase_model_training_info {
+ derived_table: {
+ sql_trigger_value: ${future_purchase_model.SQL_TABLE_NAME} ;;
+ sql: SELECT * FROM ml.TRAINING_INFO(MODEL ${future_purchase_model.SQL_TABLE_NAME});;
+ }
+ dimension: training_run {type: number}
+ dimension: iteration {type: number}
+ dimension: loss_raw {sql: ${TABLE}.loss;; type: number hidden:yes}
+ dimension: eval_loss {type: number}
+ dimension: duration_ms {label:"Duration (ms)" type: number}
+ dimension: learning_rate {type: number}
+ measure: total_iterations {
+ type: count
+ }
+ measure: loss {
+ value_format_name: decimal_2
+ type: sum
+ sql: ${loss_raw} ;;
+ }
+ measure: total_training_time {
+ type: sum
+ label:"Total Training Time (sec)"
+ sql: ${duration_ms}/1000 ;;
+ value_format_name: decimal_1
+ }
+ measure: average_iteration_time {
+ type: average
+ label:"Average Iteration Time (sec)"
+ sql: ${duration_ms}/1000 ;;
+ value_format_name: decimal_1
+ }
+}
+
+view: feature_importance {
+ derived_table: {
+ sql_trigger_value: ${future_purchase_model.SQL_TABLE_NAME} ;;
+ sql: SELECT
+ *
+ FROM
+ ML.GLOBAL_EXPLAIN(MODEL ${future_purchase_model.SQL_TABLE_NAME});;
+ }
+ dimension: feature {type:string}
+ dimension: attribution {type: number value_format_name: decimal_2}
+}
+
+########################################## PREDICT FUTURE ############################
+explore: future_purchase_prediction {hidden:yes}
+view: future_purchase_prediction {
+ derived_table: {
+ sql_trigger_value: ${future_purchase_model.SQL_TABLE_NAME} ;;
+ sql: select
+ pred.*,
+ predicted_will_purchase_in_future_probs_unnest.prob as pred_probability from
+ (SELECT * FROM ml.PREDICT(
+ MODEL ${future_purchase_model.SQL_TABLE_NAME},
+ (SELECT * FROM ${future_input.SQL_TABLE_NAME}))) pred
+ left join unnest(pred.predicted_will_purchase_in_future_probs) as predicted_will_purchase_in_future_probs_unnest
+ where predicted_will_purchase_in_future_probs_unnest.label=1
+ ;;
+ }
+ dimension: predicted_will_purchase_in_future {type: number}
+ # dimension: sl_key {type: number hidden:yes}
+ # dimension: user_pseudo_id {type: number hidden: yes}
+ dimension: user_pseudo_id {type: number primary_key: yes}
+ # dimension: prob {type: number hidden: yes}
+
+ dimension: pred_probability {
+ type: number
+ value_format_name: percent_2
+ sql: ${TABLE}.pred_probability ;;
+ drill_fields: [user_pseudo_id]
+ }
+ dimension: pred_prob_perc {
+ type: number
+ sql:APPROX_QUANTILES(${TABLE}.pred_probability,100);;
+ }
+ dimension: pred_prob_perc_10 {
+ type: number
+ hidden: yes
+ sql: ${pred_prob_perc}[OFFSET(10)] ;;
+ }
+ dimension: pred_prob_perc_20 {
+ type: number
+ hidden: yes
+ sql: ${pred_prob_perc}[OFFSET(20)] ;;
+ }
+ dimension: pred_prob_perc_30 {
+ type: number
+ hidden: yes
+ sql: ${pred_prob_perc}[OFFSET(30)];;
+ }
+ dimension: pred_prob_perc_40 {
+ type: number
+ hidden: yes
+ sql:${pred_prob_perc}[OFFSET(40)];;
+ }
+ dimension: pred_prob_perc_50 {
+ type: number
+ hidden: yes
+ sql: ${pred_prob_perc}[OFFSET(50)] ;;
+ }
+ dimension: pred_prob_perc_60 {
+ type: number
+ hidden: yes
+ sql:${pred_prob_perc}[OFFSET(60)] ;;
+ }
+ dimension: pred_prob_perc_70 {
+ type: number
+ hidden: yes
+ sql: ${pred_prob_perc}[OFFSET(70)] ;;
+ }
+ dimension: pred_prob_perc_80 {
+ type: number
+ hidden: yes
+ sql: ${pred_prob_perc}[OFFSET(80)];;
+ }
+ dimension: pred_prob_perc_90 {
+ type: number
+ hidden: yes
+ sql: ${pred_prob_perc}[OFFSET(90)] ;;
+ }
+
+ dimension: pred_probability_bucket {
+ type: tier
+ tiers: [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]
+ style: relational
+ sql: ${pred_probability} ;;
+ drill_fields: [user_pseudo_id]
+ }
+ measure: count {
+ label:"Person Count"
+ type: count
+ }
+}
diff --git a/views/bqml/purchase_propensity/testing_input.view.lkml b/views/bqml/purchase_propensity/testing_input.view.lkml
new file mode 100644
index 0000000..f96d87b
--- /dev/null
+++ b/views/bqml/purchase_propensity/testing_input.view.lkml
@@ -0,0 +1,215 @@
+include: "/views/sessions/*.view.lkml"
+view: testing_input {
+ derived_table: {
+ sql_trigger_value: ${training_input.SQL_TABLE_NAME} ;;
+ sql:
+ select * from
+ (WITH
+ visitors_labeled AS (
+ SELECT
+ user_pseudo_id,
+ MIN(
+ CASE
+ WHEN REGEXP_CONTAINS(event_name, 'purchase')
+ THEN event_timestamp END) AS event_session,
+ MIN(
+ CASE
+ WHEN REGEXP_CONTAINS(event_name, 'purchase')
+ THEN event_date END) AS event_date,
+ MAX(
+ CASE
+ WHEN REGEXP_CONTAINS(event_name, 'purchase')
+ THEN 1
+ ELSE 0 END) AS label
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_test_months} MONTH)
+ GROUP BY
+ user_pseudo_id
+ ),
+ visitor_location AS (
+ SELECT
+ GA.user_pseudo_id,
+ MAX(geo.city) AS city,
+ MAX(geo.region) AS region,
+ MAX(geo.country) AS country
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ LEFT JOIN visitors_labeled AS Labels
+ ON GA.user_pseudo_id = Labels.user_pseudo_id
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_test_months} MONTH)
+ AND (
+ GA.event_timestamp < IFNULL(event_session, 0)
+ OR event_session IS NULL)
+ GROUP BY
+ user_pseudo_id
+ ),
+ visitor_day_page_map AS (
+ SELECT
+ GA.user_pseudo_id,
+ EXTRACT(DAYOFWEEK FROM PARSE_DATE('%Y%m%d', GA.event_date)) AS day,
+ SUM(
+ CASE
+ WHEN event_name = 'page_view'
+ THEN 1
+ ELSE 0
+ END)
+ AS pages_viewed
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ LEFT JOIN visitors_labeled AS Labels
+ ON GA.user_pseudo_id = Labels.user_pseudo_id
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_test_months} MONTH)
+ AND (
+ GA.event_timestamp < IFNULL(event_session, 0)
+ OR event_session IS NULL)
+ GROUP BY
+ 1, 2
+ ),
+ visitor_common_day AS (
+ SELECT
+ user_pseudo_id,
+ /* In the event of a tie, pick any of the top dates. */
+ CASE
+ WHEN ANY_VALUE(day) = 1 THEN 'Sunday'
+ WHEN ANY_VALUE(day) = 2 THEN 'Monday'
+ WHEN ANY_VALUE(day) = 3 THEN 'Tuesday'
+ WHEN ANY_VALUE(day) = 4 THEN 'Wednesday'
+ WHEN ANY_VALUE(day) = 5 THEN 'Thursday'
+ WHEN ANY_VALUE(day) = 6 THEN 'Friday'
+ WHEN ANY_VALUE(day) = 7 THEN 'Saturday'
+ END AS day
+ FROM
+ visitor_day_page_map AS day_page_map
+ WHERE day_page_map.pages_viewed = (
+ SELECT MAX(pages_viewed)
+ FROM visitor_day_page_map AS day_map
+ WHERE day_page_map.user_pseudo_id = day_map.user_pseudo_id)
+ GROUP BY 1
+ ),
+ event_cnts AS (
+ SELECT
+ GA.user_pseudo_id,
+ SUM(IF(event_name = 'user_engagement', 1, 0)) AS cnt_user_engagement,
+ SUM(IF(event_name = 'scroll', 1, 0)) AS cnt_scroll,
+ SUM(IF(event_name = 'session_start', 1, 0)) AS cnt_session_start
+ -- Uncomment, customize, and copy the line below to count specific events.
+ -- SUM(IF(event_name = 'my custom event', 1, 0)) AS cnt_my_custom_event
+ -- Don't forget to add a comma after 'cnt_session_start' when adding a new field.
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ LEFT JOIN visitors_labeled AS Labels
+ ON GA.user_pseudo_id = Labels.user_pseudo_id
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_test_months} MONTH)
+ AND (
+ GA.event_timestamp < IFNULL(event_session, 0)
+ OR event_session IS NULL)
+ GROUP BY 1
+ ),
+ engagement AS (
+ SELECT
+ user_pseudo_id,
+ SAFE_DIVIDE(
+ SUM(session_engaged),
+ COUNT(DISTINCT session_id)
+ ) AS engagement_rate,
+ ROUND(SUM(engagement_time_msec)/1000) AS engagement_time_seconds,
+ COUNT(DISTINCT session_id) AS total_sessions
+ FROM (
+ SELECT
+ GA.user_pseudo_id,
+ (
+ SELECT value.int_value
+ FROM UNNEST(event_params)
+ WHERE key = 'ga_session_id'
+ ) AS session_id,
+ MAX((
+ SELECT value.int_value
+ FROM UNNEST(event_params)
+ WHERE key = 'session_engaged'
+ )) AS session_engaged,
+ MAX((
+ SELECT value.int_value
+ FROM UNNEST(event_params)
+ WHERE key = 'engagement_time_msec'
+ )) AS engagement_time_msec
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ LEFT JOIN visitors_labeled AS Labels
+ ON GA.user_pseudo_id = Labels.user_pseudo_id
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_test_months} MONTH)
+ AND (
+ GA.event_timestamp < IFNULL(event_session, 0)
+ OR event_session IS NULL)
+ GROUP BY
+ user_pseudo_id,
+ session_id
+ )
+ GROUP BY user_pseudo_id
+ ),
+ user_model AS (
+ SELECT
+ GA.user_pseudo_id,
+ IFNULL(MAX(label), 0) AS will_purchase_in_future,
+ MAX(Visitor_location.country) AS visited_country,
+ MAX(Visitor_location.region) AS visited_region,
+ MAX(Visitor_location.city) AS visited_city,
+ MAX(Visitor_common_day.day) AS visited_dow,
+ SUM(
+ CASE
+ WHEN event_name = 'page_view'
+ THEN 1
+ ELSE 0 END) AS pageviews,
+ MAX(device.operating_system) AS device_operating_system,
+ MAX(device.operating_system_version) AS device_operating_system_version,
+ MAX(device.category) AS device_category,
+ MAX(device.web_info.browser) AS browser,
+ MAX(traffic_source.medium) AS medium,
+ MAX(traffic_source.source) AS source,
+ COUNT(DISTINCT event_name) AS events,
+ MAX(event_name) AS common_events,
+ MAX(device.mobile_brand_name) AS device_mobile_brand_name,
+ MAX(device.mobile_model_name) AS device_mobile_model_name,
+ MAX(device.language) AS device_language,
+ COUNT(DISTINCT EXTRACT(DAYOFWEEK FROM PARSE_DATE('%Y%m%d', GA.event_date)))
+ AS num_diff_days_visited,
+ IFNULL(MAX(Engagement.engagement_rate), 0) AS engagement_rate,
+ IFNULL(MAX(Engagement.engagement_time_seconds), 0) AS engagement_time_seconds,
+ IFNULL(MAX(Event_counts.cnt_user_engagement), 0) AS cnt_user_engagement,
+ IFNULL(MAX(Event_counts.cnt_scroll), 0) AS cnt_scroll,
+ IFNULL(MAX(Event_counts.cnt_session_start), 0) AS cnt_session_start
+ -- Uncomment the field below to add your additional feature to the model.
+ -- IFNULL(MAX(Event_counts.cnt_my_custom_event), 0) AS cnt_my_custom_event
+ -- Don't forget to add a comma after 'cnt_session_start' when adding a new field.
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ LEFT JOIN visitors_labeled AS Labels
+ ON GA.user_pseudo_id = Labels.user_pseudo_id
+ LEFT JOIN engagement AS Engagement
+ ON GA.user_pseudo_id = Engagement.user_pseudo_id
+ LEFT JOIN visitor_location AS Visitor_location
+ ON GA.user_pseudo_id = Visitor_location.user_pseudo_id
+ LEFT JOIN visitor_common_day AS Visitor_common_day
+ ON GA.user_pseudo_id = Visitor_common_day.user_pseudo_id
+ LEFT JOIN event_cnts AS Event_counts
+ ON GA.user_pseudo_id = Event_counts.user_pseudo_id
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_test_months} MONTH)
+ AND (
+ GA.event_timestamp < IFNULL(event_session, 0)
+ OR event_session IS NULL)
+ AND platform IN ('WEB')
+ GROUP BY
+ GA.user_pseudo_id
+ )
+ SELECT
+ *
+ FROM
+ user_model);;
+ }
+}
diff --git a/views/bqml/purchase_propensity/training_input.view.lkml b/views/bqml/purchase_propensity/training_input.view.lkml
new file mode 100644
index 0000000..f3fe331
--- /dev/null
+++ b/views/bqml/purchase_propensity/training_input.view.lkml
@@ -0,0 +1,216 @@
+include: "/views/sessions/*.view.lkml"
+include: "/views/*/*.view.lkml"
+view: training_input {
+ derived_table: {
+ #datagroup_trigger: bqml_datagroup
+ sql_trigger_value: ${sessions.SQL_TABLE_NAME} ;;
+ sql:
+ WITH
+ visitors_labeled AS (
+ SELECT
+ user_pseudo_id,
+ MIN(
+ CASE
+ WHEN REGEXP_CONTAINS(event_name, 'purchase')
+ THEN event_timestamp END) AS event_session,
+ MIN(
+ CASE
+ WHEN REGEXP_CONTAINS(event_name, 'purchase')
+ THEN event_date END) AS event_date,
+ MAX(
+ CASE
+ WHEN REGEXP_CONTAINS(event_name, 'purchase')
+ THEN 1
+ ELSE 0 END) AS label
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL (@{GA4_BQML_train_months} + @{GA4_BQML_test_months}) MONTH) AND DATE(session_date) < DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_test_months} MONTH)
+ GROUP BY
+ user_pseudo_id
+ ),
+ visitor_location AS (
+ SELECT
+ GA.user_pseudo_id,
+ MAX(geo.city) AS city,
+ MAX(geo.region) AS region,
+ MAX(geo.country) AS country
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ LEFT JOIN visitors_labeled AS Labels
+ ON GA.user_pseudo_id = Labels.user_pseudo_id
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL (@{GA4_BQML_train_months} + @{GA4_BQML_test_months}) MONTH) AND DATE(session_date) < DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_test_months} MONTH)
+ AND (
+ GA.event_timestamp < IFNULL(event_session, 0)
+ OR event_session IS NULL)
+ GROUP BY
+ user_pseudo_id
+ ),
+ visitor_day_page_map AS (
+ SELECT
+ GA.user_pseudo_id,
+ EXTRACT(DAYOFWEEK FROM PARSE_DATE('%Y%m%d', GA.event_date)) AS day,
+ SUM(
+ CASE
+ WHEN event_name = 'page_view'
+ THEN 1
+ ELSE 0
+ END)
+ AS pages_viewed
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ LEFT JOIN visitors_labeled AS Labels
+ ON GA.user_pseudo_id = Labels.user_pseudo_id
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL (@{GA4_BQML_train_months} + @{GA4_BQML_test_months}) MONTH) AND DATE(session_date) < DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_test_months} MONTH)
+ AND (
+ GA.event_timestamp < IFNULL(event_session, 0)
+ OR event_session IS NULL)
+ GROUP BY
+ 1, 2
+ ),
+ visitor_common_day AS (
+ SELECT
+ user_pseudo_id,
+ /* In the event of a tie, pick any of the top dates. */
+ CASE
+ WHEN ANY_VALUE(day) = 1 THEN 'Sunday'
+ WHEN ANY_VALUE(day) = 2 THEN 'Monday'
+ WHEN ANY_VALUE(day) = 3 THEN 'Tuesday'
+ WHEN ANY_VALUE(day) = 4 THEN 'Wednesday'
+ WHEN ANY_VALUE(day) = 5 THEN 'Thursday'
+ WHEN ANY_VALUE(day) = 6 THEN 'Friday'
+ WHEN ANY_VALUE(day) = 7 THEN 'Saturday'
+ END AS day
+ FROM
+ visitor_day_page_map AS day_page_map
+ WHERE day_page_map.pages_viewed = (
+ SELECT MAX(pages_viewed)
+ FROM visitor_day_page_map AS day_map
+ WHERE day_page_map.user_pseudo_id = day_map.user_pseudo_id)
+ GROUP BY 1
+ ),
+ event_cnts AS (
+ SELECT
+ GA.user_pseudo_id,
+ SUM(IF(event_name = 'user_engagement', 1, 0)) AS cnt_user_engagement,
+ SUM(IF(event_name = 'scroll', 1, 0)) AS cnt_scroll,
+ SUM(IF(event_name = 'session_start', 1, 0)) AS cnt_session_start
+ -- Uncomment, customize, and copy the line below to count specific events.
+ -- SUM(IF(event_name = 'my custom event', 1, 0)) AS cnt_my_custom_event
+ -- Don't forget to add a comma after 'cnt_session_start' when adding a new field.
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ LEFT JOIN visitors_labeled AS Labels
+ ON GA.user_pseudo_id = Labels.user_pseudo_id
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL (@{GA4_BQML_train_months} + @{GA4_BQML_test_months}) MONTH) AND DATE(session_date) < DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_test_months} MONTH)
+ AND (
+ GA.event_timestamp < IFNULL(event_session, 0)
+ OR event_session IS NULL)
+ GROUP BY 1
+ ),
+ engagement AS (
+ SELECT
+ user_pseudo_id,
+ SAFE_DIVIDE(
+ SUM(session_engaged),
+ COUNT(DISTINCT session_id)
+ ) AS engagement_rate,
+ ROUND(SUM(engagement_time_msec)/1000) AS engagement_time_seconds,
+ COUNT(DISTINCT session_id) AS total_sessions
+ FROM (
+ SELECT
+ GA.user_pseudo_id,
+ (
+ SELECT value.int_value
+ FROM UNNEST(event_params)
+ WHERE key = 'ga_session_id'
+ ) AS session_id,
+ MAX((
+ SELECT value.int_value
+ FROM UNNEST(event_params)
+ WHERE key = 'session_engaged'
+ )) AS session_engaged,
+ MAX((
+ SELECT value.int_value
+ FROM UNNEST(event_params)
+ WHERE key = 'engagement_time_msec'
+ )) AS engagement_time_msec
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ LEFT JOIN visitors_labeled AS Labels
+ ON GA.user_pseudo_id = Labels.user_pseudo_id
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL (@{GA4_BQML_train_months} + @{GA4_BQML_test_months}) MONTH) AND DATE(session_date) < DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_test_months} MONTH)
+ AND (
+ GA.event_timestamp < IFNULL(event_session, 0)
+ OR event_session IS NULL)
+ GROUP BY
+ user_pseudo_id,
+ session_id
+ )
+ GROUP BY user_pseudo_id
+ ),
+ user_model AS (
+ SELECT
+ GA.user_pseudo_id,
+ IFNULL(MAX(label), 0) AS will_purchase_in_future,
+ MAX(Visitor_location.country) AS visited_country,
+ MAX(Visitor_location.region) AS visited_region,
+ MAX(Visitor_location.city) AS visited_city,
+ MAX(Visitor_common_day.day) AS visited_dow,
+ SUM(
+ CASE
+ WHEN event_name = 'page_view'
+ THEN 1
+ ELSE 0 END) AS pageviews,
+ MAX(device.operating_system) AS device_operating_system,
+ MAX(device.operating_system_version) AS device_operating_system_version,
+ MAX(device.category) AS device_category,
+ MAX(device.web_info.browser) AS browser,
+ MAX(traffic_source.medium) AS medium,
+ MAX(traffic_source.source) AS source,
+ COUNT(DISTINCT event_name) AS events,
+ MAX(event_name) AS common_events,
+ MAX(device.mobile_brand_name) AS device_mobile_brand_name,
+ MAX(device.mobile_model_name) AS device_mobile_model_name,
+ MAX(device.language) AS device_language,
+ COUNT(DISTINCT EXTRACT(DAYOFWEEK FROM PARSE_DATE('%Y%m%d', GA.event_date)))
+ AS num_diff_days_visited,
+ IFNULL(MAX(Engagement.engagement_rate), 0) AS engagement_rate,
+ IFNULL(MAX(Engagement.engagement_time_seconds), 0) AS engagement_time_seconds,
+ IFNULL(MAX(Event_counts.cnt_user_engagement), 0) AS cnt_user_engagement,
+ IFNULL(MAX(Event_counts.cnt_scroll), 0) AS cnt_scroll,
+ IFNULL(MAX(Event_counts.cnt_session_start), 0) AS cnt_session_start
+ -- Uncomment the field below to add your additional feature to the model.
+ -- IFNULL(MAX(Event_counts.cnt_my_custom_event), 0) AS cnt_my_custom_event
+ -- Don't forget to add a comma after 'cnt_session_start' when adding a new field.
+ FROM
+ ${session_list_with_event_history.SQL_TABLE_NAME} AS GA
+ LEFT JOIN visitors_labeled AS Labels
+ ON GA.user_pseudo_id = Labels.user_pseudo_id
+ LEFT JOIN engagement AS Engagement
+ ON GA.user_pseudo_id = Engagement.user_pseudo_id
+ LEFT JOIN visitor_location AS Visitor_location
+ ON GA.user_pseudo_id = Visitor_location.user_pseudo_id
+ LEFT JOIN visitor_common_day AS Visitor_common_day
+ ON GA.user_pseudo_id = Visitor_common_day.user_pseudo_id
+ LEFT JOIN event_cnts AS Event_counts
+ ON GA.user_pseudo_id = Event_counts.user_pseudo_id
+ WHERE
+ DATE(session_date) > DATE_SUB(CURRENT_DATE(), INTERVAL (@{GA4_BQML_train_months} + @{GA4_BQML_test_months}) MONTH) AND DATE(session_date) < DATE_SUB(CURRENT_DATE(), INTERVAL @{GA4_BQML_test_months} MONTH)
+ AND (
+ GA.event_timestamp < IFNULL(event_session, 0)
+ OR event_session IS NULL)
+ AND platform IN ('WEB')
+ GROUP BY
+ GA.user_pseudo_id
+ )
+ SELECT
+ *
+ FROM
+ user_model;;
+ }
+}
diff --git a/views/event_data_dimensions/.gitkeep b/views/event_data_dimensions/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/views/event_data_dimensions/event_data_event_params.view.lkml b/views/event_data_dimensions/event_data_event_params.view.lkml
new file mode 100644
index 0000000..47e187a
--- /dev/null
+++ b/views/event_data_dimensions/event_data_event_params.view.lkml
@@ -0,0 +1,178 @@
+view: event_data_event_params {
+ extension: required
+
+ ## Event Parameters
+ ## Because there are multiple "key"/"value" rows per event, these are unnested at the dimension level.
+ ## This view is included in event_data.view, and not directly joined on the model.
+
+ dimension: event_param_all_data {
+ group_label: "Event: Parameters"
+ label: "All Data"
+ type: number
+ sql: (SELECT value.double_value FROM UNNEST(event_params) WHERE key = "all_data") ;;
+ }
+
+ dimension: event_param_campaign {
+ group_label: "Event: Parameters"
+ label: "Campaign"
+ description: "The campaign value. Usually set by the utm_campaign URL parameter."
+ type: string
+ sql: (SELECT value.string_value FROM UNNEST(event_params) WHERE key = "campaign") ;;
+ full_suggestions: yes
+ }
+
+ dimension: event_param_clean_event {
+ group_label: "Event: Parameters"
+ label: "Clean Event"
+ type: string
+ sql: (SELECT value.string_value FROM UNNEST(event_params) WHERE key = "clean_event") ;;
+ full_suggestions: yes
+ }
+
+ dimension: event_param_debug_mode {
+ group_label: "Event: Parameters"
+ label: "Debug Mode"
+ type: number
+ sql: (SELECT value.int_value FROM UNNEST(event_params) WHERE key = "debug_mode") ;;
+ }
+
+ dimension: event_param_engaged_session_event {
+ group_label: "Event: Parameters"
+ label: "Session Event"
+ type: number
+ sql: (SELECT coalesce(cast(value.string_value as INT64),value.int_value) FROM UNNEST(event_params) WHERE key = "engaged_session_event") ;;
+ }
+
+ dimension: event_param_engagement_time_msec {
+ group_label: "Event: Parameters"
+ label: "Engagement Time MSEC"
+ type: number
+ sql: (SELECT value.int_value FROM UNNEST(event_params) WHERE key = "engagement_time_msec") ;;
+ }
+
+ dimension: event_param_entrances {
+ group_label: "Event: Parameters"
+ label: "Entrances"
+ type: number
+ sql: (SELECT value.int_value FROM UNNEST(event_params) WHERE key = "entrances") ;;
+ }
+
+ dimension: event_param_ga_session_id {
+ group_label: "Event: Parameters"
+ label: "GA Session ID"
+ type: number
+ sql: (SELECT value.int_value FROM UNNEST(event_params) WHERE key = "ga_session_id") ;;
+ full_suggestions: yes
+ }
+
+ dimension: event_param_ga_session_number {
+ group_label: "Event: Parameters"
+ label: "GA Session Number"
+ type: number
+ sql: (SELECT value.int_value FROM UNNEST(event_params) WHERE key = "ga_session_number") ;;
+ }
+
+ dimension: event_param_medium {
+ group_label: "Event: Parameters"
+ label: "Medium"
+ type: string
+ sql: (SELECT value.string_value FROM UNNEST(event_params) WHERE key = "medium") ;;
+ full_suggestions: yes
+ }
+
+ dimension: event_param_host {
+ group_label: "Event: Parameters"
+ label: "Host"
+ description: "Host of Page View URL"
+ full_suggestions: yes
+ type: string
+ sql: NET.HOST((SELECT value.string_value FROM UNNEST(event_params) WHERE key = "page_location")) ;;
+ }
+
+ dimension: event_param_page {
+ group_label: "Event: Parameters"
+ label: "Page"
+ description: "The path of the page."
+ full_suggestions: yes
+ type: string
+ sql: coalesce(regexp_extract((SELECT value.string_value FROM UNNEST(event_params) WHERE key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/') ;;
+ }
+
+ # The "Page" event parameter may not be enabled, in which situation the above regex query will extract the path from the page location value.
+ # If the "Page" event parameter is enabled, you may use this below dimension instead if desired:
+ # dimension: event_param_page_path {
+ # group_label: "Event: Parameters"
+ # label: "Page"
+ # description: "The Page Path value"
+ # full_suggestions: yes
+ # type: string
+ # sql: (SELECT value.string_value FROM UNNEST(event_params) WHERE key = "page") ;;
+ # }
+
+ dimension: event_param_page_location {
+ group_label: "Event: Parameters"
+ label: "Page Location"
+ type: string
+ sql: (SELECT value.string_value FROM UNNEST(event_params) WHERE key = "page_location") ;;
+ full_suggestions: yes
+ }
+
+ dimension: event_param_page_referrer {
+ group_label: "Event: Parameters"
+ label: "Page Referrer"
+ type: string
+ sql: (SELECT value.string_value FROM UNNEST(event_params) WHERE key = "page_referrer") ;;
+ full_suggestions: yes
+ }
+
+ dimension: event_param_page_title {
+ group_label: "Event: Parameters"
+ label: "Page Title"
+ description: "The page's title. Multiple pages might have the same page title."
+ type: string
+ sql: (SELECT value.string_value FROM UNNEST(event_params) WHERE key = "page_title") ;;
+ full_suggestions: yes
+ }
+
+ dimension: event_param_percent_scrolled {
+ group_label: "Event: Parameters"
+ label: "Percent Scrolled"
+ type: number
+ sql: (SELECT value.int_value FROM UNNEST(event_params) WHERE key = "percent_scrolled") ;;
+ }
+
+ dimension: event_param_session_engaged {
+ group_label: "Event: Parameters"
+ label: "Session Engaged"
+ type: number
+ sql: (SELECT coalesce(cast(value.string_value as INT64),value.int_value) FROM UNNEST(event_params) WHERE key = "session_engaged") ;;
+ }
+
+ dimension: event_param_source {
+ group_label: "Event: Parameters"
+ label: "Source"
+ type: string
+ sql: (SELECT value.string_value FROM UNNEST(event_params) WHERE key = "source") ;;
+ full_suggestions: yes
+ }
+
+ dimension: event_param_synthetic_bundle {
+ group_label: "Event: Parameters"
+ label: "Synthetic Bundle"
+ type: number
+ sql: (SELECT coalesce(cast(value.string_value as INT64),value.int_value) FROM UNNEST(event_params) WHERE key = "synthetic_bundle") ;;
+ }
+
+ dimension: event_param_term {
+ # group_label: "Event: Parameters"
+ # label: "Term"
+ view_label: "Acquisition"
+ group_label: "Advertising"
+ label: "Keyword"
+ description: "The Event keyword of the traffic source, usually set when the trafficSource.medium is 'organic' or 'cpc'. Can be set by the utm_term URL parameter."
+ type: string
+ sql: (SELECT value.string_value FROM UNNEST(event_params) WHERE key = "term") ;;
+ full_suggestions: yes
+ }
+
+}
diff --git a/views/event_data_dimensions/event_data_user_properties.view.lkml b/views/event_data_dimensions/event_data_user_properties.view.lkml
new file mode 100644
index 0000000..501db78
--- /dev/null
+++ b/views/event_data_dimensions/event_data_user_properties.view.lkml
@@ -0,0 +1,101 @@
+view: event_data_user_properties {
+ extension: required
+
+## Dimensions
+ dimension: user_property_age {
+ group_label: "User Properties"
+ label: "Age"
+ type: string
+ sql: (SELECT value.string_value FROM UNNEST(event_params) WHERE key = "age") ;;
+ full_suggestions: yes
+ }
+
+ dimension: user_property_country {
+ group_label: "User Properties"
+ label: "Country"
+ type: string
+ sql: (SELECT value.string_value FROM UNNEST(event_params) WHERE key = "country") ;;
+ full_suggestions: yes
+ }
+
+ dimension: user_property_device_category {
+ group_label: "User Properties"
+ label: "Device Category"
+ type: string
+ sql: (SELECT value.string_value FROM UNNEST(event_params) WHERE key = "device_category") ;;
+ full_suggestions: yes
+ }
+
+ dimension: user_property_device_model {
+ group_label: "User Properties"
+ label: "Device Model"
+ type: string
+ sql: (SELECT value.string_value FROM UNNEST(event_params) WHERE key = "device_model") ;;
+ full_suggestions: yes
+ }
+
+ dimension: user_property_gender {
+ group_label: "User Properties"
+ label: "Gender"
+ type: string
+ sql: (SELECT value.string_value FROM UNNEST(event_params) WHERE key = "gender") ;;
+ full_suggestions: yes
+ }
+
+ dimension: user_property_interests {
+ group_label: "User Properties"
+ label: "Interests"
+ type: string
+ sql: (SELECT value.string_value FROM UNNEST(event_params) WHERE key = "interests") ;;
+ full_suggestions: yes
+ }
+
+ dimension: user_property_language {
+ group_label: "User Properties"
+ label: "Language"
+ type: string
+ sql: (SELECT value.string_value FROM UNNEST(event_params) WHERE key = "language") ;;
+ full_suggestions: yes
+ }
+
+ # dimension: key {
+ # type: string
+ # sql: ${TABLE}.key ;;
+ # }
+
+ # dimension: value__double_value {
+ # type: number
+ # sql: ${TABLE}.value.double_value ;;
+ # group_label: "Value"
+ # group_item_label: "Double Value"
+ # }
+
+ # dimension: value__float_value {
+ # type: number
+ # sql: ${TABLE}.value.float_value ;;
+ # group_label: "Value"
+ # group_item_label: "Float Value"
+ # }
+
+ # dimension: value__int_value {
+ # type: number
+ # sql: ${TABLE}.value.int_value ;;
+ # group_label: "Value"
+ # group_item_label: "Int Value"
+ # }
+
+ # dimension: value__set_timestamp_micros {
+ # type: number
+ # sql: ${TABLE}.value.set_timestamp_micros ;;
+ # group_label: "Value"
+ # group_item_label: "Set Timestamp Micros"
+ # }
+
+ # dimension: value__string_value {
+ # type: string
+ # sql: ${TABLE}.value.string_value ;;
+ # group_label: "Value"
+ # group_item_label: "String Value"
+ # }
+
+}
diff --git a/views/event_data_dimensions/event_funnel.view.lkml b/views/event_data_dimensions/event_funnel.view.lkml
new file mode 100644
index 0000000..a8fb35a
--- /dev/null
+++ b/views/event_data_dimensions/event_funnel.view.lkml
@@ -0,0 +1,214 @@
+view: event_funnel {
+extension: required
+
+## Filters
+ filter: event_1_filter {
+ view_label: "Event Funnel"
+ group_label: "Funnel Events"
+ suggest_explore: sessions
+ suggest_dimension: events.event_name
+ description: "Event 1 to be used with Count of Event 1"
+ }
+ filter: event_2_filter {
+ view_label: "Event Funnel"
+ group_label: "Funnel Events"
+ suggest_explore: sessions
+ suggest_dimension: events.event_name
+ description: "Event 2 to be used with Count of Event 2"
+ }
+ filter: event_3_filter {
+ view_label: "Event Funnel"
+ group_label: "Funnel Events"
+ suggest_explore: sessions
+ suggest_dimension: events.event_name
+ description: "Event 3 to be used with Count of Event 3"
+ }
+ filter: event_4_filter {
+ view_label: "Event Funnel"
+ group_label: "Funnel Events"
+ suggest_explore: sessions
+ suggest_dimension: events.event_name
+ description: "Event 4 to be used with Count of Event 4"
+ }
+ filter: event_5_filter {
+ view_label: "Event Funnel"
+ group_label: "Funnel Events"
+ suggest_explore: sessions
+ suggest_dimension: events.event_name
+ description: "Event 5 to be used with Count of Event 5"
+ }
+ filter: event_6_filter {
+ view_label: "Event Funnel"
+ group_label: "Funnel Events"
+ suggest_explore: sessions
+ suggest_dimension: events.event_name
+ description: "Event 6 to be used with Count of Event 6"
+ }
+
+## Dimensions
+ dimension: event_1 {
+ type: string
+ hidden: yes
+ sql: (select event_name from UNNEST(${sessions.event_data}) where event_rank = 1) ;;
+ }
+ dimension: event_2 {
+ type: string
+ hidden: yes
+ sql: (select event_name from UNNEST(${sessions.event_data}) where event_rank = 2) ;;
+ }
+ dimension: event_3 {
+ type: string
+ hidden: yes
+ sql: (select event_name from UNNEST(${sessions.event_data}) where event_rank = 3) ;;
+ }
+ dimension: event_4 {
+ type: string
+ hidden: yes
+ sql: (select event_name from UNNEST(${sessions.event_data}) where event_rank = 4) ;;
+ }
+ dimension: event_5 {
+ type: string
+ hidden: yes
+ sql: (select event_name from UNNEST(${sessions.event_data}) where event_rank = 5) ;;
+ }
+ dimension: event_6 {
+ type: string
+ hidden: yes
+ sql: (select event_name from UNNEST(${sessions.event_data}) where event_rank = 6) ;;
+ }
+
+ dimension: event_1_tag {
+ type: number
+ hidden: yes
+ sql: case when {% condition event_1_filter %} ${event_1} {% endcondition %} and ${event_1} is not null then 1 else 0 end ;;
+ }
+ dimension: event_2_tag {
+ type: number
+ hidden: yes
+ sql: case when {% condition event_1_filter %} ${event_1} {% endcondition %}
+ and {% condition event_2_filter %} ${event_2} {% endcondition %}
+ and ${event_2} is not null then 1 else 0 end ;;
+ }
+ dimension: event_3_tag {
+ type: number
+ hidden: yes
+ sql: case when {% condition event_1_filter %} ${event_1} {% endcondition %}
+ and {% condition event_2_filter %} ${event_2} {% endcondition %}
+ and {% condition event_3_filter %} ${event_3} {% endcondition %}
+ and ${event_2} is not null
+ and ${event_3} is not null then 1 else 0 end ;;
+ }
+ dimension: event_4_tag {
+ type: number
+ hidden: yes
+ sql: case when {% condition event_1_filter %} ${event_1} {% endcondition %}
+ and {% condition event_2_filter %} ${event_2} {% endcondition %}
+ and {% condition event_3_filter %} ${event_3} {% endcondition %}
+ and {% condition event_4_filter %} ${event_4} {% endcondition %}
+ and ${event_2} is not null
+ and ${event_3} is not null
+ and ${event_4} is not null then 1 else 0 end ;;
+ }
+ dimension: event_5_tag {
+ type: number
+ hidden: yes
+ sql: case when {% condition event_1_filter %} ${event_1} {% endcondition %}
+ and {% condition event_2_filter %} ${event_2} {% endcondition %}
+ and {% condition event_3_filter %} ${event_3} {% endcondition %}
+ and {% condition event_4_filter %} ${event_4} {% endcondition %}
+ and {% condition event_5_filter %} ${event_5} {% endcondition %}
+ and ${event_2} is not null
+ and ${event_3} is not null
+ and ${event_4} is not null
+ and ${event_5} is not null then 1 else 0 end ;;
+ }
+ dimension: event_6_tag {
+ type: number
+ hidden: yes
+ sql: case when {% condition event_1_filter %} ${event_1} {% endcondition %}
+ and {% condition event_2_filter %} ${event_2} {% endcondition %}
+ and {% condition event_3_filter %} ${event_3} {% endcondition %}
+ and {% condition event_4_filter %} ${event_4} {% endcondition %}
+ and {% condition event_5_filter %} ${event_5} {% endcondition %}
+ and {% condition event_6_filter %} ${event_6} {% endcondition %}
+ and ${event_2} is not null
+ and ${event_3} is not null
+ and ${event_4} is not null
+ and ${event_5} is not null
+ and ${event_6} is not null then 1 else 0 end ;;
+ }
+
+
+## Measures
+ measure: count_of_event_1 {
+ view_label: "Event Funnel"
+ type: sum
+ sql: ${event_1_tag} ;;
+ label: "{% if event_1_filter._in_query %}
+ {{_filters['event_1_filter']}}
+ {% else %}
+ Count of Event 1
+ {% endif %}"
+ description: "Count of Event 1 to be used with Event 1 filter, if no filter is selected it shows all events"
+ }
+
+ measure: count_of_event_2 {
+ view_label: "Event Funnel"
+ type: sum
+ sql: ${event_2_tag} ;;
+ label: "{% if event_2_filter._in_query %}
+ {{_filters['event_2_filter']}}
+ {% else %}
+ Count of Event 2
+ {% endif %}"
+ description: "Count of Event 2 to be used with Event 2 filter, if no filter is selected it shows all events"
+ }
+
+ measure: count_of_event_3 {
+ view_label: "Event Funnel"
+ type: sum
+ sql: ${event_3_tag} ;;
+ label: "{% if event_3_filter._in_query %}
+ {{_filters['event_3_filter']}}
+ {% else %}
+ Count of Event 3
+ {% endif %}"
+ description: "Count of Event 3 to be used with Event 3 filter, if no filter is selected it shows all events"
+ }
+
+ measure: count_of_event_4 {
+ view_label: "Event Funnel"
+ type: sum
+ sql: ${event_4_tag} ;;
+ label: "{% if event_4_filter._in_query %}
+ {{_filters['event_4_filter']}}
+ {% else %}
+ Count of Event 4
+ {% endif %}"
+ description: "Count of Event 4 to be used with Event 4 filter, if no filter is selected it shows all events"
+ }
+
+ measure: count_of_event_5 {
+ view_label: "Event Funnel"
+ type: sum
+ sql: ${event_5_tag} ;;
+ label: "{% if event_5_filter._in_query %}
+ {{_filters['event_5_filter']}}
+ {% else %}
+ Count of Event 5
+ {% endif %}"
+ description: "Count of Event 5 to be used with Event 5 filter, if no filter is selected it shows all events"
+ }
+
+ measure: count_of_event_6 {
+ view_label: "Event Funnel"
+ type: sum
+ sql: ${event_6_tag} ;;
+ label: "{% if event_6_filter._in_query %}
+ {{_filters['event_6_filter']}}
+ {% else %}
+ Count of Event 6
+ {% endif %}"
+ description: "Count of Event 6 to be used with Event 6 filter, if no filter is selected it shows all events"
+ }
+}
diff --git a/views/event_data_dimensions/event_path.view.lkml b/views/event_data_dimensions/event_path.view.lkml
new file mode 100644
index 0000000..1677fd5
--- /dev/null
+++ b/views/event_data_dimensions/event_path.view.lkml
@@ -0,0 +1,297 @@
+## Purpose: This view is for defining the "Event Path" dimensions, it is extended into events.view
+
+## The default Event Path is comprised of the Event Name and the Page Location URL Path.
+## In the SQL definitions below, the Event Name is called by "event_history.event_name"
+## The Page Location URL Path is called by coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+## It is likely that additional customization of the event path will be required after non-default GA4 Tags are added to your event parameters.
+## Using the [ (select value.value_type from UNNEST(event_params) where key = "GA4_TAG") ] format will facilitate adding these new tags to the event path.
+
+view: event_path {
+ extension: required
+
+ ## Event Path Dimensions
+ dimension: event_path_1 {
+ view_label: "Event Flow"
+ group_label: "Event Path"
+ description: "1st Event in Session."
+ type: string
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = 1 limit 1) ;;
+ #sql: case when ${event_rank} = 1 then ${full_event} else null end ;;
+ full_suggestions: yes
+ }
+ dimension: event_path_2 {
+ view_label: "Event Flow"
+ group_label: "Event Path"
+ description: "2nd Event in Session."
+ type: string
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = 2 limit 1) ;;
+ #sql: case when ${event_rank} = 2 then ${full_event} else null end ;;
+ full_suggestions: yes
+ }
+ dimension: event_path_3 {
+ view_label: "Event Flow"
+ group_label: "Event Path"
+ description: "3rd Event in Session."
+ type: string
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = 3 limit 1) ;;
+ # sql: case when ${event_rank} = 3 then ${full_event} else null end ;;
+ full_suggestions: yes
+ }
+ dimension: event_path_4 {
+ view_label: "Event Flow"
+ group_label: "Event Path"
+ description: "4th Event in Session."
+ type: string
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = 4 limit 1) ;;
+ # sql: case when ${event_rank} = 4 then ${full_event} else null end ;;
+ full_suggestions: yes
+ }
+ dimension: event_path_5 {
+ view_label: "Event Flow"
+ group_label: "Event Path"
+ description: "5th Event in Session."
+ type: string
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = 5 limit 1) ;;
+ # sql: case when ${event_rank} = 5 then ${full_event} else null end ;;
+ full_suggestions: yes
+ }
+ dimension: event_path_6 {
+ view_label: "Event Flow"
+ group_label: "Event Path"
+ description: "6th Event in Session."
+ type: string
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = 6 limit 1) ;;
+ # sql: case when ${event_rank} = 6 then ${full_event} else null end ;;
+ full_suggestions: yes
+ }
+ dimension: event_path_7 {
+ view_label: "Event Flow"
+ group_label: "Event Path"
+ description: "7th Event in Session."
+ type: string
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = 7 limit 1) ;;
+ # sql: case when ${event_rank} = 7 then ${full_event} else null end ;;
+ full_suggestions: yes
+ }
+ dimension: event_path_8 {
+ view_label: "Event Flow"
+ group_label: "Event Path"
+ description: "8th Event in Session."
+ type: string
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = 8 limit 1) ;;
+ # sql: case when ${event_rank} = 8 then ${full_event} else null end ;;
+ full_suggestions: yes
+ }
+ dimension: event_path_9 {
+ view_label: "Event Flow"
+ group_label: "Event Path"
+ description: "9th Event in Session."
+ type: string
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = 9 limit 1) ;;
+ # sql: case when ${event_rank} = 9 then ${full_event} else null end ;;
+ full_suggestions: yes
+ }
+
+ ## Relative full_event Path Dimensions
+ dimension: current_event_plus_1 {
+ view_label: "Event Flow"
+ group_label: "Relative Event Path"
+ description: "Event Path for Event that came directly before current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank + 1) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_event_plus_2 {
+ view_label: "Event Flow"
+ group_label: "Relative Event Path"
+ description: "Event Path for Event that came 2 Events before current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank + 2) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_event_plus_3 {
+ view_label: "Event Flow"
+ group_label: "Relative Event Path"
+ description: "Event Path for Event that came 3 Events before current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank + 3) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_event_plus_4 {
+ view_label: "Event Flow"
+ group_label: "Relative Event Path"
+ description: "Event Path for Event that came 4 Events before current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank + 4) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_event_plus_5 {
+ view_label: "Event Flow"
+ group_label: "Relative Event Path"
+ description: "Event Path for Event that came 5 Events before current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank + 5) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_event_plus_6 {
+ view_label: "Event Flow"
+ group_label: "Relative Event Path"
+ description: "Event Path for Event that came 6 Events before current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank + 6) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_event_plus_7 {
+ view_label: "Event Flow"
+ group_label: "Relative Event Path"
+ description: "Event Path for Event that came 7 Events before current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank + 7) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_event_plus_8 {
+ view_label: "Event Flow"
+ group_label: "Relative Event Path"
+ description: "Event Path for Event that came 8 Events before current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank + 8) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_event_plus_9 {
+ view_label: "Event Flow"
+ group_label: "Relative Event Path"
+ description: "Event Path for Event that came 9 Events before current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank + 9) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+
+ ## Reverse full_event Path Dimensions
+
+ dimension: current_event_minus_1 {
+ view_label: "Event Flow"
+ group_label: "Reverse Event Path"
+ description: "Event Path for Event that came directly after current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank - 1) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_event_minus_2 {
+ view_label: "Event Flow"
+ group_label: "Reverse Event Path"
+ description: "Event Path for Event that came 2 Events after current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank - 2) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_event_minus_3 {
+ view_label: "Event Flow"
+ group_label: "Reverse Event Path"
+ description: "Event Path for Event that came 3 Events after current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank - 3) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_event_minus_4 {
+ view_label: "Event Flow"
+ group_label: "Reverse Event Path"
+ description: "Event Path for Event that came 4 Events after current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank - 4) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_event_minus_5 {
+ view_label: "Event Flow"
+ group_label: "Reverse Event Path"
+ description: "Event Path for Event that came 5 Events after current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank - 5) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_event_minus_6 {
+ view_label: "Event Flow"
+ group_label: "Reverse Event Path"
+ description: "Event Path for Event that came 6 Events after current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank - 6) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_event_minus_7 {
+ view_label: "Event Flow"
+ group_label: "Reverse Event Path"
+ description: "Event Path for Event that came 7 Events after current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank - 7) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_event_minus_8 {
+ view_label: "Event Flow"
+ group_label: "Reverse Event Path"
+ description: "Event Path for Event that came 8 Events after current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank - 8) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_event_minus_9 {
+ view_label: "Event Flow"
+ group_label: "Reverse Event Path"
+ description: "Event Path for Event that came 9 Events after current Event."
+ sql: (select event_history.event_name||': '||coalesce(coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/'),"")
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.event_rank = (${TABLE}.event_rank - 9) limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+}
diff --git a/views/event_data_dimensions/goals.view.lkml b/views/event_data_dimensions/goals.view.lkml
new file mode 100644
index 0000000..66b5aaf
--- /dev/null
+++ b/views/event_data_dimensions/goals.view.lkml
@@ -0,0 +1,137 @@
+# Purpose: To house the fields used to generate Custom Goals. This file is extended into the `event_data` view.
+
+###
+# Adding New Goal Types:
+# To create a new goal type, a new filter will be created. This filter will be used to compare values of an existing dimension.
+# Each filter should correspond to an existing dimension (to be used in place of ${new_dimension_to_be_filtered} in Step 2 below).
+#
+# 1. Add a Filter -
+# filter: new_filter_name {
+# label: "New Filter Label"
+# view_label: "Goals"
+# group_label: "Goal Selection"
+# description: "New Goal Description"
+#
+# 2. Add your new filter to the sql parameter of the dynamic_goal, goal_in_query, and has_completed_goal dimensions -
+# dimension: dynamic_goal {
+# sql: IF( ${has_completed_goal}, CONCAT(
+# IF({{ event_name_goal_selection._in_query }}, CONCAT(${event_name}, " "), "")
+# , IF({{ page_goal_selection._in_query }}, CONCAT("on ", ${event_param_page}), "")
+# ----> , IF({{ new_filter_name._in_query }}, CONCAT(${new_dimension_to_be_filtered}), "")
+# ), null );; }
+#
+# dimension: goal_in_query {
+# sql: {{ event_name_goal_selection._in_query }}
+# OR {{ page_goal_selection._in_query }}
+# ----> OR {{ new_filter_name._in_query }} ;; }
+#
+# dimension: has_completed_goal {
+# sql:if(
+# ${goal_in_query}
+# , {% condition event_name_goal_selection %} ${event_name} {% endcondition %}
+# AND {% condition page_goal_selection %} ${event_param_page} {% endcondition %}
+# ----> AND {% condition new_filter_name %} ${new_dimension_to_be_filtered} {% endcondition %}
+# , false
+# );; }
+#
+# 3. Add the newly created Filter to the Custom Goals Conversion dashboard and apply to all tiles.
+###
+
+view: goals {
+ extension: required
+
+## Filters
+
+ filter: event_name_goal_selection {
+ label: "Event Name"
+ view_label: "Goals"
+ group_label: "Goal Selection"
+ description: "Enter Event Name to be used with Total Conversion measures."
+ suggest_explore: sessions
+ suggest_dimension: events.event_name
+ suggest_persist_for: "0 seconds"
+ type: string
+ }
+
+ filter: page_goal_selection {
+ label: "Page"
+ view_label: "Goals"
+ group_label: "Goal Selection"
+ description: "Enter Page Path to be used with Conversion measures (format should be: '/
'). Should not include Hostname."
+ suggest_explore: sessions
+ suggest_dimension: events.event_param_page
+ type: string
+ }
+
+## Dimensions
+
+ dimension: dynamic_goal {
+ view_label: "Goals"
+ group_label: "Goals"
+ description: "Goal label based on Goal selection filters."
+ type: string
+ sql: IF( ${has_completed_goal}, CONCAT(
+ IF({{ event_name_goal_selection._in_query }}, CONCAT(${event_name}, " "), "")
+ , IF({{ page_goal_selection._in_query }}, CONCAT("on ", ${event_param_page}), "")
+ ), null );;
+ }
+
+ dimension: goal_in_query {
+ description: "Check to verify user has entered a value for at least one goal filter."
+ hidden: yes
+ type: yesno
+ sql: {{ event_name_goal_selection._in_query }}
+ OR {{ page_goal_selection._in_query }};;
+ }
+
+ dimension: has_completed_goal {
+ view_label: "Goals"
+ group_label: "Goals"
+ description: "A session that resulted in a conversion (i.e. resulted in reaching successful point on website defined in 'Goal Selection' field)."
+ type: yesno
+ sql:if(
+ ${goal_in_query}
+ , {% condition event_name_goal_selection %} ${event_name} {% endcondition %}
+ AND {% condition page_goal_selection %} ${event_param_page} {% endcondition %}
+ , false
+ );;
+ }
+
+## Measures
+ measure: conversion_count {
+ view_label: "Goals"
+ group_label: "Goal Conversions"
+ label: "Total Conversions"
+ description: "Total number of hits (Page or Event) that are identified as converisons based on 'Goal Selection' filters."
+ type: count_distinct
+ allow_approximate_optimization: yes
+ sql: ${ed_key} ;;
+ filters: [has_completed_goal: "yes"]
+ value_format_name: formatted_number
+ drill_fields: []
+ }
+
+ measure: sessions_with_conversions {
+ view_label: "Goals"
+ group_label: "Goal Conversions"
+ label: "Sessions with Conversion"
+ description: "Sessions that result in a conversion based on 'Goal Selection' filters."
+ type: count_distinct
+ allow_approximate_optimization: yes
+ sql: ${sessions.sl_key} ;;
+ filters: [has_completed_goal: "yes"]
+ value_format_name: formatted_number
+ drill_fields: [client_id, visit_number, sessions_with_conversions]
+ }
+
+ measure: session_conversion_rate {
+ view_label: "Goals"
+ group_label: "Goal Conversions"
+ label: "Session Conversion Rate"
+ description: "Percentage of sessions resulting in a conversion based on 'Goal Selection' filters."
+ type: number
+ sql: (1.0*${sessions_with_conversions})/NULLIF(${sessions.total_sessions}, 0) ;;
+ value_format_name: percent_1
+ drill_fields: []
+ }
+}
diff --git a/views/event_data_dimensions/items_data.view.lkml b/views/event_data_dimensions/items_data.view.lkml
new file mode 100644
index 0000000..2750329
--- /dev/null
+++ b/views/event_data_dimensions/items_data.view.lkml
@@ -0,0 +1,187 @@
+## Purpose: This view is for defining the 'event_data' 'Item' specific fields. This view unnested from event_data in the 'sessions' explore.
+
+view: event_data_items {
+
+## Dimensions
+ dimension: affiliation {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.affiliation ;;
+ full_suggestions: yes
+ }
+
+ dimension: coupon {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.coupon ;;
+ full_suggestions: yes
+ }
+
+ dimension: creative_name {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.creative_name ;;
+ full_suggestions: yes
+ }
+
+ dimension: creative_slot {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.creative_slot ;;
+ full_suggestions: yes
+ }
+
+ dimension: item_brand {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.item_brand ;;
+ full_suggestions: yes
+ }
+
+ dimension: item_category {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.item_category ;;
+ full_suggestions: yes
+ }
+
+ dimension: item_category2 {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.item_category2 ;;
+ full_suggestions: yes
+ }
+
+ dimension: item_category3 {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.item_category3 ;;
+ full_suggestions: yes
+ }
+
+ dimension: item_category4 {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.item_category4 ;;
+ full_suggestions: yes
+ }
+
+ dimension: item_category5 {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.item_category5 ;;
+ full_suggestions: yes
+ }
+
+ dimension: item_id {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.item_id ;;
+ full_suggestions: yes
+ }
+
+ dimension: item_list_id {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.item_list_id ;;
+ full_suggestions: yes
+ }
+
+ dimension: item_list_index {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.item_list_index ;;
+ full_suggestions: yes
+ }
+
+ dimension: item_list_name {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.item_list_name ;;
+ full_suggestions: yes
+ }
+
+ dimension: item_name {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.item_name ;;
+ full_suggestions: yes
+ }
+
+ dimension: item_refund {
+ group_label: "Items"
+ type: number
+ sql: ${TABLE}.item_refund ;;
+ full_suggestions: yes
+ }
+
+ dimension: item_refund_in_usd {
+ group_label: "Items"
+ type: number
+ sql: ${TABLE}.item_refund_in_usd ;;
+ full_suggestions: yes
+ }
+
+ dimension: item_revenue {
+ group_label: "Items"
+ type: number
+ sql: ${TABLE}.item_revenue ;;
+ full_suggestions: yes
+ }
+
+ dimension: item_revenue_in_usd {
+ group_label: "Items"
+ type: number
+ sql: ${TABLE}.item_revenue_in_usd ;;
+ full_suggestions: yes
+ }
+
+ dimension: item_variant {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.item_variant ;;
+ full_suggestions: yes
+ }
+
+ dimension: location_id {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.location_id ;;
+ full_suggestions: yes
+ }
+
+ dimension: price {
+ group_label: "Items"
+ type: number
+ sql: ${TABLE}.price ;;
+ full_suggestions: yes
+ }
+
+ dimension: price_in_usd {
+ group_label: "Items"
+ type: number
+ sql: ${TABLE}.price_in_usd ;;
+ full_suggestions: yes
+ }
+
+ dimension: promotion_id {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.promotion_id ;;
+ full_suggestions: yes
+ }
+
+ dimension: promotion_name {
+ group_label: "Items"
+ type: string
+ sql: ${TABLE}.promotion_name ;;
+ full_suggestions: yes
+ }
+
+ dimension: quantity {
+ group_label: "Items"
+ type: number
+ sql: ${TABLE}.quantity ;;
+ full_suggestions: yes
+ }
+}
diff --git a/views/event_data_dimensions/page_data.view.lkml b/views/event_data_dimensions/page_data.view.lkml
new file mode 100644
index 0000000..207f735
--- /dev/null
+++ b/views/event_data_dimensions/page_data.view.lkml
@@ -0,0 +1,442 @@
+## Purpose: This view is for defining the 'page_view' specific fields. This view is extended into 'event_data'.
+
+view: page_data {
+ extension: required
+
+ dimension: page_view_rank {
+ view_label: "Page Flow"
+ group_label: "Page Path"
+ label: "Page View Rank"
+ description: "Rank of 'Page View' Event, 1 = First Event"
+ type: number
+ sql: ${TABLE}.page_view_rank ;;
+ }
+
+ dimension: page_view_reverse_rank {
+ view_label: "Page Flow"
+ group_label: "Page Path"
+ label: "Page View Reverse Rank"
+ description: "Reverse Rank of 'Page View' Event, 1 = Last Event"
+ type: number
+ sql: ${TABLE}.page_view_reverse_rank ;;
+ }
+
+ dimension: time_to_next_page {
+ view_label: "Behavior"
+ group_label: "Time on Page"
+ label: "Time on Page"
+ description: "Time user spent on page. Single page_view Sessions have 0 Duration."
+ type: number
+ sql: ${TABLE}.time_to_next_page ;;
+ value_format_name: hour_format
+ }
+
+ dimension: is_landing_page {
+ view_label: "Behavior"
+ group_label: "Page Filters"
+ description: "Use to filter for first pageview of a session. Use with Page dimensions."
+ type: yesno
+ sql: ${page_view_rank} = 1 ;;
+ full_suggestions: yes
+ }
+
+ dimension: is_exit_page {
+ view_label: "Behavior"
+ group_label: "Page Filters"
+ description: "If this hit was the last pageview or screenview hit of a session, this is set to true."
+ type: yesno
+ sql: ${page_view_reverse_rank} = 1 ;;
+ full_suggestions: yes
+ }
+
+ dimension: is_bounce {
+ view_label: "Behavior"
+ group_label: "Page Filters"
+ label: "Is Bounce?"
+ description: "If this hit was the last pageview or screenview hit of a session, this is set to true."
+ type: yesno
+ sql: ${sessions.session_data_page_view_count} = 1 ;;
+ full_suggestions: yes
+ }
+
+ ## Page Path Dimensions
+ dimension: page_path_1 {
+ view_label: "Page Flow"
+ group_label: "Page Path"
+ description: "1st Page in Session."
+ type: string
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = 1
+ and event_history.event_name = "page_view" limit 1) ;;
+ # sql: case when ${page_view_rank} = 1 then ${event_param_page} else null end ;;
+ full_suggestions: yes
+ }
+ dimension: page_path_2 {
+ view_label: "Page Flow"
+ group_label: "Page Path"
+ description: "2nd Page in Session."
+ type: string
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = 2
+ and event_history.event_name = "page_view" limit 1) ;;
+ # sql: case when ${page_view_rank} = 2 then ${event_param_page} else null end ;;
+ full_suggestions: yes
+ }
+ dimension: page_path_3 {
+ view_label: "Page Flow"
+ group_label: "Page Path"
+ description: "3rd Page in Session."
+ type: string
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = 3
+ and event_history.event_name = "page_view" limit 1) ;;
+ # sql: case when ${page_view_rank} = 3 then ${event_param_page} else null end ;;
+ full_suggestions: yes
+ }
+ dimension: page_path_4 {
+ view_label: "Page Flow"
+ group_label: "Page Path"
+ description: "4th Page in Session."
+ type: string
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = 4
+ and event_history.event_name = "page_view" limit 1) ;;
+ # sql: case when ${page_view_rank} = 4 then ${event_param_page} else null end ;;
+ full_suggestions: yes
+ }
+ dimension: page_path_5 {
+ view_label: "Page Flow"
+ group_label: "Page Path"
+ description: "5th Page in Session."
+ type: string
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = 5
+ and event_history.event_name = "page_view" limit 1) ;;
+ # sql: case when ${page_view_rank} = 5 then ${event_param_page} else null end ;;
+ full_suggestions: yes
+ }
+ dimension: page_path_6 {
+ view_label: "Page Flow"
+ group_label: "Page Path"
+ description: "6th Page in Session."
+ type: string
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = 6
+ and event_history.event_name = "page_view" limit 1) ;;
+ # sql: case when ${page_view_rank} = 6 then ${event_param_page} else null end ;;
+ full_suggestions: yes
+ }
+ dimension: page_path_7 {
+ view_label: "Page Flow"
+ group_label: "Page Path"
+ description: "4th Page in Session."
+ type: string
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = 7
+ and event_history.event_name = "page_view" limit 1) ;;
+ # sql: case when ${page_view_rank} = 7 then ${event_param_page} else null end ;;
+ full_suggestions: yes
+ }
+ dimension: page_path_8 {
+ view_label: "Page Flow"
+ group_label: "Page Path"
+ description: "5th Page in Session."
+ type: string
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = 8
+ and event_history.event_name = "page_view" limit 1) ;;
+ # sql: case when ${page_view_rank} = 8 then ${event_param_page} else null end ;;
+ full_suggestions: yes
+ }
+ dimension: page_path_9 {
+ view_label: "Page Flow"
+ group_label: "Page Path"
+ description: "6th Page in Session."
+ type: string
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = 9
+ and event_history.event_name = "page_view" limit 1) ;;
+ # sql: case when ${page_view_rank} = 9 then ${event_param_page} else null end ;;
+ full_suggestions: yes
+ }
+
+ ## Relative Page Path Dimensions
+ dimension: current_page_plus_1 {
+ view_label: "Page Flow"
+ group_label: "Relative Page Path"
+ description: "Page Path for page that came directly before current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank + 1)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_page_plus_2 {
+ view_label: "Page Flow"
+ group_label: "Relative Page Path"
+ description: "Page Path for page that came 2 pages before current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank + 2)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_page_plus_3 {
+ view_label: "Page Flow"
+ group_label: "Relative Page Path"
+ description: "Page Path for page that came 3 pages before current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank + 3)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_page_plus_4 {
+ view_label: "Page Flow"
+ group_label: "Relative Page Path"
+ description: "Page Path for page that came 4 pages before current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank + 4)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_page_plus_5 {
+ view_label: "Page Flow"
+ group_label: "Relative Page Path"
+ description: "Page Path for page that came 5 pages before current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank + 5)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_page_plus_6 {
+ view_label: "Page Flow"
+ group_label: "Relative Page Path"
+ description: "Page Path for page that came 6 pages before current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank + 6)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_page_plus_7 {
+ view_label: "Page Flow"
+ group_label: "Relative Page Path"
+ description: "Page Path for page that came 7 pages before current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank + 7)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_page_plus_8 {
+ view_label: "Page Flow"
+ group_label: "Relative Page Path"
+ description: "Page Path for page that came 8 pages before current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank + 8)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_page_plus_9 {
+ view_label: "Page Flow"
+ group_label: "Relative Page Path"
+ description: "Page Path for page that came 9 pages before current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank + 9)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+
+ ## Reverse Page Path Dimensions
+ dimension: current_page_minus_1 {
+ view_label: "Page Flow"
+ group_label: "Reverse Page Path"
+ description: "Page Path for page that came directly after current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank - 1)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_page_minus_2 {
+ view_label: "Page Flow"
+ group_label: "Reverse Page Path"
+ description: "Page Path for page that came 2 pages after current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank - 2)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_page_minus_3 {
+ view_label: "Page Flow"
+ group_label: "Reverse Page Path"
+ description: "Page Path for page that came 3 pages after current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank - 3)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_page_minus_4 {
+ view_label: "Page Flow"
+ group_label: "Reverse Page Path"
+ description: "Page Path for page that came 4 pages after current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank - 4)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_page_minus_5 {
+ view_label: "Page Flow"
+ group_label: "Reverse Page Path"
+ description: "Page Path for page that came 5 pages after current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank - 5)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_page_minus_6 {
+ view_label: "Page Flow"
+ group_label: "Reverse Page Path"
+ description: "Page Path for page that came 6 pages after current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank - 6)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_page_minus_7 {
+ view_label: "Page Flow"
+ group_label: "Reverse Page Path"
+ description: "Page Path for page that came 7 pages after current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank - 7)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_page_minus_8 {
+ view_label: "Page Flow"
+ group_label: "Reverse Page Path"
+ description: "Page Path for page that came 8 pages after current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank - 8)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+ dimension: current_page_minus_9 {
+ view_label: "Page Flow"
+ group_label: "Reverse Page Path"
+ description: "Page Path for page that came 9 pages after current page."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_history.event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(${sessions.event_data}) as event_history
+ where event_history.page_view_rank = (${TABLE}.page_view_rank - 9)
+ and event_history.event_name = "page_view" limit 1) ;;
+ full_suggestions: yes
+ type: string
+ }
+
+
+ ## Measures
+ measure: total_entrances {
+ view_label: "Behavior"
+ group_label: "Pages"
+ label: "Entrances"
+ description: "The number of entrances to the property measured as the first pageview in a session, typically used with Landing Page."
+ type: count_distinct
+ filters: [is_landing_page: "yes"]
+ sql: ${ed_key} ;;
+ value_format_name: formatted_number
+ }
+ measure: entrance_rate {
+ view_label: "Behavior"
+ group_label: "Pages"
+ label: "Entrance Rate"
+ description:"The percentage of 'Page View' events in which this page was the entrance."
+ type: number
+ sql: ${total_entrances}/nullif(${total_page_views},0) ;;
+ value_format_name: percent_2
+ }
+ measure: total_bounce {
+ view_label: "Behavior"
+ group_label: "Pages"
+ label: "Bounces"
+ type: count_distinct
+ sql: ${sl_key} ;;
+ filters: [is_bounce: "yes", event_name: "page_view"]
+ value_format_name: formatted_number
+ }
+ measure: bounce_rate {
+ view_label: "Behavior"
+ group_label: "Pages"
+ label: "Bounce Rate"
+ type: number
+ sql: ${total_bounce}/nullif(${total_page_views},0) ;;
+ value_format_name: percent_2
+ }
+ measure: total_exits {
+ view_label: "Behavior"
+ group_label: "Pages"
+ label: "Exits"
+ description: "The number of exits from the property."
+ type: count_distinct
+ filters: [is_exit_page: "yes"]
+ sql: ${ed_key} ;;
+ value_format_name: formatted_number
+ }
+ measure: exit_rate {
+ view_label: "Behavior"
+ group_label: "Pages"
+ label: "Exit Rate"
+ description: "Exit is (number of exits) / (number of pageviews) for the page or set of pages. It indicates how often users exit from that page or set of pages when they view the page(s)."
+ type: number
+ sql: ${total_exits}/nullif(${total_page_views},0) ;;
+ value_format_name: percent_2
+ }
+ measure: average_time_to_next_page {
+ view_label: "Behavior"
+ group_label: "Pages"
+ label: "Average Time on Page"
+ description: "Avg time a user spent on a specific page. Note that Single Page_View Sessions are excluded from this measure."
+ type: average
+ sql: coalesce(${time_to_next_page},0) ;;
+ filters: [time_to_next_page: ">0"] ## Filtering out 0 Duration Page View Events, which occurs when a session only has one page_view.
+ value_format_name: hour_format
+ }
+
+}
diff --git a/views/event_data_dimensions/page_funnel.view.lkml b/views/event_data_dimensions/page_funnel.view.lkml
new file mode 100644
index 0000000..eefa11c
--- /dev/null
+++ b/views/event_data_dimensions/page_funnel.view.lkml
@@ -0,0 +1,226 @@
+view: page_funnel {
+extension: required
+
+## Filters
+ filter: page_1_filter {
+ view_label: "Page Funnel"
+ group_label: "Funnel Pages"
+ suggest_explore: sessions
+ suggest_dimension: events.event_param_page
+ description: "Page 1 Filter, to be used with Count of Page 1"
+ }
+
+ filter: page_2_filter {
+ view_label: "Page Funnel"
+ group_label: "Funnel Pages"
+ suggest_explore: sessions
+ suggest_dimension: events.event_param_page
+ description: "Page 2 Filter, to be used with Count of Page 2"
+ }
+
+ filter: page_3_filter {
+ view_label: "Page Funnel"
+ group_label: "Funnel Pages"
+ suggest_explore: sessions
+ suggest_dimension: events.event_param_page
+ description: "Page 3 Filter, to be used with Count of Page 3"
+ }
+
+ filter: page_4_filter {
+ view_label: "Page Funnel"
+ group_label: "Funnel Pages"
+ suggest_explore: sessions
+ suggest_dimension: events.event_param_page
+ description: "Page 4 Filter, to be used with Count of Page 4"
+ }
+
+ filter: page_5_filter {
+ view_label: "Page Funnel"
+ group_label: "Funnel Pages"
+ suggest_explore: sessions
+ suggest_dimension: events.event_param_page
+ description: "Page 5 Filter, to be used with Count of Page 5"
+ }
+
+ filter: page_6_filter {
+ view_label: "Page Funnel"
+ group_label: "Funnel Pages"
+ suggest_explore: sessions
+ suggest_dimension: events.event_param_page
+ description: "Page 6 Filter, to be used with Count of Page 6"
+ }
+
+## Dimensions
+ dimension: sl_key {
+ type: string
+ sql: ${TABLE}.sl_key ;;
+ hidden: yes
+ primary_key: yes
+ }
+ dimension: page_1 {
+ type: string
+ hidden: yes
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/') from UNNEST(${sessions.event_data}) where page_view_rank = 1) ;;
+ }
+ dimension: page_2 {
+ type: string
+ hidden: yes
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/') from UNNEST(${sessions.event_data}) where page_view_rank = 2) ;;
+ }
+ dimension: page_3 {
+ type: string
+ hidden: yes
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/') from UNNEST(${sessions.event_data}) where page_view_rank = 3) ;;
+ }
+ dimension: page_4 {
+ type: string
+ hidden: yes
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/') from UNNEST(${sessions.event_data}) where page_view_rank = 4) ;;
+ }
+ dimension: page_5 {
+ type: string
+ hidden: yes
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/') from UNNEST(${sessions.event_data}) where page_view_rank = 5) ;;
+ }
+ dimension: page_6 {
+ type: string
+ hidden: yes
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?#]+)"),'/') from UNNEST(${sessions.event_data}) where page_view_rank = 6) ;;
+ }
+
+ dimension: page_1_tag {
+ type: number
+ hidden: yes
+ sql: case when {% condition page_1_filter %} ${page_1} {% endcondition %} and ${page_1} is not null then 1 else 0 end ;;
+ }
+ dimension: page_2_tag {
+ type: number
+ hidden: yes
+ sql: case when {% condition page_1_filter %} ${page_1} {% endcondition %}
+ and {% condition page_2_filter %} ${page_2} {% endcondition %}
+ and ${page_2} is not null then 1 else 0 end ;;
+ }
+ dimension: page_3_tag {
+ type: number
+ hidden: yes
+ sql: case when {% condition page_1_filter %} ${page_1} {% endcondition %}
+ and {% condition page_2_filter %} ${page_2} {% endcondition %}
+ and {% condition page_3_filter %} ${page_3} {% endcondition %}
+ and ${page_2} is not null
+ and ${page_3} is not null then 1 else 0 end ;;
+ }
+ dimension: page_4_tag {
+ type: number
+ hidden: yes
+ sql: case when {% condition page_1_filter %} ${page_1} {% endcondition %}
+ and {% condition page_2_filter %} ${page_2} {% endcondition %}
+ and {% condition page_3_filter %} ${page_3} {% endcondition %}
+ and {% condition page_4_filter %} ${page_4} {% endcondition %}
+ and ${page_2} is not null
+ and ${page_3} is not null
+ and ${page_4} is not null then 1 else 0 end ;;
+ }
+ dimension: page_5_tag {
+ type: number
+ hidden: yes
+ sql: case when {% condition page_1_filter %} ${page_1} {% endcondition %}
+ and {% condition page_2_filter %} ${page_2} {% endcondition %}
+ and {% condition page_3_filter %} ${page_3} {% endcondition %}
+ and {% condition page_4_filter %} ${page_4} {% endcondition %}
+ and {% condition page_5_filter %} ${page_5} {% endcondition %}
+ and ${page_2} is not null
+ and ${page_3} is not null
+ and ${page_4} is not null
+ and ${page_5} is not null then 1 else 0 end ;;
+ }
+ dimension: page_6_tag {
+ type: number
+ hidden: yes
+ sql: case when {% condition page_1_filter %} ${page_1} {% endcondition %}
+ and {% condition page_2_filter %} ${page_2} {% endcondition %}
+ and {% condition page_3_filter %} ${page_3} {% endcondition %}
+ and {% condition page_4_filter %} ${page_4} {% endcondition %}
+ and {% condition page_5_filter %} ${page_5} {% endcondition %}
+ and {% condition page_6_filter %} ${page_6} {% endcondition %}
+ and ${page_2} is not null
+ and ${page_3} is not null
+ and ${page_4} is not null
+ and ${page_5} is not null
+ and ${page_6} is not null then 1 else 0 end ;;
+ }
+
+## Measures
+
+ measure: count_of_page_1 {
+ view_label: "Page Funnel"
+ type: sum
+ sql: ${page_1_tag} ;;
+ label: "{% if page_1_filter._in_query %}
+ {{_filters['page_1_filter']}}
+ {% else %}
+ Count of Page 1
+ {% endif %}"
+ description: "Count of Page 1 to be used with Page 1 filter, if no filter is selected it shows all Pages"
+ }
+
+ measure: count_of_page_2 {
+ view_label: "Page Funnel"
+ type: sum
+ sql: ${page_2_tag} ;;
+ label: "{% if page_2_filter._in_query %}
+ {{_filters['page_2_filter']}}
+ {% else %}
+ Count of Page 2
+ {% endif %}"
+ description: "Count of Page 2 to be used with Page 2 filter, if no filter is selected it shows all Pages"
+ }
+
+ measure: count_of_page_3 {
+ view_label: "Page Funnel"
+ type: sum
+ sql: ${page_3_tag} ;;
+ label: "{% if page_3_filter._in_query %}
+ {{_filters['page_3_filter']}}
+ {% else %}
+ Count of Page 3
+ {% endif %}"
+ description: "Count of Page 3 to be used with Page 3 filter, if no filter is selected it shows all Pages"
+ }
+
+ measure: count_of_page_4 {
+ view_label: "Page Funnel"
+ type: sum
+ sql: ${page_4_tag} ;;
+ label: "{% if page_4_filter._in_query %}
+ {{_filters['page_4_filter']}}
+ {% else %}
+ Count of Page 4
+ {% endif %}"
+ description: "Count of Page 4 to be used with Page 4 filter, if no filter is selected it shows all Pages"
+ }
+
+ measure: count_of_page_5 {
+ view_label: "Page Funnel"
+ type: sum
+ sql: ${page_5_tag} ;;
+ label: "{% if page_5_filter._in_query %}
+ {{_filters['page_5_filter']}}
+ {% else %}
+ Count of Page 5
+ {% endif %}"
+ description: "Count of Page 5 to be used with Page 5 filter, if no filter is selected it shows all Pages"
+ }
+
+ measure: count_of_page_6 {
+ view_label: "Page Funnel"
+ type: sum
+ sql: ${page_6_tag} ;;
+ label: "{% if page_6_filter._in_query %}
+ {{_filters['page_6_filter']}}
+ {% else %}
+ Count of Page 6
+ {% endif %}"
+ description: "Count of Page 6 to be used with Page 6 filter, if no filter is selected it shows all Pages"
+ }
+
+}
diff --git a/views/events.view.lkml b/views/events.view.lkml
new file mode 100644
index 0000000..8afd754
--- /dev/null
+++ b/views/events.view.lkml
@@ -0,0 +1,721 @@
+## PURPOSE: This view is for a convenient location to define dimensions and measures sourced from the event_data element in sessions.
+## Event_Data represents the source event level rows from the GA Export Dataset.
+## The following views are defined in this file:
+## - event_data
+## - event_data_event_params
+## - event_data_user_properties
+## - goals
+## - page_data
+## - 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]
+
+## Dimensions
+
+ dimension: ed_key {
+ type: string
+ primary_key: yes
+ hidden: yes
+ sql: ${sl_key}||${event_rank} ;;
+ }
+
+ dimension: sl_key {
+ type: string
+ hidden: yes
+ sql: ${TABLE}.sl_key ;;
+ }
+
+ dimension: event_rank {
+ label: "Event Rank"
+ type: number
+ sql: ${TABLE}.event_rank ;;
+ description: "Event Rank in Session, 1st Event = Event Rank 1."
+ full_suggestions: yes
+ }
+
+ dimension: reverse_event_rank {
+ label: "Reverse Event Rank"
+ type: number
+ sql: ${TABLE}.reverse_event_rank ;;
+ description: "Reverse Event Rank in Session. Last Event = Reverse Event Rank 1."
+ full_suggestions: yes
+ }
+
+ # dimension_group: event {
+ # label: "Event"
+ # type: time
+ # timeframes: [date,day_of_month,day_of_week,day_of_week_index,day_of_year,month,month_name,month_num,fiscal_quarter,fiscal_quarter_of_year,year]
+ # sql: ${TABLE}.event_date ;;
+ # }
+
+ dimension_group: event_time {
+ type: time
+ timeframes: [date,day_of_month,day_of_week,day_of_week_index,day_of_year,month,month_name,month_num,fiscal_quarter,fiscal_quarter_of_year,year,time,hour,hour_of_day,minute,second]
+ label: "Event"
+ sql: TIMESTAMP_MICROS(${TABLE}.event_timestamp) ;;
+ description: "Event Date/Time from Event Timestamp."
+ }
+ parameter: event_time_window {
+ allowed_value: {
+ label: "Hourly window"
+ value: "hour"
+ }
+ allowed_value: {
+ label: "Minute window"
+ value: "minute"
+ }
+ default_value: "Daily"
+ }
+
+ dimension: event_timestamp { hidden: yes sql: ${TABLE}.event_timestamp ;; }
+
+ dimension: time_to_next_event {
+ label: "Time on Event"
+ description: "Time user spent on Event, measured as duration from event to the subsequent event."
+ sql: ${TABLE}.time_to_next_event ;;
+ type: number
+ value_format_name: hour_format
+ }
+
+ dimension: event_name {
+ label: "Event Name"
+ type: string
+ sql: ${TABLE}.event_name ;;
+ full_suggestions: yes
+ }
+
+ dimension: full_event {
+ view_label: "Behavior"
+ ## Customize with your specific event parameters that encompass the specific points of interest in your event.
+ type: string
+ sql: ${event_name}||': '||coalesce(${events.event_param_page},"") ;;
+ full_suggestions: yes
+ }
+
+ dimension: event_bundle_sequence_id {
+ type: number
+ sql: ${TABLE}.event_bundle_sequence_id ;;
+ full_suggestions: yes
+ }
+
+ dimension: event_dimensions__hostname {
+ type: string
+ sql: ${TABLE}.event_dimensions.hostname ;;
+ group_label: "Event Dimensions"
+ group_item_label: "Hostname"
+ full_suggestions: yes
+ }
+
+ dimension: event_previous_timestamp {
+ type: number
+ sql: ${TABLE}.event_previous_timestamp ;;
+ full_suggestions: yes
+ }
+
+ dimension: event_server_timestamp_offset {
+ type: number
+ sql: ${TABLE}.event_server_timestamp_offset ;;
+ full_suggestions: yes
+ }
+
+ dimension: event_value_in_usd {
+ type: number
+ sql: ${TABLE}.event_value_in_usd ;;
+ full_suggestions: yes
+ }
+
+ dimension: items {
+ hidden: yes
+ sql: ${TABLE}.items ;;
+ ## This is the parent dimension for the items fields within the event_data_items view.
+ }
+
+ dimension: platform {
+ type: string
+ sql: ${TABLE}.platform ;;
+ full_suggestions: yes
+ }
+ dimension: stream_id {
+ type: string
+ sql: ${TABLE}.stream_id ;;
+ full_suggestions: yes
+ }
+
+ ## App Info Fields
+ dimension: app_info__firebase_app_id {
+ type: string
+ sql: ${TABLE}.app_info.firebase_app_id ;;
+ full_suggestions: yes
+ group_label: "App Info"
+ group_item_label: "Firebase App ID"
+ }
+
+ dimension: app_info__id {
+ type: string
+ sql: ${TABLE}.app_info.id ;;
+ full_suggestions: yes
+ group_label: "App Info"
+ group_item_label: "ID"
+ }
+
+ dimension: app_info__install_source {
+ type: string
+ sql: ${TABLE}.app_info.install_source ;;
+ full_suggestions: yes
+ group_label: "App Info"
+ group_item_label: "Install Source"
+ }
+
+ dimension: app_info__install_store {
+ type: string
+ sql: ${TABLE}.app_info.install_store ;;
+ full_suggestions: yes
+ group_label: "App Info"
+ group_item_label: "Install Store"
+ }
+
+ dimension: app_info__version {
+ type: string
+ sql: ${TABLE}.app_info.version ;;
+ full_suggestions: yes
+ group_label: "App Info"
+ group_item_label: "Version"
+ }
+
+
+ ## Device Fields
+ dimension: device__advertising_id {
+ type: string
+ sql: ${TABLE}.device.advertising_id ;;
+ full_suggestions: yes
+ group_label: "Device"
+ group_item_label: "Advertising ID"
+ }
+
+ dimension: device__browser {
+ type: string
+ sql: ${TABLE}.device.browser ;;
+ full_suggestions: yes
+ group_label: "Device"
+ group_item_label: "Browser"
+ }
+
+ dimension: device__browser_version {
+ type: string
+ sql: ${TABLE}.device.browser_version ;;
+ full_suggestions: yes
+ group_label: "Device"
+ group_item_label: "Browser Version"
+ }
+
+ dimension: device__category {
+ type: string
+ sql: ${TABLE}.device.category ;;
+ full_suggestions: yes
+ group_label: "Device"
+ group_item_label: "Category"
+ }
+
+ dimension: device__is_limited_ad_tracking {
+ type: string
+ sql: ${TABLE}.device.is_limited_ad_tracking ;;
+ full_suggestions: yes
+ group_label: "Device"
+ group_item_label: "Is Limited Ad Tracking"
+ }
+
+ dimension: device__language {
+ type: string
+ sql: ${TABLE}.device.language ;;
+ full_suggestions: yes
+ group_label: "Device"
+ group_item_label: "Language"
+ }
+
+ dimension: device__mobile_brand_name {
+ type: string
+ sql: ${TABLE}.device.mobile_brand_name ;;
+ full_suggestions: yes
+ group_label: "Device"
+ group_item_label: "Mobile Brand Name"
+ }
+
+ dimension: device__mobile_marketing_name {
+ type: string
+ sql: ${TABLE}.device.mobile_marketing_name ;;
+ full_suggestions: yes
+ group_label: "Device"
+ group_item_label: "Mobile Marketing Name"
+ }
+
+ dimension: device__mobile_model_name {
+ type: string
+ sql: ${TABLE}.device.mobile_model_name ;;
+ full_suggestions: yes
+ group_label: "Device"
+ group_item_label: "Mobile Model Name"
+ }
+
+ dimension: device__mobile_os_hardware_model {
+ type: string
+ sql: ${TABLE}.device.mobile_os_hardware_model ;;
+ full_suggestions: yes
+ group_label: "Device"
+ group_item_label: "Mobile OS Hardware Model"
+ }
+
+ dimension: device__operating_system {
+ type: string
+ sql: ${TABLE}.device.operating_system ;;
+ full_suggestions: yes
+ group_label: "Device"
+ group_item_label: "Operating System"
+ }
+
+ dimension: device__operating_system_version {
+ type: string
+ sql: ${TABLE}.device.operating_system_version ;;
+ full_suggestions: yes
+ group_label: "Device"
+ group_item_label: "Operating System Version"
+ }
+
+ dimension: device__time_zone_offset_seconds {
+ type: number
+ sql: ${TABLE}.device.time_zone_offset_seconds ;;
+ group_label: "Device"
+ group_item_label: "Time Zone Offset Seconds"
+ }
+
+ dimension: device__vendor_id {
+ type: string
+ sql: ${TABLE}.device.vendor_id ;;
+ full_suggestions: yes
+ group_label: "Device"
+ group_item_label: "Vendor ID"
+ }
+
+ dimension: device__web_info__browser {
+ type: string
+ sql: ${TABLE}.device.web_info.browser ;;
+ full_suggestions: yes
+ group_label: "Device Web Info"
+ group_item_label: "Browser"
+ }
+
+ dimension: device__web_info__browser_version {
+ type: string
+ sql: ${TABLE}.device.web_info.browser_version ;;
+ full_suggestions: yes
+ group_label: "Device Web Info"
+ group_item_label: "Browser Version"
+ }
+
+ dimension: device__web_info__hostname {
+ type: string
+ sql: ${TABLE}.device.web_info.hostname ;;
+ full_suggestions: yes
+ group_label: "Device Web Info"
+ group_item_label: "Hostname"
+ }
+
+
+ ## ECommerce Fields
+ dimension: ecommerce__purchase_revenue {
+ type: number
+ sql: ${TABLE}.ecommerce.purchase_revenue ;;
+ group_label: "Ecommerce"
+ group_item_label: "Purchase Revenue"
+ value_format_name: usd
+ }
+
+ dimension: ecommerce__purchase_revenue_in_usd {
+ type: number
+ sql: ${TABLE}.ecommerce.purchase_revenue_in_usd ;;
+ group_label: "Ecommerce"
+ group_item_label: "Purchase Revenue In USD"
+ value_format_name: usd
+ }
+
+ dimension: ecommerce__refund_value {
+ type: number
+ sql: ${TABLE}.ecommerce.refund_value ;;
+ group_label: "Ecommerce"
+ group_item_label: "Refund Value"
+ value_format_name: usd
+ }
+
+ dimension: ecommerce__refund_value_in_usd {
+ type: number
+ sql: ${TABLE}.ecommerce.refund_value_in_usd ;;
+ group_label: "Ecommerce"
+ group_item_label: "Refund Value In USD"
+ value_format_name: usd
+ }
+
+ dimension: ecommerce__shipping_value {
+ type: number
+ sql: ${TABLE}.ecommerce.shipping_value ;;
+ group_label: "Ecommerce"
+ group_item_label: "Shipping Value"
+ value_format_name: usd
+ }
+
+ dimension: ecommerce__shipping_value_in_usd {
+ type: number
+ sql: ${TABLE}.ecommerce.shipping_value_in_usd ;;
+ group_label: "Ecommerce"
+ group_item_label: "Shipping Value In USD"
+ value_format_name: usd
+ }
+
+ dimension: ecommerce__tax_value {
+ type: number
+ sql: ${TABLE}.ecommerce.tax_value ;;
+ group_label: "Ecommerce"
+ group_item_label: "Tax Value"
+ value_format_name: usd
+ }
+
+ dimension: ecommerce__tax_value_in_usd {
+ type: number
+ sql: ${TABLE}.ecommerce.tax_value_in_usd ;;
+ group_label: "Ecommerce"
+ group_item_label: "Tax Value In USD"
+ value_format_name: usd
+ }
+
+ dimension: ecommerce__total_item_quantity {
+ type: number
+ sql: ${TABLE}.ecommerce.total_item_quantity ;;
+ group_label: "Ecommerce"
+ group_item_label: "Total Item Quantity"
+ value_format_name: decimal_0
+ }
+
+ dimension: ecommerce__transaction_id {
+ type: string
+ sql: ${TABLE}.ecommerce.transaction_id ;;
+ full_suggestions: yes
+ group_label: "Ecommerce"
+ group_item_label: "Transaction ID"
+ }
+
+ dimension: ecommerce__unique_items {
+ type: number
+ sql: ${TABLE}.ecommerce.unique_items ;;
+ group_label: "Ecommerce"
+ group_item_label: "Unique Items"
+ value_format_name: decimal_0
+ }
+
+
+ ## Geo Fields
+ dimension: geo__city {
+ type: string
+ sql: ${TABLE}.geo.city ;;
+ full_suggestions: yes
+ group_label: "Geo"
+ group_item_label: "City"
+ }
+
+ dimension: geo__continent {
+ type: string
+ sql: ${TABLE}.geo.continent ;;
+ full_suggestions: yes
+ group_label: "Geo"
+ group_item_label: "Continent"
+ }
+
+ dimension: geo__country {
+ type: string
+ sql: ${TABLE}.geo.country ;;
+ full_suggestions: yes
+ group_label: "Geo"
+ group_item_label: "Country"
+ map_layer_name: countries
+ }
+
+ dimension: geo__metro {
+ type: string
+ sql: ${TABLE}.geo.metro ;;
+ full_suggestions: yes
+ group_label: "Geo"
+ group_item_label: "Metro"
+ }
+
+ dimension: geo__region {
+ type: string
+ sql: ${TABLE}.geo.region ;;
+ full_suggestions: yes
+ group_label: "Geo"
+ group_item_label: "Region"
+ map_layer_name: us_states
+ }
+
+ dimension: geo__sub_continent {
+ type: string
+ sql: ${TABLE}.geo.sub_continent ;;
+ full_suggestions: yes
+ group_label: "Geo"
+ group_item_label: "Sub Continent"
+ }
+
+
+ ## Traffic Source Fields
+ dimension: traffic_source__medium {
+ view_label: "Acquisition"
+ type: string
+ sql: ${TABLE}.traffic_source.medium ;;
+ full_suggestions: yes
+ group_label: "User Traffic Source"
+ group_item_label: "Medium"
+ description: "The medium of the traffic source for the user's original first visit (Saved up to 1 Year by Default)."
+ }
+
+ dimension: traffic_source__name {
+ view_label: "Acquisition"
+ type: string
+ sql: ${TABLE}.traffic_source.name ;;
+ full_suggestions: yes
+ group_label: "User Traffic Source"
+ description: "The name of the traffic source for the user's original first visit (Saved up to 1 Year by Default)."
+ group_item_label: "Name"
+ }
+
+ dimension: traffic_source__source {
+ view_label: "Acquisition"
+ type: string
+ sql: ${TABLE}.traffic_source.source ;;
+ full_suggestions: yes
+ group_label: "User Traffic Source"
+ group_item_label: "Source"
+ description: "The source of the traffic source for the user's original first visit (Saved up to 1 Year by Default)."
+ }
+
+
+ ## User Fields
+ dimension: user_first_touch_timestamp {
+ type: number
+ sql: ${TABLE}.user_first_touch_timestamp ;;
+ }
+
+ dimension: user_ltv__currency {
+ type: string
+ sql: ${TABLE}.user_ltv.currency ;;
+ full_suggestions: yes
+ group_label: "User Ltv"
+ group_item_label: "Currency"
+ }
+
+ dimension: user_ltv__revenue {
+ type: number
+ sql: ${TABLE}.user_ltv.revenue ;;
+ group_label: "User Ltv"
+ group_item_label: "Revenue"
+ }
+
+ dimension: user_properties {
+ hidden: yes
+ sql: ${TABLE}.user_properties ;;
+ }
+
+ dimension: user_pseudo_id {
+ type: string
+ sql: ${TABLE}.user_pseudo_id ;;
+ full_suggestions: yes
+ }
+
+ # dimension: user_id
+
+## Measures
+
+ measure: total_events {
+ view_label: "Behavior"
+ group_label: "Events"
+ description: "The total number of events for the session."
+ type: count
+ # view_label: "Metrics"
+ # group_label: "Event Data"
+ # label: "Total Events"
+ }
+
+ measure: total_unique_events {
+ view_label: "Behavior"
+ group_label: "Events"
+ label: "Unique Events"
+ description: "Total Unique Events (Unique by Full Event Definition)"
+ #description: "Unique Events are interactions with content by a single user within a single session that can be tracked separately from pageviews or screenviews. "
+ type: count_distinct
+ sql: ${sl_key} ;;
+ }
+
+
+ measure: total_page_views {
+ # view_label: "Metrics"
+ # group_label: "Event Data"
+ # label: "Total Page Views"
+ view_label: "Behavior"
+ group_label: "Pages"
+ label: "Pageviews"
+ description: "The total number of pageviews for the property."
+ type: count
+ filters: [event_name: "page_view"]
+ value_format_name: formatted_number
+ }
+
+ measure: total_unique_page_views {
+ # view_label: "Metrics"
+ # group_label: "Event Data"
+ # label: "Total Unique Page Views"
+ view_label: "Behavior"
+ group_label: "Pages"
+ label: "Unique Pageviews"
+ description: "Unique Pageviews are the number of sessions during which the specified page was viewed at least once. A unique pageview is counted for each page URL + page title combination."
+ type: count_distinct
+ sql: CONCAT(${event_param_ga_session_id}, ${event_param_page}, ${event_param_page_title}) ;;
+ value_format_name: formatted_number
+ filters: [event_name: "page_view"]
+ }
+
+ measure: total_engaged_events {
+ type: count_distinct
+ view_label: "Behavior"
+ group_label: "Events"
+ label: "Engaged Events"
+ #description: ""
+ filters: [event_param_engaged_session_event: ">0"]
+ }
+
+ ## ECommerce
+
+ measure: total_transactions {
+ group_label: "Ecommerce"
+ label: "Transactions"
+ type: count_distinct
+ sql: ${ecommerce__transaction_id} ;;
+ filters: [ecommerce__transaction_id: "-(not set)"]
+ }
+
+ measure: transaction_revenue_per_user {
+ group_label: "Ecommerce"
+ type: number
+ sql: 1.0 * (${total_purchase_revenue}/NULLIF(${sessions.total_users},0)) ;;
+ value_format_name: usd
+ }
+
+ measure: transaction_conversion_rate {
+ group_label: "Ecommerce"
+ label: "Transaction Conversion Rate"
+ type: number
+ sql: 1.0 * (${total_transactions}/NULLIF(${sessions.total_sessions},0)) ;;
+ value_format_name: percent_2
+ }
+
+ measure: total_purchase_revenue {
+ group_label: "Ecommerce"
+ label: "Purchase Revenue"
+ type: sum_distinct
+ sql: ${ecommerce__purchase_revenue} ;;
+ sql_distinct_key: ${ecommerce__transaction_id} ;;
+ value_format_name: usd
+ }
+
+ measure: total_purchase_revenue_usd {
+ group_label: "Ecommerce"
+ label: "Purchase Revenue (USD)"
+ type: sum
+ sql: ${ecommerce__purchase_revenue_in_usd} ;;
+ # sql_distinct_key: ${ecommerce__transaction_id} ;;
+ value_format_name: usd
+ }
+
+ measure: total_refund_value {
+ group_label: "Ecommerce"
+ label: "Refund Value"
+ type: sum_distinct
+ sql: ${ecommerce__refund_value} ;;
+ sql_distinct_key: ${ecommerce__transaction_id} ;;
+ value_format_name: usd
+ }
+
+ measure: total_refund_value_usd {
+ group_label: "Ecommerce"
+ label: "Refund Value (USD)"
+ type: sum_distinct
+ sql: ${ecommerce__refund_value_in_usd} ;;
+ sql_distinct_key: ${ecommerce__transaction_id} ;;
+ value_format_name: usd
+ }
+
+ measure: total_shipping_value {
+ group_label: "Ecommerce"
+ label: "Shipping Value"
+ type: sum_distinct
+ sql: ${ecommerce__shipping_value} ;;
+ sql_distinct_key: ${ecommerce__transaction_id} ;;
+ value_format_name: usd
+ }
+
+ measure: total_shipping_value_usd {
+ group_label: "Ecommerce"
+ label: "Shipping Value (USD)"
+ type: sum_distinct
+ sql: ${ecommerce__shipping_value_in_usd} ;;
+ sql_distinct_key: ${ecommerce__transaction_id} ;;
+ value_format_name: usd
+ }
+
+ measure: total_tax_value {
+ group_label: "Ecommerce"
+ label: "Tax Value"
+ type: sum_distinct
+ sql: ${ecommerce__tax_value} ;;
+ sql_distinct_key: ${ecommerce__transaction_id} ;;
+ value_format_name: usd
+ }
+
+ measure: total_tax_value_usd {
+ group_label: "Ecommerce"
+ label: "Tax Value (USD)"
+ type: sum_distinct
+ sql: ${ecommerce__tax_value_in_usd} ;;
+ sql_distinct_key: ${ecommerce__transaction_id} ;;
+ value_format_name: usd
+ }
+
+ measure: total_item_quantity {
+ group_label: "Ecommerce"
+ label: "Transaction Items"
+ type: sum_distinct
+ sql: ${ecommerce__total_item_quantity} ;;
+ sql_distinct_key: ${ecommerce__transaction_id} ;;
+ value_format_name: decimal_0
+ }
+
+ measure: total_unique_items {
+ group_label: "Ecommerce"
+ label: "Unique Items"
+ type: sum_distinct
+ sql: ${ecommerce__unique_items} ;;
+ sql_distinct_key: ${ecommerce__transaction_id} ;;
+ value_format_name: decimal_0
+ }
+
+ # ----- Sets of fields for drilling ------
+ set: detail {
+ fields: [
+ event_name,
+ traffic_source__name,
+ device__mobile_model_name,
+ device__mobile_brand_name,
+ device__web_info__hostname,
+ event_dimensions__hostname,
+ device__mobile_marketing_name
+ ]
+ }
+}
diff --git a/views/sessions.view.lkml b/views/sessions.view.lkml
new file mode 100644
index 0000000..d8c5bbf
--- /dev/null
+++ b/views/sessions.view.lkml
@@ -0,0 +1,617 @@
+include: "/views/event_data_dimensions/event_funnel.view"
+include: "/views/event_data_dimensions/page_funnel.view"
+include: "/views/sessions/*.view"
+include: "/views/bqml/*/*.view"
+
+view: sessions {
+ derived_table: {
+ sql_trigger_value: ${device_geo.SQL_TABLE_NAME} ;;
+ partition_keys: ["session_date"]
+ cluster_keys: ["session_date"]
+ increment_key: "session_date"
+ increment_offset: 3
+ sql:
+-- Final Select Statement:
+select se.session_date as session_date
+ , se.ga_session_id as ga_session_id
+ , se.ga_session_number as ga_session_number
+ , se.user_pseudo_id as user_pseudo_id
+ , se.sl_key
+ -- packing session-level data into structs by category
+ , (SELECT AS STRUCT coalesce(sa.medium,'(none)') medium -- sessions missing last-non-direct are direct
+ , coalesce(sa.source,'(direct)') source
+ , coalesce(sa.campaign,'(direct)') campaign
+ , sa.page_referrer) session_attribution
+ , (SELECT AS STRUCT sf.session_event_count
+ , sf.engaged_events
+ , sf.session_page_view_count
+ , sf.is_engaged_session
+ , sf.is_first_visit_session
+ , sf.session_end
+ , sf.session_start
+ , sf.session_length_minutes) session_data
+ , (SELECT AS STRUCT d.device__category
+ , d.device__mobile_brand_name
+ , d.device__mobile_model_name
+ , d.device__mobile_device_info
+ , d.device__mobile_marketing_name
+ , d.device__mobile_os_hardware_model
+ , d.device__operating_system
+ , d.device__operating_system_version
+ , d.device__vendor_id
+ , d.device__advertising_id
+ , d.device__language
+ , d.device__time_zone_offset_seconds
+ , d.device__is_limited_ad_tracking
+ , d.device__web_info_browser
+ , d.device__web_info_browser_version
+ --, d.device__web_info_hostname
+ , d.device__is_mobile) device_data
+ , (SELECT AS STRUCT d.geo__continent
+ , d.geo__country
+ , d.geo__city
+ , d.geo__metro
+ , d.geo__sub_continent
+ , d.geo__region) geo_data
+ , se.event_data event_data
+from ${session_event_packing.SQL_TABLE_NAME} as se
+left join ${session_tags.SQL_TABLE_NAME} as sa
+ on se.sl_key = sa.sl_key
+left join ${session_facts.SQL_TABLE_NAME} as sf
+ on se.sl_key = sf.sl_key
+left join ${device_geo.SQL_TABLE_NAME} as d
+ on se.sl_key = d.sl_key
+where {% incrementcondition %} se.session_date {% endincrementcondition %}
+ ;;
+ }
+
+extends: [event_funnel, page_funnel]
+
+## Parameters
+
+ parameter: audience_selector {
+ view_label: "Audience"
+ description: "Use to set 'Audience Trait' field to dynamically choose a user cohort."
+ type: string
+ allowed_value: { value: "Device" }
+ allowed_value: { value: "Operating System" }
+ allowed_value: { value: "Browser" }
+ allowed_value: { value: "Country" }
+ allowed_value: { value: "Continent" }
+ allowed_value: { value: "Metro" }
+ allowed_value: { value: "Language" }
+ allowed_value: { value: "Channel" }
+ allowed_value: { value: "Medium" }
+ allowed_value: { value: "Source" }
+ allowed_value: { value: "Source Medium" }
+ default_value: "Source"
+ }
+
+## Dimensions
+ dimension: sl_key {
+ type: string
+ sql: ${TABLE}.sl_key ;;
+ primary_key: yes
+ hidden: yes
+ }
+
+ dimension_group: session {
+ type: time
+ sql: ${TABLE}.session_date ;;
+ }
+
+ dimension: ga_session_id {
+ type: number
+ sql: ${TABLE}.ga_session_id ;;
+ }
+
+ dimension: ga_session_number {
+ view_label: "Audience"
+ group_label: "User"
+ label: "Session Number"
+ type: number
+ sql: ${TABLE}.ga_session_number ;;
+ }
+
+ dimension: ga_session_number_tier {
+ view_label: "Audience"
+ group_label: "User"
+ label: "Session Number Tier"
+ description: "Session Number dimension grouped in tiers between 1-100. See 'Session Number' for full description."
+ type: tier
+ tiers: [1,2,5,10,15,20,50,100]
+ style: integer
+ sql: ${ga_session_number} ;;
+ }
+
+ dimension: user_pseudo_id {
+ type: string
+ sql: ${TABLE}.user_pseudo_id ;;
+ }
+
+ dimension: event_data {
+ hidden: yes
+ type: string
+ sql: ${TABLE}.event_data ;;
+ ## This is the parent array that contains the event_data struct elements. It is not directly useably as a dimension.
+ ## It is necessary for proper unnesting in the model Join.
+ }
+
+ dimension: audience_trait {
+ view_label: "Audience"
+ group_label: "Audience Cohorts"
+ description: "Dynamic cohort field based on value set in 'Audience Selector' filter."
+ type: string
+ sql: CASE
+ WHEN {% parameter audience_selector %} = 'Channel' THEN ${attribution_sources.attribution_source_channel}
+ WHEN {% parameter audience_selector %} = 'Medium' THEN ${session_attribution_medium}
+ WHEN {% parameter audience_selector %} = 'Source' THEN ${session_attribution_source}
+ WHEN {% parameter audience_selector %} = 'Source Medium' THEN ${session_attribution_source_medium}
+ WHEN {% parameter audience_selector %} = 'Device' THEN ${device_data_device_category}
+ WHEN {% parameter audience_selector %} = 'Browser' THEN ${device_data_web_info_browser}
+ WHEN {% parameter audience_selector %} = 'Metro' THEN ${geo_data_metro}
+ WHEN {% parameter audience_selector %} = 'Country' THEN ${geo_data_country}
+ WHEN {% parameter audience_selector %} = 'Continent' THEN ${geo_data_continent}
+ WHEN {% parameter audience_selector %} = 'Language' THEN ${device_data_language}
+ WHEN {% parameter audience_selector %} = 'Operating System' THEN ${device_data_operating_system}
+ END;;
+ }
+
+ ## Entrance(Landing)/Exit
+
+ dimension: landing_page {
+ view_label: "Behavior"
+ group_label: "Pages"
+ description: "Landing/Entrance Page (first 'Page View' event) of a Session."
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(sessions.event_data) as event_history
+ where event_history.sl_key = (sessions.sl_key) and event_history.page_view_rank = 1 limit 1) ;;
+ }
+ dimension: exit_page {
+ view_label: "Behavior"
+ group_label: "Pages"
+ description: "Exit Page (last 'Page View' event) of a Session."
+
+ sql: (select coalesce(regexp_extract((select value.string_value from UNNEST(event_params) where key = "page_location"),r"(?:.*?[\.][^\/]*)([\/][^\?]+)"),'/')
+ from UNNEST(sessions.event_data) as event_history
+ where event_history.sl_key = (sessions.sl_key) and event_history.page_view_reverse_rank = 1 limit 1) ;;
+ }
+
+ ## Session Data Dimensions
+ dimension: session_data {
+ type: string
+ sql: ${TABLE}.session_data ;;
+ hidden: yes
+ ## This is the Parent Struct that contains the session_data elements. It is not directly useably as a dimension.
+ ## It is referred to by its child dimensions in their sql definition.
+ }
+ dimension: session_data_session_event_count {
+ type: number
+ sql:${session_data}.session_event_count;;
+ label: "Session Event Count"
+ }
+ dimension: session_data_engaged_events {
+ type: number
+ sql: ${session_data}.engaged_events ;;
+ label: "Session Engaged Event Count"
+ }
+ dimension: session_data_page_view_count {
+ type: number
+ sql: ${session_data}.session_page_view_count ;;
+ label: "Page View Count"
+ }
+ dimension: session_data_is_engaged_session {
+ type: yesno
+ sql: ${session_data}.is_engaged_session ;;
+ label: "Is Engaged Session?"
+ }
+ dimension: session_data_is_first_visit_session {
+ type: yesno
+ sql: ${session_data}.is_first_visit_session ;;
+ label: "Is First Visit Session?"
+ }
+ dimension_group: session_data_session_end {
+ type: time
+ sql: ${session_data}.session_end ;;
+ timeframes: [raw,time,hour,hour_of_day,date,day_of_week,day_of_week_index,week,month,year]
+ label: "Session End"
+ }
+ dimension_group: session_data_session_start {
+ type: time
+ sql: ${session_data}.session_start ;;
+ timeframes: [raw,time,hour,hour_of_day,date,day_of_week,day_of_week_index,week,month,year]
+ label: "Session Start"
+ }
+ dimension: session_data_session_duration {
+ type: number
+ sql: ((TIMESTAMP_DIFF(${session_data_session_end_raw}, ${session_data_session_start_raw}, second))/86400.0) ;;
+ value_format_name: hour_format
+ label: "Session Duration"
+ }
+ dimension: session_data_session_duration_tier {
+ label: "Session Duration Tiers"
+ description: "The length (returned as a string) of a session measured in seconds and reported in second increments."
+ type: tier
+ sql: (${session_data_session_duration}*86400.0) ;;
+ tiers: [10,30,60,120,180,240,300,600]
+ style: integer
+ }
+ dimension: session_data_is_bounce {
+ type: yesno
+ sql: ${session_data_session_duration} = 0 ;;
+ label: "Is Bounce?"
+ description: "If Session Duration Minutes = 0 and there are no engaged events in the Session, then Bounce = True."
+ }
+
+ ## Session Attribution Dimensions
+ dimension: session_attribution {
+ type: string
+ sql: ${TABLE}.session_attribution ;;
+ hidden: yes
+ ## This is the Parent Struct that contains the session_attribution elements. It is not directly useably as a dimension.
+ ## It is referred to by its child dimensions in their sql definition.
+ }
+ dimension: session_attribution_page_referrer {
+ # group_label: "Attribution"
+ # label: "Page Referrer"
+ view_label: "Acquisition"
+ group_label: "Session Traffic Source"
+ label: "Full Referrer"
+ description: "The full referring URL including the hostname and path."
+ type: string
+ sql: ${session_attribution}.page_referrer ;;
+ }
+ dimension: session_attribution_campaign {
+ view_label: "Acquisition"
+ group_label: "Advertising"
+ label: "Campaign"
+ description: "The campaign value. Usually set by the utm_campaign URL parameter."
+ type: string
+ sql: ${session_attribution}.campaign ;;
+ }
+ dimension: session_attribution_source {
+ view_label: "Acquisition"
+ group_label: "Session Traffic Source"
+ label: "Source"
+ type: string
+ sql: ${session_attribution}.source ;;
+ }
+ dimension: session_attribution_medium {
+ view_label: "Acquisition"
+ group_label: "Session Traffic Source"
+ label: "Medium"
+ type: string
+ sql: ${session_attribution}.medium ;;
+ }
+ dimension: session_attribution_source_medium {
+ view_label: "Acquisition"
+ group_label: "Session Traffic Source"
+ label: "Source Medium"
+ type: string
+ sql: ${session_attribution}.source||' '||${session_attribution}.medium ;;
+ }
+
+ ## Session Device Data Dimensions
+ dimension: device_data {
+ type: string
+ sql: ${TABLE}.device_data ;;
+ hidden: yes
+ ## This is the Parent Struct that contains the device_data elements. It is not directly useably as a dimension.
+ ## It is referred to by its child dimensions in their sql definition.
+ }
+ dimension: device_data_device_category {
+ view_label: "Audience"
+ group_label: "Mobile"
+ label: "Device Category"
+ type: string
+ sql: ${device_data}.device__category ;;
+ }
+ dimension: device_data_mobile_brand_name {
+ view_label: "Audience"
+ group_label: "Mobile"
+ label: "Mobile Device Branding"
+ type: string
+ sql: ${device_data}.device__mobile_brand_name ;;
+ }
+ dimension: device_data_mobile_model_name {
+ view_label: "Audience"
+ group_label: "Mobile"
+ label: "Mobile Device Model"
+ type: string
+ sql: ${device_data}.device__mobile_model_name ;;
+ }
+ dimension: device_data_mobile_device_info {
+ view_label: "Audience"
+ group_label: "Mobile"
+ label: "Mobile Device Info"
+ type: string
+ sql: ${device_data}.device__mobile_device_info ;;
+ }
+ dimension: device_data_mobile_marketing_name {
+ view_label: "Audience"
+ group_label: "Mobile"
+ label: "Mobile Device Marketing Name"
+ type: string
+ sql: ${device_data}.device__mobile_marketing_name ;;
+ }
+ dimension: device_data_mobile_os_hardware_model {
+ view_label: "Audience"
+ group_label: "Mobile"
+ label: "Mobile OS Hardware Model"
+ type: string
+ sql: ${device_data}.device__mobile_os_hardware_model ;;
+ }
+ dimension: device_data_operating_system {
+ view_label: "Audience"
+ group_label: "Technology"
+ label: "Operating System"
+ type: string
+ sql: ${device_data}.device__operating_system ;;
+ }
+ dimension: device_data_operating_system_version {
+ view_label: "Audience"
+ group_label: "Technology"
+ label: "Operating System Version"
+ type: string
+ sql: ${device_data}.device__operating_system_version ;;
+ }
+ dimension: device_data_vendor_id {
+ hidden: yes
+ group_label: "Device"
+ label: "Vendor ID"
+ type: string
+ sql: ${device_data}.device__vendor_id ;;
+ }
+ dimension: device_data_advertising_id {
+ hidden: yes
+ group_label: "Device"
+ label: "Advertising ID"
+ type: string
+ sql: ${device_data}.device__advertising_id ;;
+ }
+ dimension: device_data_language {
+ view_label: "Audience"
+ group_label: "User"
+ label: "Language"
+ type: string
+ sql: ${device_data}.device__language ;;
+ }
+ dimension: device_data_time_zone_offset_seconds {
+ group_label: "Device"
+ label: "Time Zone Offset Seconds"
+ type: number
+ sql: ${device_data}.device__time_zone_offset_seconds ;;
+ }
+ dimension: device_data_is_limited_ad_tracking {
+ group_label: "Device"
+ label: "Is Limited Ad Tracking?"
+ type: string
+ sql: ${device_data}.device__is_limited_ad_tracking ;;
+ }
+ dimension: device_data_web_info_browser {
+ view_label: "Audience"
+ group_label: "Technology"
+ label: "Browser"
+ type: string
+ sql: ${device_data}.device__web_info_browser ;;
+ }
+ dimension: device_data_web_info_browser_version {
+ view_label: "Audience"
+ group_label: "Technology"
+ label: "Browser Version"
+ type: string
+ sql: ${device_data}.device__web_info_browser_version ;;
+ }
+ #dimension: device_data_web_info_hostname {
+ #group_label: "Device"
+ # view_label: "Behavior"
+ #group_label: "Pages"
+ #label: "Hostname"
+ #description: "The hostname from which the tracking request was made."
+ #type: string
+ #sql: ${device_data}.device__web_info_hostname ;;
+ #}
+ dimension: device_is_mobile {
+ group_label: "Device"
+ label: "Is Mobile?"
+ type: string
+ sql: ${device_data}.device__is_mobile ;;
+ description: "Is the user's device a mobile device? (Yes/No)"
+ }
+
+ ## Session Geo Data Dimensions
+ dimension: geo_data {
+ type: string
+ sql: ${TABLE}.geo_data ;;
+ hidden: yes
+ ## This is the Parent Struct that contains the geo_data elements. It is not directly useably as a dimension.
+ ## It is referred to by its child dimensions in their sql definition.
+ }
+ dimension: geo_data_continent {
+ view_label: "Audience"
+ group_label: "Geo"
+ label: "Continent"
+ type: string
+ sql: ${geo_data}.geo__continent ;;
+ }
+ dimension: geo_data_country {
+ view_label: "Audience"
+ group_label: "Geo"
+ label: "Country"
+ type: string
+ sql: ${geo_data}.geo__country ;;
+ map_layer_name: countries
+ }
+ dimension: geo_data_city {
+ view_label: "Audience"
+ group_label: "Geo"
+ label: "City"
+ type: string
+ sql: ${geo_data}.geo__city ;;
+ }
+ dimension: geo_data_metro {
+ view_label: "Audience"
+ group_label: "Geo"
+ label: "Metro"
+ type: string
+ sql: ${geo_data}.geo__metro ;;
+ }
+ dimension: geo_data_sub_continent {
+ view_label: "Audience"
+ group_label: "Geo"
+ label: "Sub-Continent"
+ type: string
+ sql: ${geo_data}.geo__sub_continent ;;
+ }
+ dimension: geo_data_region {
+ view_label: "Audience"
+ group_label: "Geo"
+ label: "Region"
+ type: string
+ sql: ${geo_data}.geo__region ;;
+ map_layer_name: us_states
+ }
+
+## Measures
+
+ measure: total_sessions {
+ group_label: "Session"
+ label: "Sessions"
+ description: "Total Number of Sessions (Count)"
+ type: count_distinct
+ sql: ${sl_key} ;;
+ value_format_name: formatted_number
+ drill_fields: [session_attribution_source_medium,total_sessions,total_new_users,events.total_page_views,average_session_duration]
+ }
+
+ measure: total_first_visit_sessions {
+ group_label: "Session"
+ label: "New Sessions"
+ description: "Total Number of 'First Visit' Sessions (Count)"
+ type: count_distinct
+ sql: ${sl_key} ;;
+ filters: [session_data_is_first_visit_session: "yes"]
+ value_format_name: formatted_number
+ }
+
+ measure: total_first_visit_sessions_percentage {
+ group_label: "Session"
+ label: "New Sessions %"
+ description: "Percentage of New Sessions out of All Sessions"
+ type: number
+ sql: ${total_first_visit_sessions}/nullif(${total_sessions},0) ;;
+ value_format_name: percent_2
+ }
+
+ measure: total_engaged_sessions {
+ group_label: "Session"
+ label: "Engaged Sessions"
+ description: "Total Number of Sessions w/ Engaged Event"
+ type: count_distinct
+ sql: ${sl_key} ;;
+ filters: [session_data_is_engaged_session: "yes"]
+ value_format_name: formatted_number
+ }
+
+ measure: total_engaged_sessions_percentage {
+ group_label: "Session"
+ label: "Engaged Sessions %"
+ type: number
+ sql: ${total_engaged_sessions}/nullif(${total_sessions},0) ;;
+ value_format_name: percent_2
+ }
+
+ measure: average_page_views_per_session {
+ group_label: "Session"
+ label: "Avg. Page Views per Session"
+ description: "Average Count of 'Page_View' events within each Session."
+ type: average
+ sql: ${session_data_page_view_count} ;;
+ value_format_name: decimal_2
+ }
+
+ measure: total_bounced_sessions {
+ group_label: "Session"
+ label: "Bounces"
+ description: "Total Number of Sessions with 0 Duration w/out Engagement"
+ type: count_distinct
+ sql: ${sl_key} ;;
+ filters: [session_data_is_bounce: "yes"]
+ value_format_name: formatted_number
+ }
+
+ measure: total_bounced_sessions_percentage {
+ group_label: "Session"
+ label: "Bounce Rate"
+ description: "Percentage of Bounce Sessions out of All Sessions"
+ type: number
+ sql: ${total_bounced_sessions}/nullif(${total_sessions},0) ;;
+ value_format_name: percent_2
+ }
+
+ measure: average_session_duration {
+ group_label: "Session"
+ label: "Avg. Session Duration"
+ description: "The Average Session Duration in HH:MM:SS Format"
+ type: average
+ sql: ${session_data_session_duration} ;;
+ value_format_name: hour_format
+ }
+
+ measure: total_users {
+ view_label: "Audience"
+ group_label: "User"
+ label: "Users"
+ description: "Distinct/Unique count of Users"
+ type: count_distinct
+ sql: ${user_pseudo_id} ;;
+ value_format_name: formatted_number
+ }
+ #measure: total_event_count {
+ # type: sum
+ # description: "Total times an event occured on a specific date"
+ # sql: ${session_data_session_event_count} ;;
+ # value_format_name: formatted_number
+ #}
+
+ measure: total_new_users {
+ view_label: "Audience"
+ group_label: "User"
+ label: "New Users"
+ description: "Distinct/Unique count of User Pseudo ID where GA Session Number = 1"
+ type: count_distinct
+ sql: ${user_pseudo_id} ;;
+ filters: [session_data_is_first_visit_session: "yes"]
+ value_format_name: formatted_number
+ }
+
+ measure: total_returning_users {
+ view_label: "Audience"
+ group_label: "User"
+ label: "Returning Users"
+ description: "Distinct/Unique count of User Pseudo ID where GA Session Number > 1"
+ type: count_distinct
+ sql: ${user_pseudo_id} ;;
+ filters: [session_data_is_first_visit_session: "no"]
+ value_format_name: formatted_number
+ }
+
+ measure: percentage_new_users {
+ view_label: "Audience"
+ group_label: "User"
+ label: "% New Users"
+ type: number
+ sql: ${total_new_users}/nullif(${total_users},0) ;;
+ value_format_name: percent_2
+ }
+
+ measure: percentage_returning_users {
+ view_label: "Audience"
+ group_label: "User"
+ label: "% Returning Users"
+ type: number
+ sql: ${total_returning_users}/nullif(${total_users},0) ;;
+ value_format_name: percent_2
+ }
+
+}
diff --git a/views/sessions/device_geo.view.lkml b/views/sessions/device_geo.view.lkml
new file mode 100644
index 0000000..0c83e55
--- /dev/null
+++ b/views/sessions/device_geo.view.lkml
@@ -0,0 +1,32 @@
+include: "/views/sessions/*.view.lkml"
+view: device_geo{
+ derived_table:{
+ sql_trigger_value: ${session_event_packing.SQL_TABLE_NAME} ;;
+ sql:select sl.sl_key
+ , sl.device.category device__category
+ , sl.device.mobile_brand_name device__mobile_brand_name
+ , sl.device.mobile_model_name device__mobile_model_name
+ , sl.device.mobile_brand_name||' '||device.mobile_model_name device__mobile_device_info
+ , sl.device.mobile_marketing_name device__mobile_marketing_name
+ , sl.device.mobile_os_hardware_model device__mobile_os_hardware_model
+ , sl.device.operating_system device__operating_system
+ , sl.device.operating_system_version device__operating_system_version
+ , sl.device.vendor_id device__vendor_id
+ , sl.device.advertising_id device__advertising_id
+ , sl.device.language device__language
+ , sl.device.time_zone_offset_seconds device__time_zone_offset_seconds
+ , sl.device.is_limited_ad_tracking device__is_limited_ad_tracking
+ , sl.device.web_info.browser device__web_info_browser
+ , sl.device.web_info.browser_version device__web_info_browser_version
+ --, sl.device.web_info.hostname device__web_info_hostname
+ , case when sl.device.category = 'mobile' then true else false end as device__is_mobile
+ , sl.geo.continent geo__continent
+ , sl.geo.country geo__country
+ , sl.geo.city geo__city
+ , sl.geo.metro geo__metro
+ , sl.geo.sub_continent geo__sub_continent
+ , sl.geo.region geo__region
+ from ${session_list_with_event_history.SQL_TABLE_NAME} AS sl
+ where sl.event_name = 'session_start' ;;
+ }
+}
diff --git a/views/sessions/session_event_packing.view.lkml b/views/sessions/session_event_packing.view.lkml
new file mode 100644
index 0000000..f4d2b3f
--- /dev/null
+++ b/views/sessions/session_event_packing.view.lkml
@@ -0,0 +1,53 @@
+include: "/views/sessions/*.view.lkml"
+view: session_event_packing {
+ derived_table:{
+ sql_trigger_value: ${session_facts.SQL_TABLE_NAME} ;;
+ partition_keys: ["session_date"]
+ cluster_keys: ["sl_key","user_pseudo_id","session_date"]
+ increment_key: "session_date"
+ increment_offset: 0
+ sql:select sl.session_date session_date
+ , sl.ga_session_id ga_session_id
+ , sl.ga_session_number ga_session_number
+ , sl.user_pseudo_id user_pseudo_id
+ , sl.sl_key
+ , ARRAY_AGG(STRUCT(sl.sl_key
+ , sl.event_rank
+ , sl.page_view_rank
+ , sl.page_view_reverse_rank
+ , sl.time_to_next_event
+ , sl.time_to_next_page
+ , sl.event_date
+ , sl.event_timestamp
+ , sl.event_name
+ , sl.event_params
+ , sl.event_previous_timestamp
+ , sl.event_value_in_usd
+ , sl.event_bundle_sequence_id
+ , sl.event_server_timestamp_offset
+ , sl.user_id
+ , sl.user_pseudo_id
+ , sl.user_properties
+ , sl.user_first_touch_timestamp
+ , sl.user_ltv
+ , sl.device
+ , sl.geo
+ , sl.app_info
+ , sl.traffic_source
+ , sl.stream_id
+ , sl.platform
+ , sl.event_dimensions
+ , sl.ecommerce
+ , sl.items)) event_data
+ from ${session_list_with_event_history.SQL_TABLE_NAME} AS sl
+ WHERE sl.sl_key IN (SELECT sl_key FROM ${session_facts.SQL_TABLE_NAME}
+ WHERE CASE WHEN "@{EVENT_COUNT}" = "" THEN 1=1 WHEN "@{EVENT_COUNT}" != "" THEN
+ session_event_count< SAFE_CAST("@{EVENT_COUNT}" AS INT64) END)
+ AND {% incrementcondition %} session_date {% endincrementcondition %}
+ group by 1,2,3,4,5;;
+ }
+ dimension: session_date{
+ type: date
+ hidden: yes
+ }
+}
diff --git a/views/sessions/session_facts.view.lkml b/views/sessions/session_facts.view.lkml
new file mode 100644
index 0000000..5ec7161
--- /dev/null
+++ b/views/sessions/session_facts.view.lkml
@@ -0,0 +1,20 @@
+include: "/views/sessions/*.view.lkml"
+view: session_facts{
+ derived_table: {
+ #datagroup_trigger: ga4_main_datagroup
+ sql_trigger_value: ${session_tags.SQL_TABLE_NAME} ;;
+ sql: select sl.sl_key as sl_key
+ , COUNT(sl.event_timestamp) session_event_count
+ , SUM(case when sl.event_name = 'page_view' then 1 else 0 end) session_page_view_count
+ , COALESCE(SUM((select value.int_value from UNNEST(sl.event_params) where key = "engaged_session_event")),0) engaged_events
+ , case when (COALESCE(SUM((select value.int_value from UNNEST(sl.event_params) where key = "engaged_session_event")),0) = 0
+ and COALESCE(SUM((select coalesce(SAFE_CAST(value.string_value as INT64),value.int_value) from UNNEST(sl.event_params) where key = "session_engaged"))) = 0)
+ then false else true end as is_engaged_session
+ , case when countif(event_name = 'first_visit') = 0 then false else true end as is_first_visit_session
+ , MAX(TIMESTAMP_MICROS(sl.event_timestamp)) as session_end
+ , MIN(TIMESTAMP_MICROS(sl.event_timestamp)) as session_start
+ , (MAX(sl.event_timestamp) - MIN(sl.event_timestamp))/(60 * 1000 * 1000) AS session_length_minutes
+ from ${session_list_with_event_history.SQL_TABLE_NAME} AS sl
+ group by 1;;
+ }
+}
diff --git a/views/sessions/session_list_with_event_history.view.lkml b/views/sessions/session_list_with_event_history.view.lkml
new file mode 100644
index 0000000..f750484
--- /dev/null
+++ b/views/sessions/session_list_with_event_history.view.lkml
@@ -0,0 +1,61 @@
+include: "/views/event_data_dimensions/event_funnel.view"
+include: "/views/event_data_dimensions/page_funnel.view"
+
+view: session_list_with_event_history {
+ derived_table: {
+ datagroup_trigger: ga4_main_datagroup
+ partition_keys: ["session_date"]
+ cluster_keys: ["sl_key","user_id","session_date"]
+ increment_key: "session_date"
+ increment_offset: 0
+ sql:-- obtains a list of sessions, uniquely identified by the table date, ga_session_id event parameter, ga_session_number event parameter, and the user_pseudo_id.
+ select timestamp(SAFE.PARSE_DATE('%Y%m%d', REGEXP_EXTRACT(_TABLE_SUFFIX,r'(\d{8})'))) session_date
+ , (select value.int_value from UNNEST(events.event_params) where key = "ga_session_id") ga_session_id
+ , (select value.int_value from UNNEST(events.event_params) where key = "ga_session_number") ga_session_number
+ , events.user_pseudo_id
+ -- unique key for session:
+ , timestamp(SAFE.PARSE_DATE('%Y%m%d', REGEXP_EXTRACT(_TABLE_SUFFIX,r'[0-9]+')))||(select value.int_value from UNNEST(events.event_params) where key = "ga_session_id")||(select value.int_value from UNNEST(events.event_params) where key = "ga_session_number")||events.user_pseudo_id as sl_key
+ , row_number() over (partition by (timestamp(SAFE.PARSE_DATE('%Y%m%d', REGEXP_EXTRACT(_TABLE_SUFFIX,r'[0-9]+')))||(select value.int_value from UNNEST(events.event_params) where key = "ga_session_id")||(select value.int_value from UNNEST(events.event_params) where key = "ga_session_number")||events.user_pseudo_id) order by events.event_timestamp) event_rank
+ , (TIMESTAMP_DIFF(TIMESTAMP_MICROS(LEAD(events.event_timestamp) OVER (PARTITION BY timestamp(SAFE.PARSE_DATE('%Y%m%d', REGEXP_EXTRACT(_TABLE_SUFFIX,r'[0-9]+')))||(select value.int_value from UNNEST(events.event_params) where key = "ga_session_id")||(select value.int_value from UNNEST(events.event_params) where key = "ga_session_number")||events.user_pseudo_id ORDER BY events.event_timestamp asc))
+ ,TIMESTAMP_MICROS(events.event_timestamp),second)/86400.0) time_to_next_event
+ , case when events.event_name = 'page_view' then row_number() over (partition by (timestamp(SAFE.PARSE_DATE('%Y%m%d', REGEXP_EXTRACT(_TABLE_SUFFIX,r'[0-9]+')))||(select value.int_value from UNNEST(events.event_params) where key = "ga_session_id")||(select value.int_value from UNNEST(events.event_params) where key = "ga_session_number")||events.user_pseudo_id), case when events.event_name = 'page_view' then true else false end order by events.event_timestamp)
+ else 0 end as page_view_rank
+ , case when events.event_name = 'page_view' then row_number() over (partition by (timestamp(SAFE.PARSE_DATE('%Y%m%d', REGEXP_EXTRACT(_TABLE_SUFFIX,r'[0-9]+')))||(select value.int_value from UNNEST(events.event_params) where key = "ga_session_id")||(select value.int_value from UNNEST(events.event_params) where key = "ga_session_number")||events.user_pseudo_id), case when events.event_name = 'page_view' then true else false end order by events.event_timestamp desc)
+ else 0 end as page_view_reverse_rank
+ , case when events.event_name = 'page_view' then (TIMESTAMP_DIFF(TIMESTAMP_MICROS(LEAD(events.event_timestamp) OVER (PARTITION BY timestamp(SAFE.PARSE_DATE('%Y%m%d', REGEXP_EXTRACT(_TABLE_SUFFIX,r'[0-9]+')))||(select value.int_value from UNNEST(events.event_params) where key = "ga_session_id")||(select value.int_value from UNNEST(events.event_params) where key = "ga_session_number")||events.user_pseudo_id , case when events.event_name = 'page_view' then true else false end ORDER BY events.event_timestamp asc))
+ ,TIMESTAMP_MICROS(events.event_timestamp),second)/86400.0) else null end as time_to_next_page -- this window function yields 0 duration results when session page_view count = 1.
+ -- raw event data:
+ , events.event_date
+ , events.event_timestamp
+ , events.event_name
+ , events.event_params
+ , events.event_previous_timestamp
+ , events.event_value_in_usd
+ , events.event_bundle_sequence_id
+ , events.event_server_timestamp_offset
+ , events.user_id
+ -- , events.user_pseudo_id
+ , events.user_properties
+ , events.user_first_touch_timestamp
+ , events.user_ltv
+ , events.device
+ , events.geo
+ , events.app_info
+ , events.traffic_source
+ , events.stream_id
+ , events.platform
+ , events.event_dimensions
+ , events.ecommerce
+ , ARRAY(select as STRUCT it.* EXCEPT(item_params) from unnest(events.items) as it) as items
+ from `@{GA4_SCHEMA}.@{GA4_TABLE_VARIABLE}` events
+ where {% incrementcondition %} timestamp(PARSE_DATE('%Y%m%d', REGEXP_EXTRACT(_TABLE_SUFFIX,r'[0-9]+'))) {% endincrementcondition %}
+ --where timestamp(PARSE_DATE('%Y%m%d', REGEXP_EXTRACT(_TABLE_SUFFIX,r'[0-9]+'))) >= ((TIMESTAMP_ADD(TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY), INTERVAL -15 DAY)))
+ --and timestamp(PARSE_DATE('%Y%m%d', REGEXP_EXTRACT(_TABLE_SUFFIX,r'[0-9]+'))) <= ((TIMESTAMP_ADD(TIMESTAMP_ADD(TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY), INTERVAL -15 DAY), INTERVAL 16 DAY)))
+ ;;
+ }
+ dimension: session_date {
+ type: date
+ hidden: yes
+ sql: ${TABLE}.session_date;;
+ }
+ }
diff --git a/views/sessions/session_tags.view.lkml b/views/sessions/session_tags.view.lkml
new file mode 100644
index 0000000..857808c
--- /dev/null
+++ b/views/sessions/session_tags.view.lkml
@@ -0,0 +1,35 @@
+include: "/views/sessions/*.view.lkml"
+view: session_tags{
+ derived_table:{
+ increment_key: "session_date"
+ partition_keys: ["session_date"]
+ 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
+ , 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, sl3.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 %} sl.session_date {% endincrementcondition %};;
+ }
+ dimension: session_date {
+ type: date
+ hidden: yes
+ sql: ${TABLE}.session_date ;;
+ }
+}
diff --git a/views/user_first_session.view.lkml b/views/user_first_session.view.lkml
new file mode 100644
index 0000000..5ecd4c2
--- /dev/null
+++ b/views/user_first_session.view.lkml
@@ -0,0 +1,38 @@
+view: user_first_session {
+ derived_table: {
+ explore_source: sessions {
+ column: sl_key {}
+ column: user_pseudo_id {}
+ column: session_data_session_end_time {}
+ column: session_data_session_start_time {}
+ derived_column: first_session_end_time {
+ sql: min(session_data_session_end_time) over (partition by user_pseudo_id order by session_data_session_start_time) ;;
+ }
+ }
+ }
+ dimension: sl_key { hidden:yes }
+ dimension: session_data_session_start_time { hidden:yes }
+ dimension_group: first_session_end_time {
+ hidden: yes
+ type: time
+ timeframes: [hour,date,week,year,raw]
+ }
+ dimension_group: since_previous_session {
+ view_label: "Audience"
+ group_label: "User"
+ type: duration
+ intervals: [hour,day]
+ sql_start: ${first_session_end_time_raw} ;;
+ sql_end: ${session_data_session_start_time} ;;
+ }
+ dimension: days_since_first_session_tier {
+ view_label: "Audience"
+ group_label: "User"
+ description: "Days since the first session. 0 if user only has 1 session."
+ type: tier
+ style: integer
+ tiers: [1,2,4,8,15,31,61,121,365]
+ sql: ${days_since_previous_session};;
+ }
+
+ }
diff --git a/views/user_previous_session.view.lkml b/views/user_previous_session.view.lkml
new file mode 100644
index 0000000..b069a47
--- /dev/null
+++ b/views/user_previous_session.view.lkml
@@ -0,0 +1,37 @@
+view: user_previous_session {
+ derived_table: {
+ explore_source: sessions {
+ column: sl_key {}
+ column: user_pseudo_id {}
+ column: session_data_session_end_time {}
+ column: session_data_session_start_time {}
+ derived_column: prev_session_end_time {
+ sql: lag(session_data_session_end_time) over (partition by user_pseudo_id order by session_data_session_start_time) ;;
+ }
+ }
+ }
+ dimension: sl_key { hidden:yes }
+ dimension: session_data_session_start_time { hidden:yes }
+ dimension_group: prev_session_end_time {
+ hidden: yes
+ type: time
+ timeframes: [hour,date,week,year,raw]
+ }
+ dimension_group: since_previous_session {
+ view_label: "Audience"
+ group_label: "User"
+ type: duration
+ intervals: [hour,day]
+ sql_start: ${prev_session_end_time_raw} ;;
+ sql_end: ${session_data_session_start_time} ;;
+ }
+ dimension: days_since_previous_session_tier {
+ view_label: "Audience"
+ group_label: "User"
+ description: "Days since the previous session. 0 if user only has 1 session."
+ type: tier
+ style: integer
+ tiers: [1,2,4,8,15,31,61,121,365]
+ sql: ${days_since_previous_session};;
+ }
+ }
diff --git a/views/user_segment.view.lkml b/views/user_segment.view.lkml
new file mode 100644
index 0000000..b27d987
--- /dev/null
+++ b/views/user_segment.view.lkml
@@ -0,0 +1,106 @@
+view: user_segment_filters {
+ extension: required
+ filter: user_segment_timeframe {
+ type: date
+ }
+ filter: user_segment_landing_page {
+ type: string
+ suggest_explore: sessions
+ suggest_dimension: sessions.landing_page
+ }
+}
+
+view: user_segment {
+ derived_table: {
+ #https://gafourblock.cloud.looker.com/explore/ga4/sessions?qid=TNJNii9UxKynCJltMZZ0iv&toggle=fil
+
+ explore_source: sessions {
+ column: user_pseudo_id {}
+ column: total_sessions {}
+ column: total_purchase_revenue { field: events.total_purchase_revenue }
+ column: total_transactions { field: events.total_transactions }
+ bind_filters: {
+ from_field: user_segment.user_segment_timeframe
+ to_field: sessions.session_date #bind filters to filter the table when the view is created
+ }
+ bind_filters: {
+ from_field: user_segment.user_segment_landing_page
+ to_field: sessions.landing_page
+ }
+
+ }
+ }
+
+ extends: [user_segment_filters]
+
+ dimension: user_pseudo_id {hidden:yes primary_key:yes}
+ dimension: total_sessions {
+ hidden: yes
+ label: "Sessions Sessions"
+ description: "Total Number of Sessions (Count)"
+ #value_format: "[<1000]0;[<1000000]0.0,"K";0.0,,"M""
+ type: number
+ }
+ dimension: total_purchase_revenue {
+ hidden: yes
+ label: "Events Purchase Revenue"
+ value_format: "$#,##0.00"
+ type: number
+ }
+ dimension: total_transactions {
+ hidden: yes
+ label: "Events Transactions"
+ type: number
+ }
+
+
+ measure: segment_users {
+ group_label: "In Selected Timeframe"
+ type: count_distinct
+ allow_approximate_optimization: yes
+ sql: ${user_pseudo_id} ;;
+ }
+
+ measure: retention_rate {
+ type: number
+ sql: ${segment_users}/NULLIF(${sessions.total_users},0) ;;
+ value_format_name: percent_1
+ }
+
+ measure: segment_sessions {
+ group_label: "In Selected Timeframe"
+ type: sum
+ sql: ${total_sessions} ;;
+ value_format_name: decimal_0
+ }
+
+ measure: segment_transaction_revenue {
+ group_label: "In Selected Timeframe"
+ type: sum
+ sql: ${total_purchase_revenue} ;;
+ value_format_name: usd_0
+ }
+
+ measure: segment_transaction_revenue_per_user {
+ group_label: "In Selected Timeframe"
+ type: number
+ sql: ${segment_transaction_revenue}/NULLIF(${segment_users},0) ;;
+ value_format_name: usd
+ }
+
+ measure: segment_transaction_count {
+ group_label: "In Selected Timeframe"
+ type: sum
+ sql: ${total_transactions} ;;
+ value_format_name: decimal_0
+ }
+
+ measure: segment_transaction_conversion_rate {
+ group_label: "In Selected Timeframe"
+ type: number
+ sql: ${segment_transaction_count}/NULLIF(${segment_sessions},0) ;;
+ value_format_name: percent_1
+ }
+
+
+}