Search API Connector Documentation

Print

Import Spotify Ads Data to Google Sheets

premium

In this guide, we’ll walk through how to pull Spotify Ads data directly into Google Sheets, using the API Connector add-on for Sheets.

Contents

Before You Begin

Click here to install the API Connector add-on from the Google Marketplace.

Part 1: Get OAuth Credentials

A preset Spotify connector is currently in development, and can be used instead of getting your own OAuth credentials. For beta access please message support.

Spotify Ads uses OAuth, which means we need to set up an “app” through their developers console.

  1. While logged into Spotify, navigate to https://developer.spotify.com/dashboard/applications and click Create An App
    spotifyads-createapp
  2. You’ll be prompted to give your app a name and description. Click Create
    spotifyads-create
  3. You’ll now be in the main apps dashboard. Click Edit Settings.
    spotifyads-editsettings
  4. Under Redirect URLs, enter https://script.google.com/macros/d/12COOkin8nodCH7fZGIBu0D2jWY8-AEA0uvElt4Ph4wRbLUD4wslqQUfG/usercallback.
    spotifyads-redirect
  5. Scroll down and click Save.
  6. On the left you’ll see your client ID and secret, copy those down as we’ll need them in a moment.
    spotifyads-clientid

Part 2: Set up Custom OAuth Connection

  1. Back in Google Sheets, navigate to Extensions > API Connector > Manage Connections
  2. Scroll down to the Custom Connections section and click Add Custom OAuth
    spotifyads-custom
  3. In the Custom OAuth Manager, enter and save the following:
    • Name: Spotify Ads
    • Authorization Base URL: https://accounts.spotify.com/authorize?scope=streaming
    • Token URL: https://accounts.spotify.com/api/token
    • Client ID: enter the value from the developer console
    • Client Secret: enter the value from the developer console
      spotifyads-oauthmanager
  4. Click Manage Connections to return to the Connections screen. Scroll down and you should see your new connection listed. Click Connect
    spotifyads-customconnect
  5. You’ll be prompted to approve the connection. Click Agree
    spotifyads-agree
  6. You’ll be redirected into your Google Sheet and can verify that the connection is now active.

Part 3: Pull Spotify Ad Data into Sheets

We’re now ready to fetch some data from the Spotify Ads API into Google Sheets. Open up Google Sheets and click Extensions > API Connector > Open > Create Request, and enter the following:

  • Method: POST
  • Request URL: https://api-partner.spotify.com/ads/v1.3/report
  • OAuth: Spotify Ads
  • Headers: Key = Content-Type, Value = application/json, Key = Accept, Value = application/json
  • Request body: {"filters":{"report_datetime_range":{"report_start":"2022-01-24T00:00:00Z","report_end":"2022-08-24T00:00:00Z"}},"dimensions":["CAMPAIGN"],"fields":["IMPRESSIONS","SERVE_REACH","SERVE_FREQ","SPEND","CLICKS","CTR","FIRST_QUARTILES","THIRD_QUARTILES","MIDPOINTS","COMPLETES"]}

For more available metrics and breakdowns, please check the documentation.

Part 4: Flatten Fields to Headers

By default, Spotify’s API sends back data where field headers are in one column and field values are in the next. To convert those field headers into column titles, you can flatten fields to headers, like this:

  • path to header: page.rows.fields.type
  • path to value: page.rows.fields.value

While you’re at it, select “Truncate headers” to clean up the titles even further. The end result should look like this:

Part 5: API Documentation

Official API documentation: https://developer.spotify.com/documentation/ads-api/reference/#/operations/get_report

Previous Import Spotify Data to Google Sheets
Next Import Strava Data to Google Sheets

Leave a Comment

Table of Contents