Velir/dbt-ga4

Custom event custom_parameters variables ignored

Closed this issue · 2 comments

(Still a noob with this package so apologies if I've missed something)

I setup a new custom event using the macro suggested, I have created stg_ga4__event_purchase_fe.sql, inside I have one line: {{ga4.create_custom_event('purchase_fe') }}

Within my dbt project yml, I've added:

vars:
  ga4:
  ...
   begin_checkout_custom_parameters:
   ...
    purchase_fe_custom_parameters: //this was added
      - name: "val"
        value_type: "int_value"
        rename_to: "value"
      - name: "transaction_id"
        value_type: "string_value"
      - name: "curr"
        value_type: "string_value"
        rename_to: "currency"

When I inspect the query used to create the view stg_ga4__event_purchase_fe in the DBT dataset within BigQuery, I see:

select *
    from `<project>`.`<dbt dev>`.`stg_ga4__events`
    where event_name = 'purchase_fe'

I don't see the unnested event parameters I added on (they work just fine for the begin_checkout).

Any idea what I'm doing wrong?

this is a common mistake. Try re-reading this section: https://github.com/Velir/dbt-ga4#custom-events

You'll notice that the custom params for custom events must be defined in a namespace above the ga4: key.

In other words,

vars:
  purchase_fe_custom_parameters: //this was added
    - name: "val"
      value_type: "int_value"
      rename_to: "value"
    - name: "transaction_id"
      value_type: "string_value"
    - name: "curr"
      value_type: "string_value"
      rename_to: "currency"

Ohh my mistake @adamribaudo-velir! That worked like a charm.
Thanks very much for the prompt reply, I'll close this ticket off!