The Google AdWords application Programming Interface (API) is designed for developers who represent important advertisers or third parties with extensive technical experience.
Tabla de contenidos
To start using the AdWords API, you need to get a developer token in the MCC account or Administrator Account.
To apply for the developer token, go to the account settings.
AdWords SetUp
Once we access the account settings, we have to access the “AdWords API Center”.
When we connect, we will see a form to fill in and so request that they give us a programmer token needed to work with the AdWords API.
Request AdWords API Access
Once the access is requested the screen will be updated and our “Programmer Token” will appear in test accounts mode.
To work with the AdWords API on this account, you need to apply for basic access, but in this case, we will start working with the API, with a TEST account in AdWords.
To create a test-type account in AdWords, you need to fill in the Google form To create this type of account.
Once we have created the Test account, we will see that when accessing AdWords, a message appears telling us that we are a test type account.
Cuenta Test
With the MCC Test account created, we will create an AdWords account associated to our MCC Test account. In this account is where we will do all our tests with the AdWords API.
Client ID API AdWords
Once we have it, we keep the client ID of the account, for later use it.
Now we will create some credentials to use the Google APIs, in our case for the Adwords API.
Google APIS use credentials to use these APIS.
To get those credentials we have to address the Developer Console.
As we are going to use the test type account that we have just created, we log into the developer console with that account (when we are going to use the API with the normal account, we will have to do the same).
Console API Google Credentials
Already logged in, we access the menu “Credentials”, if we do not already have a project created, will ask to create a new project.
Click on “Create a project”, indicate the name you want and click on Create.
OAuth Credentials
Now that we have created our project, we can create the credentials we wanted. To do this, in “Create credentials”, select “OAuth client ID”.
In the form that will appear to us, we select “Other” and add the name that we want to assign to him. And once we create it, We will have our credentials!
Credentials OAuth API Google Console
We will see our customer ID, and the client’s secret.
We save this data for later and we will be closer to start using the AdWords API .
The AdWords API platform allows us to use this API with different programming languages, in our case we will use PHP.
In addition to PHP also include the libraries of JAVA, PYTHON, etc…
Now we just have to start the API.
Now that we have the library, we will modify the configuration file, in this file will be added the credentials and the necessary account data.
The file is called auth.ini and is located at:
googleads-php-lib / src / Google / API / Ads / AdWords / auth.ini
If we edit it, we will see that there are several commented lines and that we ask for certain information in the variables.
Auth.ini
First we save the file auth.ini with the credentials that we have already inserted.
Open the console or terminal of our operating system, in my case I will use the Windows console (cmd).
From the console we access the path where that directory is, for this we execute the following command:
php googleads-php-lib-masterexamplesAdWordsAuthGetRefreshToken.php
When you run it, you will ask us to connect to our AdWords account (in this case in our test type account) and access a URL.
Do not close the console because then we will have to paste the code back!
Consola GetRefreshToken
If the URL appears somewhat like INSERT_OAUTH2_CLIENT_ID_HERE, it means that we have not saved the auth. ini file with the credentials data.
Therefore when we execute the indicated command, we have to notice that the URL that returns us, contains in that client ID section.
Permisos API AdWords
If everything goes correctly, Google will ask permission to manage our AdWords campaigns.
When we accept the permissions, we will see a code, we have to copy and paste it in the execution of the command we just made in console.
Paste the code where indicated, press enter and… our refresh_token will appear!
Refresh Token API AdWords
Now this code, we include it in the file auth. ini and we will have configured and running the AdWords API!
To start using the AdWords API, we will use the examples files that appear in the downloaded library.
Let’s run the example that creates new campaigns. To do this, we go to the console, and run the file AddCampaigns. PHP, located in:
examplesAdWordsv201609BasicOperations
AdWords API Example
By default these files are only run in console, but if you want to run them in a server environment, we have to comment on these lines of code.
if (__FILE__ != realpath($_SERVER['PHP_SELF'])) { return; }
And so far the process of configuring the AdWords API is a somewhat long process but the result is well worth it.
For any questions do not hesitate to ask! Also, here I leave the reference of the AdWords API. Good luck!
SEM · 18 / 06 / 2020
In Digital Menta we don’t like to stop. Our greatest enemy is called routine and so we are continually innovating and looking for new ways and methods to do our job better. The last idea we’ve had is called SEM game and we promise you that after reading this post you’re going to want to […]
Voice search is one of the trends that is currently experiencing the greatest growth. In fact, more than one billion voice searches are already performed each month and it is expected that by 2020 50% of searches will be performed by voice. Therefore, given its high utilization, companies cannot ignore voice searches. They must be […]
SEM · 28 / 05 / 2020
During the relationship between a customer and a digital service agency, there may be ups and downs due to multiple situations. It’s normal for a customer to have doubts about the quality of the services provided. Here are ten questions a customer can ask about your digital service provider.