--- name: mm-analytics description: > Analyze website SEO performance (Google Search Console) and ad campaign performance (Google Ads, Meta Ads) for a client. Produces insights and recommendations for content and marketing strategy. Use when: "analytics", "วิเคราะห์", "ดูสถิติ", "performance report", "seo report", "ad performance", "mm analytics", "ดูผล". --- # mm-analytics Analyzes SEO and ad performance for a client, produces insights and recommendations. ## When This Must Trigger - "analytics", "วิเคราะห์", "ดูสถิติ", "performance report" - "seo report", "ad performance", "mm analytics", "ดูผล" - "วิเคราะห์เว็บ", "ดู traffic", "ดู campaign" ## Scripts Location All scripts are in `~/Gitea/moreminimore-service-system/scripts/`: - `mm_gsc.py` — Google Search Console analytics - `mm_google_ads.py` — Google Ads analytics - `mm_meta_ads.py` — Meta Ads analytics ## Process ### Step 1: Determine client and analysis type ``` ต้องการวิเคราะห์อะไร? 1. 🌐 SEO (Google Search Console) — traffic, queries, rankings 2. 📢 Google Ads — campaign performance, keywords 3. 📱 Meta Ads — Facebook/Instagram ad performance 4. 📊 ทั้งหมด — comprehensive report ``` ### Step 2: Run analytics scripts #### 2a. SEO Analytics (GSC) ```bash cd ~/Gitea/moreminimore-service-system/scripts python3 mm_gsc.py --client --days 90 ``` Output: - Top queries by impressions, clicks, CTR - Top pages by traffic - Position distribution (top 3, 4-10, 11-20, 21+) - Traffic trends (increasing/decreasing) - Content gap opportunities #### 2b. Google Ads Analytics ```bash cd ~/Gitea/moreminimore-service-system/scripts python3 mm_google_ads.py --client campaigns python3 mm_google_ads.py --client keywords python3 mm_google_ads.py --client stats --days 30 ``` Output: - Active campaigns with performance metrics - Keyword performance (impressions, clicks, CTR, CPC, QS) - Campaign stats with cost per conversion #### 2c. Meta Ads Analytics ```bash cd ~/Gitea/moreminimore-service-system/scripts python3 mm_meta_ads.py --client campaigns python3 mm_meta_ads.py --client stats --days 30 ``` Output: - Active campaigns with objectives and budgets - Performance stats (impressions, clicks, spend, reach, CTR, CPC) ### Step 3: Analyze and produce insights After collecting data, analyze for: **SEO Insights:** - Queries with high impressions but low CTR → title/description optimization - Queries ranking 4-10 → quick win opportunities - Pages losing traffic → content refresh needed - Content gaps → new article topics - GEO opportunities → AI search optimization **Ad Insights:** - Campaigns with high CPA → optimize targeting/creative - Keywords with low QS → improve ad relevance - Ad fatigue signals → refresh creative - Budget allocation → shift spend to better performers **Cross-channel Insights:** - SEO queries that match ad keywords → organic vs paid synergy - Content topics that perform well in ads → create organic content - Landing page performance → conversion optimization ### Step 4: Generate recommendations Produce actionable recommendations: ``` 📋 Analytics Report: [Client Name] 📅 Period: [date range] ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🌐 SEO Performance ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Top Queries: [list] Top Pages: [list] Traffic Trend: [↑/↓/→] ⚡ Quick Wins: 1. [Query] — position [X], [Y] impressions → optimize title 2. [Page] — losing traffic → refresh content 📝 Content Opportunities: 1. [Topic] — high search volume, no content → write article 2. [Topic] — ranking 11-20 → expand existing content ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📢 Google Ads Performance ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Campaigns: [N] active Total Spend: ฿[X] Avg CPA: ฿[X] ROAS: [X]x ⚡ Recommendations: 1. [Campaign] — high CPA → adjust targeting 2. [Keyword] — low QS → improve ad relevance ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📱 Meta Ads Performance ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Campaigns: [N] active Total Spend: ฿[X] Reach: [X] CTR: [X]% ⚡ Recommendations: 1. [Campaign] — low CTR → refresh creative 2. [Ad Set] — high frequency → new audience ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📋 Next Actions ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Content: 1. Write article about [topic] (from SEO gap) 2. Refresh [page] (losing traffic) Ads: 1. Optimize [campaign] (high CPA) 2. Refresh [ad creative] (fatigue) Strategy: 1. [Recommendation based on cross-channel data] ``` ### Step 5: Save report Save analytics report to: ``` ~/vault/60_Articles//analytics/YYYY-MM-DD-report.md ``` ## Integration with Content Pipeline The analytics feed back into the content pipeline: 1. **SEO gaps** → become new article topics (mm-article-idea-extract) 2. **Top performing content** → inform future content strategy 3. **Ad performance** → inform CTA and messaging for ad copy 4. **Cross-channel insights** → optimize overall marketing strategy ## Error Handling If a script fails: - Check if credentials are configured in clients-config.json - Check if the API is enabled (Google Ads API, Meta Marketing API) - Check if the access token is valid ``` ❌ [Script] failed: [error] สาเหตุที่เป็นไปได้: - Credentials ไม่ถูกต้อง → ตรวจสอบ clients-config.json - API ไม่ได้เปิดใช้งาน → เปิดใช้ใน Google Cloud / Meta Developer - Token หมดอายุ → ต่ออายุ token ต้องการ: 1. ลองใหม่ 2. ข้าม → วิเคราะห์เฉพาะส่วนที่ใช้ได้ ``` ## Notes - All scripts read from `~/vault/99_System/clients-config.json` - GSC uses service account key from `global.google.service_account_key` - Google Ads uses developer_token + gcloud ADC for authentication - Meta Ads uses page_token or system_user_token from config - Reports are saved to the client's vault folder for reference