Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
milo157 committed May 17, 2022
1 parent 4ffccb8 commit 65bbb54
Show file tree
Hide file tree
Showing 24 changed files with 245 additions and 397 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[![Apache License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

# Intercom Airbyte
# facebook_ads Airbyte

This package models Intercom data from [Airbyte's connector](https://airbyte.com/connectors/intercom).
This package models facebook_ads data from [Airbyte's connector](https://airbyte.com/connectors/facebook_ads).

Let us know which connectors you would like to see next [here](https://19au6qz3a6s.typeform.com/to/c284SPEN)

Expand All @@ -16,7 +16,7 @@ This package contains staging models, with the following naming conventions acro

## DBT Metrics

This package contains configurations for DBT metrics for you to get up and running quickly with standard Intercom metrics in your existing BI tools.
This package contains configurations for DBT metrics for you to get up and running quickly with standard facebook_ads metrics in your existing BI tools.

## Installation Instructions

Expand All @@ -26,24 +26,24 @@ Include in your `packages.yml`

```yaml
packages:
- package: cerebriumAI/dbt-intercom
- package: cerebriumAI/dbt-facebook_ads
version: ["0.1.0"]
```
## Configuration
### Source Data Location
By default, this package will look for your Intercom data in the `intercom` schema of your [target database](https://docs.getdbt.com/docs/running-a-dbt-project/using-the-command-line-interface/configure-your-profile). If this is not where your Intercom data is, please add the following configuration to your `dbt_project.yml` file:
By default, this package will look for your facebook_ads data in the `facebook_ads` schema of your [target database](https://docs.getdbt.com/docs/running-a-dbt-project/using-the-command-line-interface/configure-your-profile). If this is not where your facebook_ads data is, please add the following configuration to your `dbt_project.yml` file:

```yml
# dbt_project.yml
---
config-version: 2
vars:
intercom_schema: your_schema_name
intercom_database: your_database_name
facebook_ads_schema: your_schema_name
facebook_ads_database: your_database_name
```

## Database Support
Expand Down
22 changes: 9 additions & 13 deletions dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'airbyte_intercom'
name: 'airbyte_facebook_ads'
version: '0.1.0'
require-dbt-version: ['>=1.0.0']
config-version: 2
Expand All @@ -16,20 +16,16 @@ clean-targets:
- "dbt_packages"

models:
airbyte_intercom:
airbyte_facebook_ads:
materialized: table
tmp:
materialized: view

vars:
airbyte_intercom:
admins: "{{ source('airbyte_intercom','admins') }}"
companies: "{{ source('airbyte_intercom','companies') }}"
companies_plan: "{{ source('airbyte_intercom','companies_plan') }}"
contacts: "{{ source('airbyte_intercom','contacts') }}"
conversation_parts: "{{ source('airbyte_intercom','conversation_parts') }}"
conversations: "{{ source('airbyte_intercom','conversations') }}"
conversations_assignee: "{{ source('airbyte_intercom','conversations_assignee') }}"
conversations_conversation_rating: "{{ source('airbyte_intercom','conversations_conversation_rating') }}"
conversations_sla_applied: "{{ source('airbyte_intercom','conversations_sla_applied') }}"
conversations_statistics: "{{ source('airbyte_intercom','conversations_statistics') }}"
facebook_ads_schema: "facebook_marketing_airbyte_masch"
airbyte_facebook_ads:
ads: "{{ source('airbyte_facebook_ads','ads') }}"
ad_creative: "{{ source('airbyte_facebook_ads','ad_creative') }}"
ad_creatives: "{{ source('airbyte_facebook_ads','ad_creatives') }}"
ad_insights: "{{ source('airbyte_facebook_ads','ad_insights') }}"
campaigns: "{{ source('airbyte_facebook_ads','campaigns') }}"
29 changes: 29 additions & 0 deletions models/facebook_ads__ad_adapter.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
base url
url host
url path
utm source
utm meidum
utm campaign
utm content
utm term
*/

with ads as (
select
created_at_timestamp as date_day,
account_id,
account_name,
campaign_id,
campaign_name,
adset_id,
adset_name,
ad_id,
ad_name,
account_id,
impressions,
clicks,
spend
from {{ ref('stg_facebook_ads_ads') }}
),
47 changes: 47 additions & 0 deletions models/facebook_ads__ad_set_report.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
date_day,
account_id,
account_name,
campaign_id,
campaign_name,
adset_id,
adset_name,
clicks,
impressions,
spend
*/

with ads as (
select
ad_id,
ad_name,
adset_id,
account_id,
account_name
campaign_id,
campaign_name,
created_at_timestamp,
spend,
clicks,
impressions
from {{ ref('stg_facebook_ads_ads') }}
),

adset as (
select
ads.created_at_timestamp,
ads.adset_id,
ads.adset_name,
ads.campaign_id,
ads.campaign_name,
ads.account_id,
ads.account_name,
sum(ads.spend),
sum(ads.clicks),
sum(ads.impressions)
from campaigns
left join ads using (campaign_id) and (created_at_timestamp)
{{ dbt_utils.group_by(n=6) }}
)

select * from final_campaigns
54 changes: 54 additions & 0 deletions models/facebook_ads__campaign_report.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
date_day,
account_id,
account_name,
campaign_id,
campaign_name,
clicks,
impressions,
spend
*/

with campaigns as (
select
id as campaign_id,
name as campaign_name,
objective,
account_id,
created_time as created_at_timestamp
from {{ ref('stg_facebook_ads_campaigns') }}
),

ads as (
select
ad_id,
ad_name,
adset_id,
account_id,
account_name
campaign_id,
campaign_name,
created_at_timestamp,
spend,
clicks,
impressions
from {{ ref('stg_facebook_ads_ads') }}
),

final_campaigns as (
select
campaigns.created_at_timestamp,
campaigns.campaign_id,
campaigns.campaign_name,
campaigns.account_id,
ads.account_name,
campaigns.objective,
sum(ads.spend),
sum(ads.clicks),
sum(ads.impressions)
from campaigns
left join ads using (campaign_id) and (created_at_timestamp)
{{ dbt_utils.group_by(n=6) }}
)

select * from final_campaigns
57 changes: 0 additions & 57 deletions models/intercom__admin_metrics.sql

This file was deleted.

32 changes: 0 additions & 32 deletions models/intercom__companies.sql

This file was deleted.

8 changes: 0 additions & 8 deletions models/intercom__contacts.sql

This file was deleted.

41 changes: 0 additions & 41 deletions models/intercom__conversation_metrics.sql

This file was deleted.

29 changes: 0 additions & 29 deletions models/intercom__conversations.sql

This file was deleted.

Loading

0 comments on commit 65bbb54

Please sign in to comment.