Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new attribution model changes #812

Merged
merged 9 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const printYamlVariables = (data) => {

export const MyMdxComponent = () => {
const schemaName = 'dbtAttribution';
const versions = ['0.1.0'];
const versions = ['0.2.0', '0.1.0'];
const label = 'dbt attribution version';
const output = printYamlVariables;
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export const datagridProps = {
<Badges badgeType="Early Release"></Badges>&nbsp;
<Badges badgeType="SPAL"></Badges>

:::warning
Make sure you upgrade to [v.0.4.0](https://github.com/snowplow/dbt-snowplow-unified/releases/tag/0.4.0) of Unified Package if you would like to use the v0.2.0 of Attribution Package

:::


# Snowplow Attribution Package
Expand Down Expand Up @@ -118,7 +123,7 @@ Alternatively, you could use the `derived.snowplow_unified_sessions` table as we
:::tip
To fully finish the config you might need to overwrite the `channel_classification()` macro. In case your classification logic for attribution analysis needs to be the same as the one already configured in the snowplow_unified model you can simply leave the default macro which refers to that field.
:::
### 3. Channel spend information (optional, for reporting)
### 3. Channel spend information (optional, but recommended)

You most likely have a warehouse with marketing (ad) spend information by channel and date, something like this:

Expand All @@ -131,7 +136,7 @@ You most likely have a warehouse with marketing (ad) spend information by channe
`, datagridProps)}
</div>

We provided a sql script to create a reporting view in the `attribution_overview()` macro that you can overwrite to suit your specific analytical needs, however as long as you name the fields the same in the `var('snowplow__spend_source')` it should work right away.
To make it flexible to use what you already have, we suggest creating a view on top of the table you have, rename the fields that the model will use and add that view reference in `var('snowplow__spend_source')`. For more details on how to do this check out our [Quick Start Guide](/docs/modeling-your-data/modeling-your-data-with-dbt/dbt-quickstart/attribution/#3.good-to-know).

### One-off setup

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ sidebar_position: 20

```mdx-code-block
import ThemedImage from '@theme/ThemedImage';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
```

## Complete refresh of Snowplow package
Expand All @@ -15,13 +17,27 @@ Without dropping the manifest during a full refresh, the selected derived increm

In order to drop all the manifest tables and start again set the `snowplow__allow_refresh` var to `true` at run time:

<Tabs groupId="refresh" queryString>
<TabItem value="Other packages" label="Other packages">

```bash
dbt run --select snowplow_<package_name> tag:snowplow_<package>_incremental --full-refresh --vars 'snowplow__allow_refresh: true'
# or using selector flag
dbt run --selector snowplow_<package_name> --full-refresh --vars 'snowplow__allow_refresh: true'
```

</TabItem>

<TabItem value="Attribution" label="Attribution">

```bash
dbt run --full-refresh --vars 'snowplow__allow_refresh: true'
```

</TabItem>
</Tabs>


When doing a full refresh of the package, it will begin again from your `snowplow__start_date` and backfill based on the calculations explained in the [Incremental Sessionization Logic](/docs/modeling-your-data/modeling-your-data-with-dbt/package-mechanics/incremental-processing/index.md) page. Please ensure you trigger enough runs to catch back up with live data, or adjust your variables for these runs accordingly (see our page on [backfilling](/docs/modeling-your-data/modeling-your-data-with-dbt/dbt-operation/backfilling/index.md) for more information).


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { Accelerator } from "@site/src/components/AcceleratorAdmonitions";
In addition to [dbt](https://github.com/dbt-labs/dbt) being installed and a web events dataset being available in your database:

- have `snowplow_unified_views` table available as a path (touch points) source (generated by the [snowplow_unified package](/docs/modeling-your-data/modeling-your-data-with-dbt/dbt-models/dbt-unified-data-model/index.md))
- have `snowplow_unified_conversions` table available as a conversions source including the revenue (generated by the optional conversions module of the [snowplow_unified package](/docs/modeling-your-data/modeling-your-data-with-dbt/dbt-models/dbt-unified-data-model/index.md))
- have `snowplow_unified_conversions` table available as a conversions source including the revenue (generated by the optional conversions module of the [snowplow_unified package](/docs/modeling-your-data/modeling-your-data-with-dbt/dbt-models/dbt-unified-data-model/index.md)). Make sure you use [v.0.4.0](https://github.com/snowplow/dbt-snowplow-unified/releases/tag/0.4.0) and above (from unified 0.2.0 onwards)
- optionally have a spend source table of your choice available which will contain your marketing spend data by channel and or campaign with a timestamp field which denotes the period. This is needed for the ROAS calculation for the drop and recompute report table

## Installation
Expand Down Expand Up @@ -58,6 +58,14 @@ vars:
snowplow__conversion_hosts: ['mysite.com']
snowplow__path_transforms: {'exposure_path' : null}
```
<details>
<summary>Decide on running optional reporting models</summary>

By default the package creates a View used for BI reporting called `snowplow__enable_attribution_overview`. In case you would like to use the Attribution Modeling Data App (coming soon!), this is not required to be enabled as app will take care of querying this data for you directly.

There is also a `snowplow__enable_paths_to_non_conversion` variable to produce a drop and recompute table for more advanced analysis which is disabled by default. The data app does not yet support recreating the same data, therefore, it needs to be enabled by setting the default variable to `true`.
</details>
rlh1994 marked this conversation as resolved.
Show resolved Hide resolved


### 2. Configure macros

Expand All @@ -68,10 +76,45 @@ import AttributionDbtMacros from "@site/docs/reusable/attribution-dbt-macros/_in

<AttributionDbtMacros/>
```
### 3. Run the model

### 3. Good-to-know
Please consider the below before running the package as it might help you save time in the long run.

<details>
<summary>Configuring the spend_source</summary>

To make setting up your attribution modeling package easier, we provided a `snowplow__spend_source` variable which you can use to directly reference a table or view where you store information about your marketing spends. We suggest you just create a view on top of your existing table, making sure you have the following fields in place:

- a timestamp field called `spend_tstamp`
- a varchar/text field callled `channel`
- a varchar/text field callled `channel`
- a numeric field called `spend`

Your channel and spend data will be summed separately in the `attribution_overview` so it should not matter how you structure your data, it is fine to have channel twice for the same period even but do keep in mind that the model will not apply any deduplication.

</details>

<details>
<summary>Running both Unified and Attribution dbt packages from the same project</summary>
Although auto-deployed packages managed via Console run in separate projects, for others there may be use cases when it is more practical to run both the [Unified Digital](/docs/modeling-your-data/modeling-your-data-with-dbt/dbt-models/dbt-unified-data-model/index.md) and Attribution dbt packages from the same project. We purposefully did not directly link the two packages and this method of running is non-standard but there is a way to make it work. When specifying the sources just make sure you change the default source references to: ref('') instead of hard coding the schema.table_name for these variables:

```yml
snowplow__conversion_path_source: "{{ ref(snowplow_unified_views') }}"
snowplow__conversions_source: "{{ ref('snowplow_unified_conversions' }}"
```

Keep in mind that the manifest tables are still not linked, therefore both projects' statefulness is dictated by their own set of tables and values.
</details>



### 4. Run the model

Execute the following either through your CLI, within dbt Cloud, or within [Snowplow BDP](/docs/modeling-your-data/running-data-models-via-snowplow-bdp/dbt/index.md)

```yml
dbt run --select snowplow_attribution
```



Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,22 @@ In addition to [dbt](https://github.com/dbt-labs/dbt) being installed:

<details>
<summary>To model web events</summary>

- web events dataset being available in your database
- [Snowplow Javascript tracker](/docs/collecting-data/collecting-from-own-applications/javascript-trackers/index.md) version 2 or later implemented.
- Web Page context [enabled](/docs/collecting-data/collecting-from-own-applications/javascript-trackers/web-tracker/tracker-setup/initialization-options/index.md#webpage-context) (enabled by default in [v3+](/docs/collecting-data/collecting-from-own-applications/javascript-trackers/web-tracker/tracker-setup/initialization-options/index.md#webpage-context)).
- [Page view events](/docs/collecting-data/collecting-from-own-applications/javascript-trackers/web-tracker/tracking-events/index.md#page-views) implemented.

</details>

<details>
<summary>To mode mobile events</summary>

- mobile events dataset being available in your database
- Snowplow [Android](/docs/collecting-data/collecting-from-own-applications/mobile-trackers/previous-versions/android-tracker/index.md), [iOS](/docs/collecting-data/collecting-from-own-applications/mobile-trackers/previous-versions/objective-c-tracker/index.md) mobile tracker version 1.1.0 (or later) or [React Native tracker](https://docs.snowplow.io/docs/collecting-data/collecting-from-own-applications/react-native-tracker/) implemented
- Mobile session context enabled ([ios](/docs/collecting-data/collecting-from-own-applications/mobile-trackers/previous-versions/objective-c-tracker/ios-tracker-1-7-0/index.md#session-context) or [android](/docs/collecting-data/collecting-from-own-applications/mobile-trackers/previous-versions/android-tracker/android-1-7-0/index.md#session-tracking)).
- Screen view events enabled ([ios](/docs/collecting-data/collecting-from-own-applications/mobile-trackers/previous-versions/objective-c-tracker/ios-tracker-1-7-0/index.md#tracking-features) or [android](/docs/collecting-data/collecting-from-own-applications/mobile-trackers/previous-versions/android-tracker/android-1-7-0/index.md#tracking-features)).

</details>

## Installation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ Any package can make use of the table grants feature provided by the `snowplow__

| Package | Minimum Required Version |
|---------|--------------------------|
| Unified | 0.3.0 |
| Unified Digital | 0.3.0 |
| E-commerce | 0.8.1 |
| Media Player | 0.7.2 |
| Normalize | 0.3.5 |
| Attribution | 0.2.0|

Note that this feature is not supported for BigQuery due to the different approach to permissions they take via IAM roles.

Expand Down
2 changes: 1 addition & 1 deletion src/componentVersions.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const versions = {

// Data Modelling
// dbt
dbtSnowplowAttribution: '0.1.0',
dbtSnowplowAttribution: '0.2.0',
dbtSnowplowUnified: '0.3.1',
dbtSnowplowWeb: '1.0.0',
dbtSnowplowMobile: '1.0.0',
Expand Down
Loading