Import Instagram Data to Google Sheets
In this guide, we’ll walk through how to pull Instagram Insights data data directly into Google Sheets, using the API Connector add-on for Sheets. We’ll be connecting using API Connector’s built-in OAuth2 integration for Instagram Insights (this is a paid feature, please upgrade to access).
Note that to use the Instagram Insights API, you must have an Instagram Business account that is connected to a Facebook Page, and you must be an admin of that Facebook page. If you need help, this guide provides information on converting your personal Instagram account to a business account.
- Part 1: Connect to the Instagram Insights API
- Part 2: Create your Instagram API Request URL
- Part 3: Pull Instagram API Data into Sheets
- Part 4: Example API URLs
PART 1: CONNECT TO THE INSTAGRAM INSIGHTS API
If you haven’t connected to the Instagram Insights API before, you’ll first need to initiate the connection.
- Open up Google Sheets and click Add-ons > API Connector > Manage Connections.
- In the list of available connections, find Instagram Insights and click Connect.
- You will be directed to Facebook and asked to choose which Instagram accounts and Facebook Pages you’d like to use with API Connector. If you are an admin of multiple accounts, make sure to choose the Instagram account and Facebook page that you’ve previously linked together. Click Done.
- You’ll then be returned to your Google Sheet, and can verify that your Instagram Insights connection is active in the Connections screen.
PART 2: CREATE YOUR INSTAGRAM API REQUEST URL
For our first request, we’ll get some basic information about your Instagram account.
- API root: https://graph.facebook.com
- Endpoint: /v8.0/me/accounts
Putting it all together, we get the full API Request URL.
PART 3: PULL INSTAGRAM API DATA INTO SHEETS
We can now enter our values into API Connector and start importing Instagram data into Google Sheets.
- Back in the Create Request interface, enter the Request URL we just created above.
- You don’t need any headers so just leave that section blank.
- Under Authentication, choose Instagram Insights from the dropdown menu.
- Create a new tab and click ‘Set current’ to use that tab as your data destination.
- Name your request and click Run. A moment later you’ll see some information about your Instagram account populate your sheet. Pay special attention to the value located in the
data » idfield as you’ll need it in the next request.
- Now let’s use that ID to get your Instagram Business account ID, because we’ll need that for all requests to the /insights endpoint, which is what we’re here for! In a new request, create an API URL like this, substituting in your own data ID.
- Just as you did before, choose Instagram Insights from the Authentication menu (you’ll need to do this for all requests to the Instagram API) and click Run.
You should now see your Instagram Business account ID printed into the sheet. Keep this handy, we’ll use this ID to get all our Instagram stats!
PART 4: EXAMPLE API URLS
You can access the Instagram Insights documentation here (and the full list of available Instagram metrics with their compatible time periods here), but if you just want to get started, you can try the following example URLs, substituting in your own business account ID.
- Impressions and reach for your Instagram account, for the past 28 days. (Note that the Instagram Graph API returns 2 sets of values, one for the period ending today, and one for the period ending yesterday.)
- Users who have viewed your Instagram business account in the last day.
- A breakdown of cities where your Instagram followers are located
- Count of new followers from the prior day
- Metrics by day for a date range (the “since” and “until” parameters contain the start and end dates)
If you want to make a dynamically updating date range, add a dynamic date formula like
=today()-1to one cell, add a second cell that converts it to UNIX with the
=(A1-DATE(1970,1,1))*86400formula, and then reference that UNIX timestamp in your API request URL. Every time the date changes, your URL will update automatically.