Skip to content

Commit 14bc5bc

Browse files
Hotfix: restore create_custom_event macro (#179)
* 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]>
1 parent a0df48b commit 14bc5bc

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,26 @@ vars:
222222
conversion_events:['purchase','download']
223223
```
224224

225+
# Custom Events
226+
227+
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:
228+
229+
```
230+
{{ ga4.create_custom_event('my_custom_event') }}
231+
```
232+
233+
Note, however, that any event-specific custom parameters or default custom parameters must be defined in the global variable space as shown below:
234+
235+
```
236+
vars:
237+
default_custom_parameters:
238+
- name: "some_parameter"
239+
value_type: "string_value"
240+
my_custom_event_custom_parameters:
241+
- name: "some_other_parameter"
242+
value_type: "string_value"
243+
```
244+
225245
# Incremental Loading of Event Data (and how to handle late-arriving hits)
226246

227247
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:

dbt_project.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'ga4'
2-
version: '3.2.0'
2+
version: '3.2.1'
33
config-version: 2
44
model-paths: ["models"]
55
analysis-paths: ["analyses"]

macros/create_custom_event.sql

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{%- macro create_custom_event(event_name) -%}
2+
{{ return(adapter.dispatch('create_custom_event', 'ga4')(event_name)) }}
3+
{%- endmacro -%}
4+
5+
{%- macro default__create_custom_event(event_name) -%}
6+
select *
7+
{% if var("default_custom_parameters", "none") != "none" %}
8+
{{ ga4.stage_custom_parameters( var("default_custom_parameters", "none") )}}
9+
{% endif %}
10+
{% if var(event_name+"_custom_parameters", "none") != "none" %}
11+
{{ ga4.stage_custom_parameters( var(event_name+"_custom_parameters") )}}
12+
{% endif %}
13+
from {{ref('stg_ga4__events')}}
14+
where event_name = '{{event_name}}'
15+
{%- endmacro -%}

0 commit comments

Comments
 (0)