Python in Digital Analytics: Automating Facebook metric reports
I am very happy to come back to this topic, after started this blog by writing about Facebook metrics 6 months ago.
Just a little side note – I used to code a lot at 16 years old – never found much fun and gave up once I made it to college. Ironically, this time I had a lot of joy learning Python to connect to Facebook API for “insights” in the past few months.
The business case here is straightforward: We need to understand how we are doing in social media channel from the metrics perspective. As I addressed in my previous post, the data exporting feature of Facebook business manager is simply not good enough.
Using Python, I was able to directly call Facebook’s Graphic API, and retrieve the metrics – impressions, likes, shares, comments, link clicks etc – of each individual posts as far as 2 years ago, to a CSV file. Then I can port it with Microsoft PowerBI and do all kinds of analysis and visualization.
What I like this the most, is by having this Python code in place, I can bypass the traditional “Extract, Transform and Load” process of using the data warehouse. As a proud “full stack” analyst, I want my “data to insights” journey as simple as possible. Also, I can’t afford the typical 1 day of delay (of data warehousing), as a social media post can go viral and suddenly receive 100 “likes” in 4 hours.
Now let me explain how it works in a bit more geeky way…