Skip to content
This repository has been archived by the owner on Nov 2, 2022. It is now read-only.

Commit

Permalink
cleaned up constant names and repointed the time on page and user fac…
Browse files Browse the repository at this point in the history
…ts table to the ga sessions table
  • Loading branch information
Justin Pao committed Aug 4, 2020
1 parent b4763d4 commit 6376be7
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 31 deletions.
2 changes: 1 addition & 1 deletion BQML/user_facts.view.lkml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ view: user_facts {
sql:
--Limiting the table scans to the date ranges identified in the predictions table
WITH filtered_base AS (
SELECT * FROM `@{SCHEMA_NAME}.@{GA360_TABLE_NAME}`
SELECT * FROM ${ga_sessions.SQL_TABLE_NAME}
WHERE TIMESTAMP(PARSE_DATE('%Y%m%d', REGEXP_EXTRACT(_TABLE_SUFFIX,r'\d\d\d\d\d\d\d\d'))) BETWEEN ((TIMESTAMP_ADD(TIMESTAMP_TRUNC( CURRENT_TIMESTAMP(), DAY), INTERVAL -DAYS_BACK DAY))) AND ((TIMESTAMP_ADD(TIMESTAMP_ADD(TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY), INTERVAL -DAYS_BACK DAY), INTERVAL DAYS_FROM DAY)))),
-- labeling customers who have made a purchase as a 1 and customers who have not made a purchas as a 0
user_label AS (
Expand Down
2 changes: 1 addition & 1 deletion Google_Analytics/Custom_Views/event_action_facts.view.lkml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ view: event_action_facts {
derived_column: current_event_plus_4 {sql: LEAD(event_action,4) OVER (PARTITION BY id ORDER BY hit_time) ;;}
derived_column: current_event_plus_5 {sql: LEAD(event_action,5) OVER (PARTITION BY id ORDER BY hit_time) ;;}
derived_column: current_event_plus_6 {sql: LEAD(event_action,6) OVER (PARTITION BY id ORDER BY hit_time) ;;}
filters: [hits.event_action: "-NULL", ga_sessions.partition_date: "@{PARTITION_DATE_PDT_FILTER}"]
filters: [hits.event_action: "-NULL", ga_sessions.partition_date: "@{PDT_DATE_FILTER}"]
}
persist_for: "24 hours"
}
Expand Down
2 changes: 1 addition & 1 deletion Google_Analytics/Custom_Views/page_facts.view.lkml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ view: page_facts {
derived_column: current_page_plus_5 {sql: LEAD(page_path,5) OVER (PARTITION BY id ORDER BY hit_time) ;;}
derived_column: current_page_plus_6 {sql: LEAD(page_path,6) OVER (PARTITION BY id ORDER BY hit_time) ;;}
derived_column: cumulative_page_path {sql: STRING_AGG(page_path, " --> ") OVER (PARTITION BY id ORDER BY hit_time);;}
filters: [hits.type: "PAGE", ga_sessions.partition_date: "@{PARTITION_DATE_PDT_FILTER}"]
filters: [hits.type: "PAGE", ga_sessions.partition_date: "@{PDT_DATE_FILTER}"]
}
persist_for: "24 hours"
}
Expand Down
8 changes: 4 additions & 4 deletions Google_Analytics/filter_suggestions.view.lkml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ view: event_actions {
explore_source: ga_sessions {
column: event_action { field: hits.event_action }

filters: [ga_sessions.partition_date: "@{PARTITION_DATE_PDT_FILTER}"]
filters: [ga_sessions.partition_date: "@{PDT_DATE_FILTER}"]
}
persist_for: "24 hours"
}
Expand All @@ -27,7 +27,7 @@ view: event_labels {
explore_source: ga_sessions {
column: event_label { field: hits.event_label }

filters: [ga_sessions.partition_date: "@{PARTITION_DATE_PDT_FILTER}"]
filters: [ga_sessions.partition_date: "@{PDT_DATE_FILTER}"]
}
persist_for: "24 hours"
}
Expand All @@ -45,7 +45,7 @@ view: event_categories {
explore_source: ga_sessions {
column: event_category { field: hits.event_category }

filters: [ga_sessions.partition_date: "@{PARTITION_DATE_PDT_FILTER}"]
filters: [ga_sessions.partition_date: "@{PDT_DATE_FILTER}"]
}
persist_for: "24 hours"
}
Expand All @@ -65,7 +65,7 @@ view: top_pages {
column: page_path { field: hits.page_path_formatted }
column: page_count { field: hits.page_count }

filters: [ga_sessions.partition_date: "@{PARTITION_DATE_PDT_FILTER}"]
filters: [ga_sessions.partition_date: "@{PDT_DATE_FILTER}"]
sorts: [hits.page_count: desc]
limit: 50
}
Expand Down
10 changes: 4 additions & 6 deletions Google_Analytics/ga_sessions.view.lkml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ view: ga_sessions {
dimension: landing_page {
view_label: "Behavior"
group_label: "Pages (with Parameters)"
label: "Landing Page"
label: "Landing Page (with Parameters)"
description: "Landing page for session."
sql: (
SELECT
Expand Down Expand Up @@ -212,12 +212,10 @@ view: ga_sessions {

dimension: partition_date_filter {
type: string
sql: CONCAT('This data is from the ','@{PARTITION_DATE_PDT_FILTER}') ;;
sql: CONCAT('This data is from the ','@{PDT_DATE_FILTER} ') ;;
hidden: no
html: <div class="vis">
<div style="white-space: normal; word-wrap: break-word;width:100%; font-size:50%;"> {{value}}.</strong>
</div>
</div> ;;
html: <a style="background: #FFF;float: center; padding:15px; font-weight: bold;font-size: 30%;">{{value}} </a></strong>
;;
}


Expand Down
4 changes: 2 additions & 2 deletions Google_Analytics/hits.view.lkml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ view: hits {
dimension: full_page_url_parameters {
view_label: "Behavior"
group_label: "Pages (with Parameters)"
label: "Full Page URL"
label: "Full Page URL (with Parameters)"
description: "The full URL including the hostname and path."
type: string
sql: CONCAT(${host_name}, ${page_path});;
Expand Down Expand Up @@ -189,7 +189,7 @@ view: hits {
dimension: page_path {
view_label: "Behavior"
group_label: "Pages (with Parameters)"
label: "Page"
label: "Page (with Parameters)"
description: "A page on the website specified by path and/or query parameters. Use this with hostname to get the page's full URL."
sql: ${TABLE}.page.pagePath ;;
}
Expand Down
2 changes: 1 addition & 1 deletion Google_Analytics/time_on_page.view.lkml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ view: time_on_page {
, 0
)
) OVER (PARTITION BY fullVisitorId, visitStartTime) AS last_event
FROM `@{SCHEMA_NAME}.@{GA360_TABLE_NAME}` AS ga_sessions
FROM ${ga_sessions.SQL_TABLE_NAME} AS ga_sessions
LEFT JOIN UNNEST(ga_sessions.hits) AS hits
WHERE {% condition ga_sessions.partition_date %} TIMESTAMP(PARSE_DATE('%Y%m%d', REGEXP_EXTRACT(_TABLE_SUFFIX,r'^\d\d\d\d\d\d\d\d'))) {% endcondition %}
)
Expand Down
4 changes: 2 additions & 2 deletions manifest.lkml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ constant: CONFIG_PROJECT_NAME {
export: override_required
}

constant: PARTITION_DATE_PDT_FILTER {
constant: PDT_DATE_FILTER {
value: "last 1500 days"
export: override_required
}

constant: PARTITION_DATE_DEFAULT_EXPLORE_FILTER {
constant: EXPLORE_DATE_FILTER {
value: "last 1500 days"
export: override_required
}
14 changes: 1 addition & 13 deletions marketing.model.lkml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ explore: ga_sessions {
always_filter: {
filters: {
field: partition_date
value: "@{PARTITION_DATE_DEFAULT_EXPLORE_FILTER}"
value: "@{EXPLORE_DATE_FILTER}"
}
}

Expand Down Expand Up @@ -58,18 +58,6 @@ explore: ga_sessions {
relationship: one_to_one
}

join: custom_dimensions {
type: left_outer
sql: LEFT JOIN UNNEST(${hits.custom_dimensions}) AS custom_dimensions ;;
relationship: one_to_many
}

join: custom_variables {
type: left_outer
sql: LEFT JOIN UNNEST(${hits.custom_variables}) AS custom_variables ;;
relationship: one_to_many
}

join: event_action_facts {
type: left_outer
sql_on: ${ga_sessions.id} = ${event_action_facts.session_id}
Expand Down

0 comments on commit 6376be7

Please sign in to comment.