How to extract Facebook page likes history by countries to Excel
In this tutorial,I will show you how to extract any public Facebook page likes history to Excel.For example, how many fans did page X have 5 months ago and the countries of the fans.
Let’s get started
Getting Facebook page likes history by countries using Graph API
Step 1:Get access Token from the Facebook Graph API explorer
In order to retrieve Facebook data through their Graph API, we must get an access token from the Facebook Graph API explorer.The access token is a special key which the app uses to call the Graph API on behalf of you the user.
The Graph API is the primary way to get data in and out of the Facebook platform.The Graph API Explorer is a tool which makes it really easy to use and traverse the Facebook Graph.
To get an access token open Facebook Graph API explorer and log in using your Facebook account(if you are not logged in) otherwise (if you are already logged in) you will see an interface as shown in the window below.
You will see the access token (see the red rectangular box below) already generated for you. Copy and paste it to store safely somewhere because we will need it in the later steps.
The access token is valid for a certain period of time normally like 1 hour or 2 then it expires.If it expires you need to get a new one by clicking “Get Token”
Step 2:Check Facebook page likes history by countries
We will use Facebook Insights API to check Facebook page likes history.As per Facebook “the Insights API only offers two years data retention. Insights data older than two years is subject to removal”.
Now it is time to check Facebook page likes history by countries.We can get the data using the following query which will return data in JSON format.Then we will convert the JSON data to CSV or Excel for easy analysis.The query can only return data for not more than 93 days duration otherwise, it will return an error “Time range too long”.
The query will return lifetime aggregated Facebook location data, sorted by country, about the people who like your Page (Unique Users).
Replace the bolded text with your info.
For example, I want to get Barack Obama Facebook page likes history by countries
His page name is barackobama
I want to get data since=2016-06-01 until=2016-09-02 (Total 93 days:2016-09-02 not included)
My query will be like below
And below is a screenshot of the results I got on my browser in JSON format.Copy all the results in a text editor as we will convert them to CSV/Excel in the coming step.You can convert the countries abbreviations to full names by referring to this website.
You can get next set of results by copying the URL after the previous or next text and pasting the URL into the browser.Do make sure to copy the result into a text editor.You can do repeatedly until you collect enough data or all the data(only 2 years back data available from the current time).
Step 3:Converting JSON to Excel
There are many free web-based tools to convert JSON to Excel.In this tutorial, I will use this website for conversion.Go to their website and paste the JSON obtained in the previous step like below image.And the page will automatically start converting.
Another window will open up with your data already in CSV ready to be downloaded to your computer.Click the “Download” button.
You can clean the Excel sheet by converting the countries abbreviations to full country names.You will have something similar to below image.
You can extract more interesting data from Facebook please check below tutorials.
If you have any problem please let me know in the comments below.