How to Automatically Export Facebook Ads Data to Google Sheets

0 Comments
Editor Ratings:
User Ratings:
[Total: 3 Average: 4.3]




This tutorial explains how to automatically export Facebook Ads Data to Google Sheets. Here I will tell you about a simple and powerful Google App Script that you can use to fetch Google Ads Data into Google Sheets and then you can use the fetched data to create ad reports that you can use anywhere you want. Here I will show how you can use Facebook’s Marketing API to fetch Facebook Ads data in to Google Sheets. The process can take some time in setup but once you go and set it up, you can automate this action on a daily or weekly basis based on your choice.

If you are Facebook Marketer and wants to create ad reports for your clients then its not an easy tasks. There are not so good third party tools out there to get Facebook Ads Data with ease. You either have to be a good programmer in order to understand the Facebook API or you buy the tools already available. The free tools are not that great out there and comes with limitations. But I have found and amazing projects on GitHub that you can use for free and to get unlimited Ads data right in Google Sheets. Not only this, but you can even automate the process.

How to Automatically Export Facebook Ads Data to Google Sheets

How to Automatically Export Facebook Ads Data to Google Sheets?

The process of setting this whole thing up is a bit irritating but you only have to do the heavy lifting once. It will be good if you have some technical knowledge in working with APIs and Google Apps Script like tools. But it you are not techie person then don’t worry I will try to list the steps to make it easy for everyone to use this ads data exporting tool. Here I will divide the process into two part. In the first part, we will create a Facebook App and in the second part we will configure the Google App scripts to fetch the ads data. So, let’s just begin…

Part One: Setup Facebook App with Marketing API Enabled and Get the App Token

The very first step is to create a Facebook app to interact with your Facebook ads account and get the data. For this, you go to Facebook Developers. Create a new app and give it a name. The name can be anything and then you will reach the main dashboard of the app.

Create a Facebook App

After creating an app, go to its basic settings and enter the domains to verify the calls to the API. Here you specify the Google Apps Script domains and save the changes. Also, fill the privacy policy and TOS fields.

ads url and privacy

Now, the next thing you have to do is add Marketing API to the app. For this, you can either search for it in the dashboard or it will appear there automatically. After that, you have to generate the app token and then copy it down, Do note that, that token will not be saved, so just copy it immediately after specify the access type to the token.

Ads Connector Marketign APi Setup

At this point, the Facebook App part has completed and you can now close Facebook. But before that, you also need to copy the ad account ID for which you want to get the ads data. If you manage multiple clients there will be multiple pages and multiple ad account ids. So, copy the one that you want to use for the ads data.

Part Two: Create Google App Script and Setup Google Sheet.

Log in to your Google account and then create a new Google Sheet. You can make it public if you want to. After that, you can copy its URL and also the tab name. “Sheet1” is the default name in every new Google Sheet.

Now, you create two new Google apps scripts and paste the code by copying it from this GitHub repository. The files are “get-facebook-report” and “request-facebook-report”. You can copy the code from these files and paste them in the exact scripts that you have made.

Get Script Files

Now, its time to fill out the credentials. You have to fill the credentials and other parameters in the app scripts. Things like access token, ad account id, fields, date range, etc. Make sure that you fill correct parameters in both the scripts and save the changes.

add credentials to scripts

Now, the Google Sheets and Google App Script have been configured. You are now all set to run the script and get ads data right in the Google Sheet. It is simple as that. But do note one thing here that there is an issue in the “request-facebook-report.gs”script. But it has been resolved in this issue. So, you will have to make the changes on line number 36. This is temporary once it is added to master branch then you will no longer have to do that. Also, this example of mine only gets the ad name, clicks, campaign name, and CPC. But you can add other parameters as well. You can see list of all parameter here and then define them based on you needs in the “Fields” variable(separated by commas) on line 23.

Exporting Ad Data

Now, you can just run the “request-facebook-report.gs” script using the play button and it should run without any problems. Next, you run the “get-facebook-report.gs” script and it will place the data in the Google Sheet whose URL you have specified in it. The data will look like this:

Facebook Ads Data in Google Sheet in action

Not only exporting the data, but you can even automate this process. The scripts can be scheduled to run automatically. You can configure the app scripts to run daily by configuring the triggers. There is a icon there which you can use for it.

Create a trigger for the Google Sheet

That’s all about this handy method to export Facebook Ads Data to Google Sheets. If you follow this tutorial carefully then you will end up creating a working Facebook app and a Google Apps Script that fetches ads data in a specified Google Sheet based on your schedule. Also, make sure that “request-facebook-report.gs” is scheduled to run before “get-facebook-report.gs”.

The Bottom line…

If you are looking for the best free way to get Facebook Ads data in Google Sheets then you have come to the right place. Here you can simply follow the guide mentioned here and create a free tool that will fetch ads data in a Google Sheet. Later you can use this Sheet as a data source to create reports in Google Data Studio. Or, if you have some other work to do with the ads data then you are free to do that.

Editor Ratings:
User Ratings:
[Total: 3 Average: 4.3]

Leave A Reply

 

Get 100 GB FREE

Provide details to get this offer