My AI Analytics Dashboard
Unified Data + AI Insights
I wanted actual answers from analytics, not just a pile of numbers. I had data scattered across 8 platforms, so I’d spend hours each week jumping between dashboards and still miss what mattered.
So I built my own system—a straight-up AI dashboard that grabs all platform data, pipes it through LLMs, then drops clear insights right where I need them. Stuff I used to miss unless I spent three hours digging? Now, five minutes tops.
The Code
Here’s what’s really running under the hood—tight integration, zero BS:
import openai
from datetime import datetime
import json
class MyAIAnalytics:
def __init__(self):
self.client = openai.OpenAI()
self.platforms = {}
self.metrics_data = {}
def connect_platform(self, platform, api_credentials):
print(f"🔌 Connecting {platform}...")
self.platforms[platform] = {
'credentials': api_credentials,
'connected_at': datetime.now().isoformat(),
'status': 'connected'
}
print(f"✅ {platform} connected\n")
def fetch_all_metrics(self, date_range=30):
print(f"📊 Fetching last {date_range} days...\n")
for platform in self.platforms:
print(f" 📱 {platform}...", end=" ")
metrics = self.fetch_platform_metrics(platform, date_range)
self.metrics_data[platform] = metrics
print(f"✅ {len(metrics.get('posts', []))} posts")
return self.metrics_data
def fetch_platform_metrics(self, platform, date_range):
# You’d swap this out for a real API fetch (Playwright+CDP, whatever works)
return {
'total_posts': 0,
'total_impressions': 0,
'total_engagement': 0,
'posts': [],
'audience': {},
'trends': {},
'overview': {}
}
def analyze_all_data(self):
print("🧠 AI analyzing data...\n")
summary = self.prepare_data_for_analysis()
insights = self.get_ai_insights(summary)
self.metrics_data['insights'] = insights
print(f"✅ {len(insights)} insights\n")
return insights
def prepare_data_for_analysis(self):
summary = {
'total_posts': 0,
'by_platform': {},
'top_performing_posts': [],
'audience_insights': {}
}
for platform, data in self.metrics_data.items():
overview = data.get('overview', {})
summary['total_posts'] += overview.get('total_posts', 0)
summary['by_platform'][platform] = overview
posts = data.get('posts', [])
summary['top_performing_posts'].extend(
sorted(posts, key=lambda x: x.get('engagement_rate', 0), reverse=True)[0:5]
)
return summary
def get_ai_insights(self, data):
prompt = f"""
Analyze this content analytics data and provide actionable insights:
DATA SUMMARY:
{data}
Provide:
- Key insights
- Content recommendations
- Growth opportunities
- Red flags
- Predicted trends
- Action items
Make insights specific, actionable, and easy to understand.
"""
response = self.client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": prompt}],
temperature=0.3,
response_format={"type": "json_object"}
)
return json.loads(response.choices[0].message.content)
def generate_weekly_report(self):
print("📋 Generating weekly report...\n")
report = {
'report_date': datetime.now().isoformat(),
'executive_summary': self.create_executive_summary(),
'top_posts': self.get_top_posts(10),
'recommendations': self.get_recommendations()
}
filename = f"analytics_report_{datetime.now().strftime('%Y%m%d')}.json"
with open(filename, 'w') as f:
json.dump(report, f, indent=2)
# Optional: Write out a readable MD file too
print(f"✅ Report saved to {filename}\n")
def create_executive_summary(self):
total_posts = sum(p.get('total_posts', 0) for p in self.metrics_data.values())
total_engagement = sum(p.get('total_engagement', 0) for p in self.metrics_data.values())
avg_engagement_rate = round(total_engagement / total_posts, 2) if total_posts else 0
return {
'total_posts': total_posts,
'avg_engagement_rate': avg_engagement_rate,
'platforms_active': len(self.metrics_data)
}
def get_top_posts(self, count=10):
all_posts = []
for platform, data in self.metrics_data.items():
posts = data.get('posts', [])
for post in posts:
post['platform'] = platform
all_posts.append(post)
return sorted(all_posts, key=lambda x: x.get('engagement_rate', 0), reverse=True)[:count]
def get_recommendations(self):
return self.metrics_data.get('insights', {}).get('content_recommendations', [])
# Usage:
dashboard = MyAIAnalytics()
dashboard.connect_platform('twitter', {'api_key': 'xxx'})
dashboard.connect_platform('instagram', {'access_token': 'xxx'})
metrics = dashboard.fetch_all_metrics(date_range=30)
insights = dashboard.analyze_all_data()
print(insights[0:3])
dashboard.generate_weekly_report()
print("✅ Analytics dashboard complete!")
Stack side-note: I plugged in Azure GPT-4.1 for insight gen, Claude Sonnet for summaries, local Ollama for fast protos. Playwright+CDP scrapes where APIs suck. The whole thing sits on a 79-tool MCP microserver backend, same omni-bridge I use at axon.nepa-ai.com.
Core Features
- All-platform metrics, actually organized
- LLM-driven insights—real red flags, not just “your reach went up”
- Auto-highlights best content, what to post next, when, and why (with numbers)
- Compares public metrics with competitors, if you want
What I Actually Track
You can ignore vanity metrics. I pull just:
- Engagement rate
- Comments quality (LLM-sorted)
- Shares/saves
- Click-throughs
- Average watch/read time
And audience stuff:
- Growth rate
- Demographics
- Retention
And: content/top format breakdowns, best times, topics.
What Changed
Before: Losing 3–4 hours a week in dashboards, still missed obvious trends.
After: I spend five minutes, know exactly what worked, and my content performance is up 40% (organic). More time to ride, less time clicking around.
Build Your Own (Quickstart)
- Day 1: Setup. Pull credentials, spin up server, connect platforms. (1 hour)
- Day 2: First data pull, raw numbers in a single table. (30 min)
- Day 3: AI insights + report auto-generation. (30 min)
Want it for your stack? Go see the real thing: axon.nepa-ai.com
