1. Setting Up Google Ads API
To set up the “Google Ads API”, firstly you need to create a project in the console
screen – Google API Console. Then, sign in to the Google Account in which you want the
google ads to be integrated. Go to the APIs & Services and test Google Ads API.
Create a project to start enabling the APIs and services. By default, it is set to “Quick Start”.
But to create a project, you have an option on the menu bar as highlighted in the image
below.
Clicking on the dropdown near the project name. Select the organization –Innovalleyworks.com
Click on “New Project”. The below window appears with various fields. Fill the project name and click “CREATE”.
Once the project is created, you will have a pop up on the right side to select that project you
want to integrate with Google Ads.
After selecting the project, you will find the project name is updated near “Google Cloud
Platform” menu icon. Now click on “Enable APIs and Services”.
Search and find the “Google Ads” in the listed API library and click on it.
Click on “Enable” button.
Once your “Google Ads API is enabled”, you will get the below screen. Click on
“Create Credentials” on top right. Fill in the details and create the credentials for
Application.
Click ondr53xc“
‘Configure Consent Screen” to first configure “OAuth Consent screen” before
generating credentials. Select the ‘external’ radio button to configure test users to
access the application and click on “CREATE”. If testing is done as part of the
organization internally the option “INTERNAL” can be used.
This will redirect to the app registration page. Fill in the mandatory details and “Save
and Continue”. This will be enough to configure it.
Fill in if any scopes required
Click on “Add Users” to create Test Users.
Once all is done, all details will be listed as summary.
Click on the “Credentials” on left above the “OAuth Consent screen” option. In the list, you
will see three options listed. Select each to get the “API key and client ID”.
For “Client ID” generation, below details need to be added and click on “CREATE”.
Click on “Create Credentials”, you will see three options listed. Select each to get the
“API key and client ID”.
2.Get the refresh token Using OAuth 2.0 to Access Google APIs
https://developers.google.com/identity/protocols/oauth2
Click the above link and Authorise the “Google Ads API”
Click on “Exchange authorization code for tokens” button then get the refresh token
3.Generate Access Token Using Postman
Use the below CURL with your details of API and generate the access token
curl –location –request POST ‘https://www.googleapis.com/oauth2/v3/token’ \
–header ‘Content-Type: application/x-www-form-urlencoded’ \
–data-urlencode ‘grant_type=refresh_token’ \
–data-urlencode ‘client_id=””’ \
–data-urlencode ‘client_secret=””’ \
–data-urlencode ‘refresh_token=
Sample Response:
{ "
access_token":
"ya29.A0ARrdaM_2dAKHTIryWLlDcwmLYqWW5wiVxx9bkESQPE461iBz47l2GiCBd3mRX5RUgvT0w
80Ize4hQ36igpjjPckfJ9hGOs32c_Ku6MLUONXToxsf_WUEsIBbWxuvmjAM8kIYl7mSidW9moD799L6
bYJeDq8rib0",
"expires_in": 3599,
"scope": "https://www.googleapis.com/auth/adwords",
"token_type": "Bearer"
}
4.Get the Customer Id and Developer token from Google AdSense
First, we need to sign into “Google AdSense”. Then we get the customer id and
developer token from under the account information menu.
5.Get the Google Ads Data Using Postman
Use the below CURL with your details of API and get the google ads data
curl–location–requestPOST
‘https://googleads.googleapis.com/v8/customers/1681829967/googleAds:search’ \
–header ‘developer-token: “”’ \
–header ‘login-customer-id: “”’ \
–header’Authorization:Bearer””’ \
–header ‘Content-Type: application/json’ \
–data-raw ‘{
“pageSize”: 5,
“query”: SELECT campaign.id,campaign.name,campaign_budget.amount_micros,
campaign.status,campaign.start_date,campaign.end_date,
campaign.optimization_score,campaign.advertising_channel_type,metrics.clicks,
metrics.impressions,metrics.ctr,metrics.average_cpc,metrics.cost_micros,
campaign.bidding_strategy_type,campaign.optimization_score,segments.date
FROM campaign WHERE segments.date DURING LAST_7_DAYS
AND campaign.status != REMOVED”
}
Sample Request:
Response will be in JSON format with all campaign details.