# Campaigns

The campaigns-worker provides endpoints for viewing campaign-level analytics — aggregated stats, budget tracking, per-campaign detail metrics, timeseries data, and paginated video lists.


# Architecture

  • Worker: campaigns-worker (standalone Cloudflare Worker)
  • Data source: videos_with_statistics_fast view, get_campaigns_list RPC, analytics_daily_sparse view
  • Auth: JWT + X-Organization-ID header (same as dashboard-worker)
  • Route: api-private.influtics.com/campaigns/*

# How Campaigns Work

A campaign is represented by a campaign_tag text field on videos. Tags are assigned through the blogger_campaign table and propagated to videos via database triggers. There is no dedicated campaigns table — campaigns are derived from distinct campaign_tag values.

Videos without a campaign tag are grouped under the no_campaign sentinel value.


# Database Objects

Object Type Purpose
get_campaigns_list(org_id) RPC Aggregated stats per campaign (video count, creator count, views, likes, etc.)
get_campaign_creators(org_id, tag) RPC Per-creator breakdown for a campaign
get_analytics_daily_totals RPC 30-day aggregated stats (views, likes, comments, reposts) for a campaign
videos_with_statistics_fast View Videos with latest stats and budget — used for metrics, budget/cpm aggregation, and video list queries
analytics_daily_sparse View Daily increment data — used for timeseries charts