Switchboard Docs
ReferenceSource Models

TikTok Models

Copy-paste SQL model definitions for TikTok Ads reporting.

Copy and Paste these TikTok Models into your Data Layer to quickly go from raw data souces —> business ready TikTok Reporting. Please note:

  • Models must be added chronological order from top to bottom (so that they can reference each other).
  • When adding your own models you must update the reference to include your source names.

Base (Ad Level)

tiktok_ads_performance_base

select 
 ad_id :: varchar as ad_id 
 , stat_time_day :: date as date 
 , spend :: float as spend
 , impressions 
 , clicks
 , purchase
 , cta_purchase
 , total_purchase 
 , total_checkout 
 , total_purchase_value

from {{sources.tiktok.ad_report_daily}}

Base (Campaign Level)

tiktok_campaign_history_base

select 
  md5(campaign_id || '-' || updated_at) as id
  , campaign_id 
  , campaign_name 
  , updated_at
  , row_number() over (
        partition by campaign_id 
        order by updated_at desc
    ) as index 
from {{sources.tiktok_ads.campaign_history}}

tiktok_campaigns_performance_base

select 
concat(stat_time_day,'-', campaign_id) as id
 , campaign_id :: varchar as campaign_id 
 , stat_time_day :: date as report_date  
 , spend :: float as spend
 , impressions as n_impressions
 , clicks as n_clicks 
 , total_purchase as n_conversions
 , total_purchase_value as conversions_in_dollars
  
  from {{sources.tiktok_ads.campaign_report_daily}}

On this page