Last Updated on March 21, 2025 by Rajeev Bagra
Introduction
Tracking daily, weekly, and monthly growth trends across websites and social media platforms is crucial for measuring marketing success. Your manager needs concise and valuable reports that highlight:
✅ New likes, followers, and subscribers
✅ Website traffic trends
✅ Engagement growth per platform
✅ Comparison of current vs. previous periods
✅ Actionable insights & AI-powered recommendations
This article expands on our Watsonx AI-powered content automation system by integrating trend reporting with daily, weekly, and monthly insights.
1️⃣ Data Collection: Tracking Daily, Weekly & Monthly Trends
We’ll extend our previous website & social media tracking system to collect:
- Daily Growth (new followers, likes, website visitors)
- Weekly Comparison (current vs. last week)
- Monthly Trends (growth over time)
Step 1: Store Data in a Database
To track long-term trends, we store daily statistics in an SQLite database.
Install SQLite Library
pip install sqlite3 pandas
Create a Database & Store Data
import sqlite3
import datetime
# Connect to SQLite database
conn = sqlite3.connect('social_media_stats.db')
cursor = conn.cursor()
# Create table if not exists
cursor.execute("""
CREATE TABLE IF NOT EXISTS stats (
date TEXT,
platform TEXT,
likes INTEGER,
followers INTEGER,
visitors INTEGER
)
""")
# Insert new data (example)
today = datetime.date.today().strftime('%Y-%m-%d')
cursor.execute("INSERT INTO stats VALUES (?, ?, ?, ?, ?)", (today, "Twitter", 50, 10, 0))
conn.commit()
conn.close()
✅ This ensures that historical data is stored for trend analysis.
2️⃣ Generating Daily, Weekly & Monthly Reports
Step 2: Calculate Growth Trends
We extract daily, weekly, and monthly statistics to track progress.
Fetch & Compare Data
import pandas as pd
# Fetch data from the database
conn = sqlite3.connect('social_media_stats.db')
df = pd.read_sql_query("SELECT * FROM stats", conn)
conn.close()
# Convert date column to datetime
df['date'] = pd.to_datetime(df['date'])
# Filter last 7 days
weekly_data = df[df['date'] >= (df['date'].max() - pd.Timedelta(days=7))]
# Aggregate trends
weekly_trends = weekly_data.groupby('platform').sum().reset_index()
print("Weekly Growth Trends:\n", weekly_trends)
✅ This script generates a concise weekly report with likes, followers, and visitors per platform.
3️⃣ AI-Powered Trend Analysis & Recommendations
Watsonx AI can analyze the trends and provide smart insights for managers.
Step 3: Generate AI-Driven Insights
We use IBM Watson Natural Language Processing (NLP) to generate summarized reports.
Install IBM Watson SDK
pip install ibm-watson
Generate AI Insights Based on Data Trends
from ibm_watson import NaturalLanguageUnderstandingV1
from ibm_watson.natural_language_understanding_v1 import Features, SentimentOptions
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
API_KEY = "YOUR_NLU_API_KEY"
NLU_URL = "YOUR_NLU_SERVICE_URL"
authenticator = IAMAuthenticator(API_KEY)
nlu = NaturalLanguageUnderstandingV1(version="2023-03-15", authenticator=authenticator)
nlu.set_service_url(NLU_URL)
def analyze_trend(trend_text):
response = nlu.analyze(text=trend_text, features=Features(sentiment=SentimentOptions())).get_result()
return response['sentiment']['document']['label']
# Generate a summary text
trend_text = f"Twitter gained {weekly_trends['followers'][0]} new followers this week."
sentiment = analyze_trend(trend_text)
print(f"AI Insight: The sentiment of the current trend is '{sentiment}'.")
✅ This AI-driven trend report provides sentiment analysis to highlight growth performance.
4️⃣ Automated Daily, Weekly & Monthly Reports for Managers
We automate reports via email or dashboard.
Step 4: Send Daily Reports via Email
Install Email Library
pip install yagmail
Send AI-Powered Reports to Your Manager
import yagmail
# Email Configuration
EMAIL_USER = "your_email@gmail.com"
EMAIL_PASS = "your_password"
yag = yagmail.SMTP(EMAIL_USER, EMAIL_PASS)
def send_report():
subject = "📊 AI-Powered Social Media Report - Weekly Trends"
body = f"""
Weekly Growth Insights:
- Twitter gained {weekly_trends['followers'][0]} new followers.
- Website visitors increased by {weekly_trends['visitors'][0]}.
- Overall engagement is trending {sentiment}.
AI-Powered Recommendation:
Post more content on Twitter between 12PM - 3PM for better reach.
"""
yag.send(to="manager@example.com", subject=subject, contents=body)
send_report()
✅ This script automatically emails weekly insights & AI-driven recommendations.
5️⃣ Dashboard for Visual Reports
For a real-time overview, we use Streamlit to build an AI-powered dashboard.
Step 5: Install Streamlit
pip install streamlit matplotlib seaborn
Step 6: Create a Live AI Dashboard
import streamlit as st
import seaborn as sns
import matplotlib.pyplot as plt
# Title
st.title("📊 AI-Powered Social Media Trends")
# Display Data
st.dataframe(weekly_trends)
# Plot Growth Trends
fig, ax = plt.subplots(figsize=(8, 5))
sns.barplot(x=weekly_trends['platform'], y=weekly_trends['followers'], ax=ax)
st.pyplot(fig)
✅ This provides a visual report with AI-powered insights on engagement trends.
Final Features Recap 🚀
✅ Daily, Weekly, & Monthly Tracking of Likes, Followers, and Website Traffic
✅ AI-Powered Sentiment & Growth Analysis
✅ Automated Email Reports for Managers
✅ Real-Time Dashboard for Insights
✅ AI Recommendations for Content Strategy
Discover more from Aiannum.com
Subscribe to get the latest posts sent to your email.
Leave a Reply