According to the latest quarterly results published by Facebook, revenue from advertising in Q3 of 2020 surpassed even the last quarter of the previous year, the time of year when the spending on advertising is the highest due to both Black Friday/Cyber Monday campaigns, and due to the Christmas season. With 1.8 billion daily active users (196m for US & Canada) and 2.7 billion monthly active users (255m for US & Canada) on the social media platform, it should come as no surprise that the investments in marketing campaigns on the platform keep increasing.
Over the years, Facebook has built a powerful ad management platform, which allows brands to carefully monitor and place ads to users through a wide range of targeting options and possible placements. One of the bigger problems they faced was creating an ad management platform for a wide range of businesses which were supposed to use it. Every company has its own marketing goals and metrics, and for those brands that want a more detailed analysis of their account performance data, Facebook provides another way to aggregate data: through its Marketing API.
At a basic level, Marketing API can be used for reporting purposes, but it also supports managing campaigns. In this blog post, we explain how to start analyzing data using this API, and in the next post, we give a reference guide for making some basic queries.
Let’s start with setting everything up, after which we will make a test call to see if everything works like it should.
Setting up the Marketing API
In this section, we guide you through the process of setting everything up, after which you should be able to send queries to Facebook and receive the requested data. The process differs depending on the purpose of the app. For the purposes of this article, we assume that the tool will only be used for internal usage (reporting), not for developing commercial applications. If you wish to create commercial applications, the process is a bit different, primarily due to additional identity checks.
1. Open “Facebook Developers”
The first step of the process is to open the Facebook Developers page. After logging into your Facebook account, navigate to the “My Apps” page which is located in the upper right corner of the page, in the navigation bar. You should see a page similar to the following:
2. Create a new app
This part of the process is the same for all apps you can create with Facebook, so you will be asked to specify what the application will do. For our purposes, we will “Manage Business Integrations”, so choose the first option, like on the following screen, and click “continue”.
3. Fill Out the Form
On the next step, you should see a form asking you to name the app, add a contact email, and connect a business manager account (this last part is optional). You are also asked about the purpose of the app, and as we said before, in this case we are interested in developing an internal app, so choose Yourself or your own business, and proceed to the next step by clicking “Create app”.
4. Set Up the “Marketing API”
After passing the security check (arguably the most difficult part of the process), you should see the main dashboard of your new app, and it should look something like the following image. Among the number of different functionalities offered by Facebook, we are interested in the “Marketing API” for now, so we click the “Set Up” button on the “Marketing API” product. There should be no additional steps.
5. Select Permissions and Generate the Access Token
We are almost done. In your app dashboard, click Tools → Graph API explorer, which should lead you to the page similar to the image below. Click the “generate access token”, and you will receive a unique token from Facebook through which you can make API calls (communicate with Facebook servers). In the upper input field (next to the submit button), enter the following and press “submit”:
You should see a list of all ad accounts you have access to, along with their respective names. The “Name” property should be specified explicitly because Facebook works with IDs (a technical detail). If you get an error message, it’s possible that you should add additional permissions. Click the dropdown button for “Add a permission”, and add “ads_management”, in order to have the rights necessary to execute the call. For each new permission added, new access tokens will have to be generated.
Congratulations, you’ve made your first API call! It may not look impressive for now, but that’s because we spent most of the time setting everything up. In the next blog post, we dive a bit deeper into how to extract data from the platform using the API, and we give a couple of example queries which are often used.
If you have any problems with the setup, or you have any questions about extracting data, feel free to tell us in the comments. For more interesting content like this, visit our blog page.