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.

CONTENTS

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.

  1. Open up Google Sheets and click Add-ons > API Connector > Manage Connections.
  2. In the list of available connections, find Instagram Insights and click Connect.
    instagram-img2
  3. 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.
    instagram-img3
  4. You’ll then be returned to your Google Sheet, and can verify that your Instagram Insights connection is active in the Connections screen.
    instagram-img4

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.

https://graph.facebook.com/v8.0/me/accounts

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.

  1. Back in the Create Request interface, enter the Request URL we just created above.
    instagram-img1
  2. You don’t need any headers so just leave that section blank.
  3. Under Authentication, choose Instagram Insights from the dropdown menu.
    instagram-img5
  4. Create a new tab and click ‘Set current’ to use that tab as your data destination.
  5. 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 » id field as you’ll need it in the next request.
    instagram-img6
  6. 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.
    https://graph.facebook.com/v8.0/YOUR_DATA_ID?fields=instagram_business_account
  7. 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!
    instagram-img7

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.)
    https://graph.facebook.com/v8.0/YOUR_BUSINESS_ACCOUNT_ID/insights?metric=impressions,reach&period=days_28
    instagram-img8
  • Users who have viewed your Instagram business account in the last day.
    https://graph.facebook.com/v8.0/YOUR_BUSINESS_ACCOUNT_ID/insights?metric=profile_views&period=day
  • A breakdown of cities where your Instagram followers are located
    https://graph.facebook.com/v7.0/YOUR_BUSINESS_ACCOUNT_ID/insights?metric=audience_city&period=lifetime
    instagram-img9
  • Count of new followers from the prior day
    https://graph.facebook.com/v8.0/YOUR_BUSINESS_ACCOUNT_ID/insights?metric=follower_count&period=day
  • Metrics by day for a date range (the “since” and “until” parameters contain the start and end dates)
    https://graph.facebook.com/v7.0/YOUR_BUSINESS_ACCOUNT_ID/insights?metric=impressions,reach,profile_views&period=day&since=1577836800&until=1580428800
The Instagram Insights API requires dates to be entered as UNIX timestamps. In Sheets, you can convert a regular date in cell A1 to a UNIX timestamp with the formula =(A1-DATE(1970,1,1))*86400.

If you want to make a dynamically updating date range, add a dynamic date formula like =today()-1 to one cell, add a second cell that converts it to UNIX with the =(A1-DATE(1970,1,1))*86400 formula, and then reference that UNIX timestamp in your API request URL. Every time the date changes, your URL will update automatically.

4 thoughts on “Import Instagram Data to Google Sheets”

  1. I’m lost on what I’m supposed to do on Step 6 to Step 7. There were no instructions on what to click and where going to Step 7. Thanks.

    Reply
    • Oh yeah, I didn’t mention that you need to click “Run” to make the request run. I’ll update the article to make that clearer!

      Reply
  2. Hi, I love this tutorial and it looks it can open one big universe how to get to data from IG and FB. I have troubles with running any requests with metrics, tho. I am able to run the list of the accounts but that’s where I got stuck.

    Once I try to run some metrics request you mentioned above (eg. this one: https://graph.facebook.com/v7.0/380044348695678/insights?metric=audience_city&period=lifetime) , it shows error and nothing happens:

    Request failed: Server responded with an error (400) show response
    {“error”:{“message”:”(#100) The value must be a valid insights metric”,”type”:”OAuthException”,”code”:100,”fbtrace_id”:”AY7XDeLA7BrDwu8TnCJ_Qrp”}}

    Any recommendation what to do?

    Reply
    • Hi Sarka, thank you for the message. I’m not sure why you’re seeing that error, I just went through all the above steps again to test if anything had changed, and didn’t run into any problems. Can you please send me a screenshot of your full request setup in API Connector so I can check if anything looks off?

      Reply

Leave a Comment