Marketing Automation
email marketing
How to Build an Automated Email Performance Dashboard
Track open rates, clicks, and revenue from email in a live dashboard.
Jay Banlasan
The AI Systems Guy
I built this automated email marketing dashboard to stop pulling reports manually every Monday. It tracks open rates, clicks, and revenue from email in a live view that updates itself.
The numbers that matter, updated automatically, in one place.
What You Need Before Starting
- Python 3.8+ with Flask
- ESP API key (Mailchimp, ConvertKit, or similar)
- SQLite for data storage
Step 1: Pull Campaign Data
import requests
from datetime import datetime
def pull_campaign_data(api_key, server):
url = f"https://{server}.api.mailchimp.com/3.0/campaigns"
response = requests.get(url, auth=("x", api_key), params={"count": 50, "status": "sent"})
results = []
for c in response.json().get("campaigns", []):
report = requests.get(f"https://{server}.api.mailchimp.com/3.0/reports/{c['id']}", auth=("x", api_key)).json()
results.append({
"id": c["id"], "subject": c["settings"]["subject_line"],
"sent": report.get("emails_sent", 0),
"opens": report.get("opens", {}).get("unique_opens", 0),
"clicks": report.get("clicks", {}).get("unique_clicks", 0),
})
return results
Step 2: Store in Database
import sqlite3
db = sqlite3.connect("email_dashboard.db")
db.execute('''CREATE TABLE IF NOT EXISTS campaigns (
id TEXT PRIMARY KEY, subject TEXT, sent INTEGER,
opens INTEGER, clicks INTEGER, fetched_at TEXT
)''')
def save(campaigns):
for c in campaigns:
db.execute("INSERT OR REPLACE INTO campaigns VALUES (?,?,?,?,?,?)",
(c["id"], c["subject"], c["sent"], c["opens"], c["clicks"], datetime.now().isoformat()))
db.commit()
Step 3: Build the Dashboard
from flask import Flask, render_template_string
app = Flask(__name__)
@app.route("/")
def dashboard():
rows = db.execute("SELECT * FROM campaigns ORDER BY fetched_at DESC LIMIT 20").fetchall()
html = "<h1>Email Dashboard</h1><table border=1>"
html += "<tr><th>Subject</th><th>Sent</th><th>Opens</th><th>Rate</th><th>Clicks</th></tr>"
for r in rows:
rate = f"{r[3]/r[2]*100:.1f}%" if r[2] else "0%"
html += f"<tr><td>{r[1]}</td><td>{r[2]}</td><td>{r[3]}</td><td>{rate}</td><td>{r[4]}</td></tr>"
return html + "</table>"
Step 4: Schedule Updates
# Cron: pull fresh data every morning
0 6 * * * cd /app && python pull_data.py
What to Build Next
Add revenue attribution by connecting your payment processor. Knowing which emails drive sales changes your entire strategy.
Related Reading
- AI for Email Marketing Automation - how AI transforms email marketing operations
- Building a Reporting Dashboard from Scratch - making AI reports that drive real action
- Creating Automated Email Sequences That Convert - how AI transforms email marketing operations
Want this system built for your business?
Get a free assessment. We will map every system your business needs and show you the ROI.
Get Your Free Assessment