API Connector Documentation
Import Snapchat Ad Data to Google Sheets
In this guide, we’ll walk through how to import Snapchat Ads data directly into Google Sheets, using the API Connector add-on for Sheets. This article also serves as an example of how to set up a custom OAuth connection.
Contents
- Before You Begin
- Part 1: Get Your Snapchat OAuth Credentials
- Part 2: Connect the Snapchat Marketing API to API Connector
- Part 3: Get Snapchat Ad Data in Sheets
- Part 4: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Get your Snapchat OAuth Credentials
- Log in to Ads Manager.
- Click the Manage Ads menu in the top corner and select Business Details.
- Scroll down and click +OAuth App
- Agree to the terms and conditions.
- You'll be asked to give your app a name and a redirect URL. You can name your app anything, but make sure to use the redirect URL provided in this article.
- Click through and you'll be presented with your Client ID and Secret. Copy these down, we'll need them shortly.
Part 2: Connect Snapchat to API Connector
- Open up Google Sheets and click Extensions > API Connector > Manage Connections
- Scroll to the bottom of the sidebar and click Add Custom OAuth
- Fill in the Custom OAuth modal like this:
- OAuth Grant Type:
Authorization Code
- Name:
Custom Snapchat
- Authorization Base URL:
https://accounts.snapchat.com/login/oauth2/authorize?scope=snapchat-marketing-api
- Token URL:
https://accounts.snapchat.com/login/oauth2/access_token
- Client ID: provided by Snapchat
- Client Secret: provided by Snapchat
- OAuth Grant Type:
- Click Save
- Click Manage Connections to return to the list of connections
- Scroll down until you find your new custom connection. Click Connect
- You'll be prompted to give access to the new app you created above. Click Continue.
- You'll be returned to your sheet and can verify that the new connection is now active.
Part 3: Get Snapchat Ad Data in Sheets
To create a request, include your full request URL in the request URL field, and select your custom Snapchat connection from the dropdown OAuth menu.
You can see the full list of available request URLs in the API documentation. For example, to get your organization ID, run a request to https://adsapi.snapchat.com/v1/me/organizations
Pay attention to your organization ID as you'll need that for subsequent requests, e.g. get your ad account IDs by plugging it into https://adsapi.snapchat.com/v1/organizations/your_org_id/adaccounts
Part 4: API Documentation
Official API documentation: https://marketingapi.snapchat.com/docs/
The documentation provides all the URLs that you can plug into API Connector's request URL field, for example here's their listing of the /adaccounts
URL from the above example.
Hi Ana, thanks for the prompt action. Really appreciate it. Can you also guide us in pulling spends, clicks, campaign names the same way you did in your fb and google guides? I think they are called endpoints as well. Thanks in advance.
Sorry to abuse my requests. Just requesting for another one so I can get the reply in one go. With my above request can you also check if we can extract spends, clicks, campaign names, impressions, cpc, etc and using a custom date range so i can use your importapi function with it. The same way I did with google. So sorry for the trouble.
Unfortunately I don't have an ads account so I can't test anything but you can click on the relevant endpoints in the documentation's /measurement section and try out their example URLs. Here's their example of how to get data by campaign, I've just slightly modified it and removed a few of the fields you aren't interested in:
https://adsapi.snapchat.com/v1/campaigns/2bbaa6e3-4ddb-4358-9efe-48334952f4aa/stats?breakdown=ad&fields=frequency,impressions,spend,swipes,view_completion,video_views&granularity=DAY&start_time=2022-10-24T07:00:00.000-00:00&end_time=2022-10-26T07:00:00.000-00:00
It looks like they only send back data for one campaign at a time so you need to run a separate request for each campaign ID. One approach would be to construct your full set of URLs in your sheet, one for each campaign ID, then cycle through the whole list with a cell reference like+++Sheet1!A1:A10+++
By the way, you don't need IMPORTAPI to use a custom date range, you can do that in the sidebar (this article has an example).
Thank you so much ana for the clarification. So snapchat doesn't have an endpoint to get all the campaign spends per ad account? It always need to be in the campaign level?
By any chance, can you please check what endpoint are they using here to pull all campaign stats per ad account in one go?
Hey Lixx, I don't see an endpoint for campaign data per ad account, do you? You can use the multi-query method to loop through all the campaign IDs at once, so setup should be pretty easy, but if that seems complicated or you aren't comfortable working with APIs directly you may want to try out a data warehouse tool like the one you linked. API Connector is a direct pipe from APIs to Google Sheets -- we don't have any backend database, so our system doesn't pre-process the data. All Snapchat integrations use the same endpoints provided by Snapchat, but some tools may first loop through all the campaign IDs and store data in their data warehouse, while we directly connect the API to Sheets without going through a data warehouse. So the retrieval methods are a bit different on the user side.
Alright thanks for the info Ana. Still very helpful as usual. Unfortunately we cannot specify each campaign ID as we launch tons of campaigns everyday. It will be very tedious to keep adding campaign IDs explicitly.
This guide is new so I'll be sure to follow this from time to time. Maybe some day there'll be some developments from you. Thanks again Ana, appreciate your promptness to help.
I think you can still do this fairly automatically, like first use
https://adsapi.snapchat.com/v1/adaccounts/{ad_account_id}/campaigns
to fetch a list of campaigns, and then run a request likehttps://adsapi.snapchat.com/v1/campaigns/+++Sheet1!A1:A50+++/stats?fields=frequency,impressions,spend,swipes,view_completion,video_views
to cycle through that list of campaigns.