Importing Insights Data into Google Sheets

This guide shows how to import insights data from the ClearFeed API into Google Sheets using Google Apps Script.

Prerequisites

Overview

You will:

  1. Open a Google Sheet and add a bound script

  2. Use Apps Script to call the ClearFeed API

  3. Populate the sheet with data from the API

Step-by-Step Instructions

1. Open the Script Editor

In your Google Sheet:

  • Go to Extensions > Apps Script

2. Add the Script

Replace the default code with the following. The script below populates a simple report based on the example in the Insights API Documentation Documentation. It can be tailored to your requirements subsequently:

3. Replace the Token

Replace the line:

With your actual ClearFeed API token.

4. Run the Script

  • Save the script.

  • Click the ▶️ Run button

  • Authorize the script when prompted

Result

After running, your sheet will be populated with insights data like:

Requests.priority
Requests.created_at.day
Requests.count
Requests.first_response_time_avg

normal

2025-05-13T00:00:00.000

1

87.0000000000000000

high

2025-05-18T00:00:00.000

1

240.0000000000000000

Notes

  • The script clears the sheet each time before writing new data

  • If no data is returned, the message "No data found" is placed in cell A1

  • The script writes all keys from the API response as column headers

Optional: Automate with a Trigger

To run this automatically (e.g. daily):

  1. Open the script editor

  2. Click the clock icon ("Triggers")

  3. Add a trigger for fetchClearfeedInsights

  4. Choose "Time-driven" and select your schedule

API Token Security Reminder

For convenience, this example uses a hardcoded API token. In production or multi-user environments, consider using secure methods such as PropertiesService or Google Secrets Manager.

Support

For help with API queries or customizations, reach out to ClearFeed Support ([email protected]).

Last updated