Skip to content

Commit

Permalink
Use environment variables for project, dataset, property ID when not …
Browse files Browse the repository at this point in the history
…set as project variables
  • Loading branch information
davidbooke4 committed Oct 30, 2024
1 parent 984c311 commit 6493051
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion macros/base_select.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
, ecommerce.transaction_id
, items
, {%- if var('combined_dataset', false) != false %} cast(left(regexp_replace(_table_suffix, r'^(intraday_)?\d{8}', ''), 100) as int64)
{%- else %} {{ var('property_ids')[0] }}
{%- elif var('property_ids', false) != false %} {{ var('property_ids')[0] }}
{%- else %} {{ env_var('BIGQUERY_PROPERTY_ID') }}
{%- endif %} as property_id
{% endmacro %}

Expand Down
6 changes: 4 additions & 2 deletions models/staging/src_ga4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ sources:
- name: ga4
database: | # Source from target.project if multi-property, otherwise source from source_project
{%- if var('combined_dataset', false) != false -%} {{target.project}}
{%- else -%} {{var('source_project')}}
{%- elif var('source_project', false) != false -%} {{var('source_project')}}
{%- else -%} {{env_var('BIGQUERY_PROJECT')}}
{%- endif -%}
schema: | # Source from combined property dataset if set, otherwise source from original GA4 property
{%- if var('combined_dataset', false) != false -%} {{var('combined_dataset')}}
{%- else -%} analytics_{{var('property_ids')[0]}}
{%- elif var('property_ids', false) != false -%} analytics_{{var('property_ids')[0]}}
{%- else -%} analytics_{{env_var('BIGQUERY_PROPERTY_ID')}}
{%- endif -%}
tables:
- name: events
Expand Down

0 comments on commit 6493051

Please sign in to comment.