Using Facebook's Graph API Explorer to retrieve Insights data
Published April 11th, 2014, updated February 15th, 2022
Summary - Quickly learn how to use Facebook's Graph API Explorer to retrieve Insights data from your page. Check out this step-by-step tutorial, designed for beginners.
A few years ago, the mere mention of the term "API" would send most marketers running to their development team. These days APIs are an accepted part of the marketing vocabulary and a sought after skill, especially amongst the growth hacking crowd. But why are APIs so popular?
The answer is that knowledge of APIs provides unparalleled access to the web services you use on a daily basis. For developers, this means creating applications that seamlessly integrate with services such as Facebook. For marketers, a basic knowledge of APIs can open doorways to growth hacking tactics, like the one AirBNB used to grow their business, or grant access to data and insights from your online marketing campaigns, like we're going to do in this tutorial.
Tutorial: Using Facebook's Graph API Explorer to retrieve Page Insights data
In this tutorial, we're going to use Facebook's Graph API Explorer to retrieve Insights from Facebook pages you manage. In the world of APIs, an "API Explorer" is an interface that helps you craft a request URL. This URL is a like a command line that tells Facebook to do something on your behalf. For instance, performing a GET request to pull data from your Facebook profile.
I recommend that you open the Graph API Explorer in another window so you can follow along.
Step 1: Navigate to Facebook Developer Website
Navigate to https://developers.facebook.com/tools/explorer
By default, your profile name and profile ID will be displayed in the explorer panel.
Step 2: Set up your Access Token
You will need to create an Access Token with "read_insights" permission associated with it.
- Click the Get Access Token button.
- Under Extended Permissions, select Read Insights.
- When complete, click the Get Access Token button when complete.
Step 3: Using the explorer panel
The explorer panel allows you see different items associated with your Facebook account. By default, you will see your profile ID. When an item is selected from the panel, the panel will update to show information about child elements and it will update the request URL.
- Select your profile ID. It is a clickable link within the explorer panel.
The Request URL is updated.
Step 4: Viewing Page information
You can access information on any Facebook Page for which you are a manager. To do this, type the name of your Page in the URL field. For instance, our Facebook Page is https://www.facebook.com/Klipfolio so we'd type /Klipfolio.
- Type the name of your Facebook Page into the URL request field.
- Click the Submit button.
Step 5: Viewing Page Insights
You can access Page Insights by typing /insights after the name of your page in the URL field. This command will retrieve all of the Insights associated with your Page.
- Type "/insights" after your company name.
- Click the Submit button.
Step 6: Viewing specific Insights
The basic "/insights" command will pull a large data file which contains every insight about your Page. In most cases, it's preferable to request a single Insight, such as "Unique page fan adds."
- Scroll through the explorer panel to locate the Insight you want to retrieve.
- Click on the "id" of that Insight.
Step 7: Putting the query to use
The request URL is now set to retrieve a very specific insights. If you're a Klipfolio user, you can grab this query to create a data visualization (we'll show you how below).
Next steps: Integrated and automated with Klipfolio
If you completed the steps above, you will have a request URL that can be used to retrieve a specific Page Insights, such as the number of fan adds per day. In fact, as long as you have a way to authenticate using OAuth, you can use this request URL in other 3rd party services. What's important about the integration with Klipfolio is that your authentication credentials will be passed automatically with your request URL.
The other benefit of using this request URL in Klipfolio is that the data source will automatically refresh. This means that any visualizations using this data will always display the most current data from Facebook. Very handy if you're building a real-time social media dashboard.
Check out our documentation: Using Facebook as a data source
Modifying the request URL in Klipfolio
By default, many request URLs will only retrieve data for a set or limited period of time. For example, the daily fan adds request will retrieve data for the past 3 days. When it comes to building a visualization, it's helpful to have a bit more data over a well-defined time period. Within Klipfolio, you have the ability to modify the request URL to retrieve data over a period of time of your choosing. Here's a quick overview of how to works.
Adding date parameters to the request URL
Let's say this is your URL:
You can change the time period by adding query parameters to the URL. Typically, query parameters are specified after a "?"
The specific parameters you can use will look like this. For the start date:
And for the end date:
Now when you use this request URL, you will retrieve metrics for the past 30 days up to and including today's date.
For more information, check out this article: Using date range parameters
Conclusion: Why learning APIs is important
I'm going to honest: learning APIs is heavy stuff. But it's well worth it in the end. This article tackles using APIs in social media analytics, although this barely scratches the surface of what you can do with APIs.
A powerful example is the ability to integrate and mashup data from multiple services in one place. For instance, pulling together Google Analytics data, Twitter data, email marketing data along with Facebook Insights to uncover deeper relationships between marketing campaigns. Learn how Klipfolio turns your data into insight.
The Starter Guide to Metrics
By Emily Hayward — June 22nd, 2022
Klipfolio's Jon Taylor: Is the MQL right for my business?
By Emily Hayward — April 1st, 2022
With so much data out there, why is there so little trust?
By Allan Wille, Co-Founder — March 23rd, 2022
What are HubSpot lifecycle stages?
By Jonathan Taylor — March 14th, 2022