Skip to content

Commit

Permalink
Hotfix: restore create_custom_event macro (#179)
Browse files Browse the repository at this point in the history
* updating local main branch from remote

* updating local main branch from remote

* restore create_custom_event macro

* Restoring Readme updates

* Update dbt_project.yml

---------

Co-authored-by: Adam Ribaudo <[email protected]>
  • Loading branch information
dgitis and adamribaudo-velir authored Apr 14, 2023
1 parent a0df48b commit 14bc5bc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,26 @@ vars:
conversion_events:['purchase','download']
```

# Custom Events

Custom events can be generated in your project using the `create_custom_event` macro. Simply create a new model in your project and enter the following:

```
{{ ga4.create_custom_event('my_custom_event') }}
```

Note, however, that any event-specific custom parameters or default custom parameters must be defined in the global variable space as shown below:

```
vars:
default_custom_parameters:
- name: "some_parameter"
value_type: "string_value"
my_custom_event_custom_parameters:
- name: "some_other_parameter"
value_type: "string_value"
```

# Incremental Loading of Event Data (and how to handle late-arriving hits)

By default, GA4 exports data into sharded event tables that use the event date as the table suffix in the format of `events_YYYYMMDD` or `events_intraday_YYYYMMDD`. This package incrementally loads data from these tables into `base_ga4__events` which is partitioned on date. There are two incremental loading strategies available:
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'ga4'
version: '3.2.0'
version: '3.2.1'
config-version: 2
model-paths: ["models"]
analysis-paths: ["analyses"]
Expand Down
15 changes: 15 additions & 0 deletions macros/create_custom_event.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{%- macro create_custom_event(event_name) -%}
{{ return(adapter.dispatch('create_custom_event', 'ga4')(event_name)) }}
{%- endmacro -%}

{%- macro default__create_custom_event(event_name) -%}
select *
{% if var("default_custom_parameters", "none") != "none" %}
{{ ga4.stage_custom_parameters( var("default_custom_parameters", "none") )}}
{% endif %}
{% if var(event_name+"_custom_parameters", "none") != "none" %}
{{ ga4.stage_custom_parameters( var(event_name+"_custom_parameters") )}}
{% endif %}
from {{ref('stg_ga4__events')}}
where event_name = '{{event_name}}'
{%- endmacro -%}

0 comments on commit 14bc5bc

Please sign in to comment.