← Back to projects

X Engagement Analytics Platform

A role-based dashboard I built so a manager could see how their social media team was performing and how each person's activity was landing on the account: daily activity per colleague, tweet engagement, and account growth, all on Flask and MySQL.

  • Team Analytics
  • Flask
  • MySQL
  • Chart.js
  • Docker
  • Caddy
  • Tampermonkey

Overview

A manager responsible for running a social media team wanted a way to see how each person was performing, and how the activity of the team was affecting account growth.

I built a role-based dashboard to solve that problem: each member of the team uses userscript in their browser which logs their activity, a Flask/MySQL backend stores it, and the dashboard turns the stored data into account-level views that the manager can use.

Figure 1: How the data moves, from browser to injecting to dashboard

Collecting the data

A userscript injected into X using Tampermonkey handles the logging. As team members use X, it intercepts network requests and tweet content and logs replies they make and tweet engagement. Everything is sent to the backend using a GM_xmlhttpRequest which is authenticated with an API key, unique to each team member.

Backend and database

The backend features two Flask APIs connected with a MySQL database.

One manages data collection, ingesting collected data from the userscript into a MySQL database. Tables keep a record of liked tweets, tracked tweets, sent tweets, engagement snapshots, follower snapshots, API keys, and accounts.

The second is the dashboard: role-based access requiring user authentication, serving Jinja2 templates with plots using Chart.js with different views depending on the role.

Two standalone scripts regularly poll X's API to capture trends of follower counts and track engagement of specified tweets.

A role-based dashboard for the team

The dashboard uses an inheritance based role system: 'senior' can do everything 'admin' can do, who can do everything a 'user' can. Each role has a unique view.

User

Team members with the 'user' role can see how many tweets they've liked and replies to each day over the last week.

Admin

Admins have four KPIs on the home page: Follower count and the change over the last week, amount of likes and replies today, and total tweets tracked for engagement. A follower trend chart that can switch between a monthly overview and all-time.

A tweet tracking page lets admins track the engagement that a tweet gets over time, and has a table which displays everything that has previously been tracked, untrack tweets, or click into a row for its engagement trend over time.

The /likes and /replies pages go a step further, displaying all-time totals per team member, a 14 day stacked barchart view across the team, and per-member charts that switch between the last 7, 14, or 28 days.

Admins can also onboard a new team accounts and export the database as CSV files, which can be manipulated further.

Senior

Seniors can see how often the team has hit X's rate limits, change anyone's role, and create new admin accounts.

Deployment

The stack runs as three Docker containers: A MySQL 8 database, a Gunicorn Flask app, and a Caddy 2 webserver offering reverse proxy and automatic HTTPS.

Business Impact

Plotting engagement, tweets liked and replies sent, against follower growth showed the manager which day-to-day habits actually brought in new followers. The team could then put more time into those and less into everything else.

It wasn't only about the follower count: more engagement puts the account in front of more people, and some of those people go on to become customers. Seeing that link between team activity and account growth gave the manager a real basis for deciding where the team's time went.

Screenshots

Click to enlarge.

User role view showing an individual's likes and replies over the last week
Admin Dashboard: KPIs, follower trend, and per-member engagement breakdown
Admins can manage which tweets are tracked for engagement
Team-wide likes breakdown
Team-wide replies breakdown
Dashboard scales up for desktop view