รวบรวม Social Media Analytics อัตโนมัติด้วย n8n
สร้าง workflow n8n ดึง analytics จาก Facebook Instagram TikTok มารวมใน Google Sheets เพื่อวิเคราะห์ performance ข้ามแพลตฟอร์มในที่เดียว
นักการตลาดส่วนใหญ่ใช้เวลา 20-30 นาทีทุกวันแค่เพื่อเก็บตัวเลข Social Media จากแต่ละแพลตฟอร์มมาใส่ใน spreadsheet ถ้าดูแล 3-4 แพลตฟอร์ม เวลานั้นบวกกัน 2 ชั่วโมงต่อสัปดาห์ไปกับงานที่ automation ทำแทนได้ทั้งหมด
n8n ดึงข้อมูลจาก Facebook Page Insights, Instagram Business Insights, TikTok Analytics และแพลตฟอร์มอื่นมารวมกันใน Google Sheets ได้ในหนึ่ง workflow รันทุกวันอัตโนมัติ ทีมเปิด sheet เช้ามาก็เห็นตัวเลขของเมื่อวานครบทุกช่องทาง
โครงสร้างข้อมูลที่ควรเก็บ
ออกแบบ Google Sheets ให้รองรับข้อมูลหลาย platform ในที่เดียว
Sheet: daily_metrics
| คอลัมน์ | ตัวอย่าง |
|---|---|
| date | 2026-04-15 |
| platform | |
| followers | 12500 |
| follower_change | +45 |
| impressions | 8400 |
| reach | 6200 |
| engagement | 380 |
| engagement_rate | 6.13% |
| clicks | 120 |
| video_views | 2800 |
Sheet: post_performance
| คอลัมน์ | ตัวอย่าง |
|---|---|
| date | 2026-04-15 |
| platform | |
| post_id | 17923456789 |
| post_type | image |
| caption_preview | 50 ตัวแรก |
| likes | 245 |
| comments | 18 |
| shares | 32 |
| saves | 67 |
| reach | 1850 |
| impressions | 2100 |
Sheet: weekly_summary — สร้างด้วย Google Sheets formula ดึงจาก daily_metrics อัตโนมัติ ไม่ต้องให้ n8n เขียนแยก
Workflow: ดึง Facebook Page Insights
Schedule Trigger รันทุกวันเวลา 6:00 น. ดึงข้อมูลของเมื่อวาน
GET https://graph.facebook.com/v18.0/{page-id}/insights
?metric=page_impressions,page_reach,page_engaged_users,
page_views_total,page_fan_adds,page_post_engagements
&period=day
&since={yesterday_start_unix}
&until={today_start_unix}
&access_token={page_access_token}
Response เป็น array ของ metric objects ใช้ Code node แปลงให้เป็น flat object ก่อนบันทึก
// Code node: แปลง Facebook Insights response
const metrics = $input.first().json.data;
const result = {};
metrics.forEach(metric => {
if (metric.values && metric.values.length > 0) {
// เอาค่าของ yesterday (index 0 หรือ 1 ขึ้นกับ period)
result[metric.name] = metric.values[0].value;
}
});
return [{
json: {
date: new Date(Date.now() - 86400000).toISOString().split('T')[0],
platform: 'facebook',
impressions: result.page_impressions || 0,
reach: result.page_reach || 0,
engaged_users: result.page_engaged_users || 0,
page_views: result.page_views_total || 0,
new_fans: result.page_fan_adds || 0,
post_engagements: result.page_post_engagements || 0
}
}];
Workflow: ดึง Instagram Account Insights
GET https://graph.facebook.com/v18.0/{ig-user-id}/insights
?metric=accounts_engaged,follower_count,impressions,
profile_views,reach,total_interactions,
website_clicks
&period=day
&since={yesterday_start_unix}
&until={today_start_unix}
สำหรับ follower_count ต้องใช้ period=lifetime แยกเพราะไม่รองรับ period=day
GET https://graph.facebook.com/v18.0/{ig-user-id}
?fields=followers_count,media_count,biography
Workflow: ดึง Top Posts ของสัปดาห์
นอกจาก account-level metrics ยังควรดึง post-level data เพื่อเปรียบเทียบว่าโพสต์ประเภทไหน perform ดีที่สุด
รัน workflow นี้ทุกวันจันทร์ เพื่อดึงโพสต์ 20 อันล่าสุดและ metrics ของแต่ละโพสต์
Facebook Posts:
GET https://graph.facebook.com/v18.0/{page-id}/posts
?fields=id,created_time,message,full_picture,
shares,story,
insights.metric(post_impressions,post_reach,
post_engaged_users,post_clicks)
&limit=20
&since={7_days_ago_unix}
Instagram Posts:
GET https://graph.facebook.com/v18.0/{ig-user-id}/media
?fields=id,timestamp,media_type,caption,permalink,
like_count,comments_count,
insights.metric(impressions,reach,engagement,saved)
&limit=20
รวมข้อมูลทุก Platform ในหนึ่ง Workflow
แทนที่จะมี workflow แยกสำหรับแต่ละแพลตฟอร์ม ให้รวมเป็น workflow เดียวที่รันทุกเช้า
Schedule Trigger (06:00)
├── HTTP Request → Facebook Insights
├── HTTP Request → Instagram Insights
├── HTTP Request → TikTok Analytics
└── HTTP Request → YouTube Analytics (ถ้ามี)
→ Merge (รวม results ทั้งหมด)
→ Code (normalize ให้เป็น format เดียวกัน)
→ Google Sheets (append ลง daily_metrics)
→ Slack/LINE (ส่ง morning brief)
Merge node ใช้ mode “Combine” เพื่อรวม outputs จากหลาย branches พร้อมกัน
Morning Brief อัตโนมัติ
ต่อ workflow ให้ส่งสรุปข้อมูลมาทาง LINE หรือ Slack ทุกเช้า
// Code node: สร้าง morning brief message
const metrics = $input.all();
let message = `📊 Social Media Report ${new Date().toLocaleDateString('th-TH')}\n\n`;
metrics.forEach(m => {
const d = m.json;
message += `${d.platform.toUpperCase()}\n`;
message += `• Reach: ${d.reach?.toLocaleString() || '-'}\n`;
message += `• Engagement: ${d.engagement?.toLocaleString() || '-'}\n`;
message += `• ผู้ติดตามใหม่: +${d.new_followers || 0}\n\n`;
});
return [{ json: { message } }];
Dashboard ด้วย Google Sheets + Looker Studio
Google Sheets ที่มีข้อมูลสะสมทุกวันสามารถต่อเข้า Looker Studio (Google Data Studio) ได้ฟรี เพื่อสร้าง dashboard ที่ดูสวยกว่า
Chart ที่มีประโยชน์สำหรับ Social Media Report
- Line chart — Follower growth ทุก platform ในกราฟเดียว
- Bar chart — Engagement rate เปรียบเทียบ platform ต่อสัปดาห์
- Heatmap — วันและเวลาที่ engagement สูงสุด (ใช้ Google Sheets formula สร้าง pivot ก่อน)
- Table — Top 10 posts ของเดือนเรียงตาม engagement
Cross-Platform Benchmark
เมื่อมีข้อมูลสะสม 30 วันขึ้นไป ให้เพิ่ม workflow รายเดือนที่คำนวณ benchmark
// คำนวณ average engagement rate ต่อ platform
const data = $input.all();
const byPlatform = {};
data.forEach(item => {
const p = item.json.platform;
if (!byPlatform[p]) byPlatform[p] = { total: 0, count: 0 };
byPlatform[p].total += parseFloat(item.json.engagement_rate) || 0;
byPlatform[p].count++;
});
return Object.entries(byPlatform).map(([platform, stats]) => ({
json: {
platform,
avg_engagement_rate: (stats.total / stats.count).toFixed(2)
}
}));
ข้อมูล benchmark นี้ช่วยให้รู้ว่าเดือนที่แล้วทำได้ดีหรือแย่กว่าค่าเฉลี่ยของตัวเอง และแพลตฟอร์มไหนควรลงทุนคอนเทนต์เพิ่ม
อยากเรียน n8n แบบเป็นระบบ ตั้งแต่เริ่มต้นจนสร้าง Workflow ใช้งานจริงได้ ลองดู คอร์สสอน n8n ที่ aiunlock.co
Related posts
สร้าง Content Calendar อัตโนมัติด้วย n8n + Google Sheets
คู่มือสร้างระบบ Content Calendar อัตโนมัติด้วย n8n และ Google Sheets วางแผนโพสต์ล่วงหน้า กำหนดเวลา แจกจ่ายไปหลาย platform พร้อมติดตามสถานะ
สร้างคอนเทนต์อัตโนมัติด้วย AI + n8n
สร้างระบบผลิตคอนเทนต์ Social Media อัตโนมัติด้วย AI และ n8n ตั้งแต่เขียนข้อความ ไปจนถึงโพสต์ Facebook, Instagram, Line
ใช้ Google Sheets เป็น CRM ง่ายๆ ด้วย n8n
สร้างระบบ CRM บน Google Sheets โดยใช้ n8n จัดการ Lead บันทึก Follow-up และส่งข้อความติดตามลูกค้าอัตโนมัติ