Skip to main content

Set up the Attribution dbt Package

Data modeling
  • Introduction

  • Before you start

  • Enabling Conversions within Unified Package

  • Setting up locally

  • Setting up via Snowplow Console

  • Optional - Configuring Channel Group Classification

  • Optional - Adding Marketing Spend Source for ROAS

Last updated on

Optional - Configuring Channel Group Classification

By default, the Attribution Package uses the channel grouping set within the Unified Package. It is recommended to set the channel grouping within the Unified Package, so you have matching channel groups across both packages.

Optionally, you can choose to have differing channel groupings within the Attribution Package by customizing the macro only within the Attribution Package.

Please Note: You only need to follow one of the configuration guides below.

Configuring within the Unified Package

  1. Create a new file called channel_group_query.sql in your root dbt projects macro folder

  1. Open this link to find the GitHub link to the channel_group_query.sql macro within Unified Package. Within the file there are three macros, find the one relevant to you:
    1. bigquery__channel_group_query - BigQuery
    2. redshift__channel_group_query - Redshift
    3. default__channel_group_query - Any other Data Warehouse or Query Engine
  2. Copy the relevant macro into the file you created within step 1. Ensure you copy the full macro.
{% macro default__channel_group_query() %}
...
{% endmacro %}
  1. Customize the CASE statement to capture your requirements. For example, you may want to set Unassigned to be called Direct.
CASE    
...
else 'Direct'
END
  1. Next time you run the Unified Package the macro you created will be prioritized over the built-in package macro.

Configuring within the Attribution Package

  1. Create a new file called channel_classification.sql in your root dbt projects macro folder

  1. Paste the following into the file you created within step 1.
{% macro default__channel_classification() %}

default_channel_group

{% endmacro %}
  1. Customize the macro to capture your requirements. See the example below on how you may want to set traffic to the channel Unassigned to be called Direct.

    The default_channel_group field is from the Unified Package.

{% macro default__channel_classification() %}

CASE
WHEN default_channel_group = 'Unassigned' THEN 'Direct'
ELSE default_channel_group
END

{% endmacro %}
  1. Next time you run the Attribution Package the macro you created will be prioritized over the built-in package macro.