Instagram Business model
Media Performance Report
Generates a media performance report for Instagram Business integration. It combines metrics from the media_history and media_insights tables to provide a comprehensive view of monthly media performance. The report includes metrics such as total media posts, likes, comments, carousel engagement, views and reach, reel likes, views and reach, and feed engagement, views and reach.
- Grain
- account x month the media was posted
- Built from
- 2Raw tables
- 1Core
- 1Analytics
- Reads from Instagram Business
- media_historymedia_insights
- Ships as
- Weld and dbt SQL, open source on GitHub
core.instagram_business.media_performance_report
1-- core.instagram_business.media_performance_report
2-- Media Performance Report. Generates a media performance report for Instagram
3-- Business integration. It combines metrics from the media_history and
4-- media_insights tables to provide a comprehensive view of monthly media
5-- performance. The report includes metrics such as total media posts, likes,
6-- comments, carousel engagement, views and reach, reel likes, views and reach,
7-- and feed engagement, views and reach.
8--
9-- Grain: account x month the media was posted. Each post counts once, with its
10-- latest lifetime likes, comments and insights. Instagram now reports reel
11-- plays as views, so total_reel_views replaces the old plays column, and
12-- reports views instead of impressions for current posts, so
13-- total_carousel_views and total_feed_views replace the impressions columns.
14-- Feed engagement is the sum of a feed post's likes, comments, saves and
15-- shares, which is how Instagram defines its total interactions.
16--
17-- From the weld.app template library, corrected. Not reconciled against
18-- Instagram Business; check the output against the source before relying on it.
19
20with
21 latest_media as (
22 -- media_history keeps a snapshot of each post per sync; the latest one
23 -- carries the current like and comment counts
24 select
25 *
26 from
27 {{raw.instagram.media_history}}
28 where
29 true
30 qualify
31 row_number() over(
32 partition by
33 id
34 order by
35 _weld_synced_at desc
36 ) = 1
37 )
38 , insights as (
39 -- Instagram's total interactions for a post are its likes, comments,
40 -- saves and shares. Feed posts are synced with those counts but withoutThis model and the 1 it depends on. Deploy them together; refs like {{staging.…}} resolve to the matching folders in Weld, and the dbt view uses source() and ref().
Notes
How it counts. And where it stops.
Raw tables it reads
- raw.instagram.media_history
- raw.instagram.media_insights
Put Instagram Business in front
of your agents.
Connect Instagram Business, deploy the models, and ask questions in Claude, Cursor or ChatGPT. Free for 14 days, no credit card.