Google AdWords provides you with a unique ID, called a “GCLID,” for every click that comes to your website from an AdWords ad. By querying you’ll be able to see which keywords (Search String) are contributing not just to new lead submissions, but, more importantly, to actual sales.
How to Retrieve Keywords
You need to have an AdWords manager account to apply for access to the API. If you don’t already have a manager account, you will need to create one.
For Create a new Manager Account follow the link.
Adwords API access:
For Adwords API access we need to submit the details, after logging in to your manager account:
Go to Gear Icon Account Settings- Adwords API Center.
1) Make sure your information is correct and your company’s website URL is functioning. If the website is not a live page, google will not be able to process your application.
2) Google will initially contact you within two business days of the date you submitted your application. In the meantime, you can try out the API with Test Account.
After completing Step 2, a link to a follow-up application form will be sent from firstname.lastname@example.org to the email address listed in the AdWords API Centre. Please complete this follow-up form to continue your application. We need to take approval of our developer token for interacting with the google system.
Token Review Team
Your assigned developer token will be activated once your application for API access is approved. Your token will be available through your AdWords API Centre accessible through the Account settings menu for the manager account from which you applied. You’ll be able to access the API by including it in your request headers when interacting with google system.
Note: You can use the Production developer token against a Test account even when the production developer token is pending approval. While making Adwords API calls.
What is Test Account?
AdWords test accounts allow developers to execute AdWords API requests against the production environment for development and testing purposes.
Note: You cannot link test MCC or Adwords accounts to production MCC accounts, or vice versa.
How to Use Test Account for Retrieve Data
For test account, you need to first create a Test MCC account. For a test account, you must have an existing Google account that is not already linked to an AdWords account (either Production MCC or Test MCC). If you don’t have you can create a new Google account at accounts.google.com.
Follow the link for Test Account: https://adwords.google.com
All client accounts created under this test MCC account will be automatically marked as test accounts. (We need Client Customer id as a request header).
Go to Left Panel Accounts then Click on +Account New Adwords Account
It will create a client account and there you can find Client Customer Id also.
Prior to making AdWords API requests to a test account, make sure you also have a production (non-test) MCC account and a production developer token (either pending approval or approved will work).
Prerequisites for Adwords API Calls
For make Calls against the AdWords API require two pieces of information
A) An approved Developer Token if it is a Production account, for Test account no need of approved one.
B) Credentials that allow access to the targeted account (OAuth2.0).
Developer Token: It is automatically generated for you when you create an account. To access it.
Go to Gear Icon Account Settings Adwords API Center.
Credentials: Each request to the AdWords API must be authorized to make changes or retrieve data for an AdWords account.
To use OAuth 2.0 to authorize the AdWords API, We need to exchange Token for authentication for this we need to send a request to
Method –> Post.
For Authorization Code
Paste the following URL in your browser after fill the client_id.
https://accounts.google.com/o/oauth2/auth?client_id=your client id&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fadwords&redirect_uri=https://accounts.google.com/o/oauth2/token&access_type=offline&approval_prompt=auto
You will then see a screen to grant your application access to your AdWords data:
After you accept the request, you will get an authorization code that can be exchanged for an access token.
For Client Id and Secret
You must first create a client identifier and a client secret.
Step 1: Register your application https://console.developers.google.com/ and create a Client Id. Then google will provide you Client Id and Client Secret. Which are useful for authentication.
For Client Id we need to create Project
Step 2: From top left corner click on Select Project –> Create Project:
Enter the Project Name then click on Create. You can also observe Project Id here.
After Successful creation it will open then
Go to API & Auth Credentials.
Step 3: It prompt window choose OAuth 2.0 Client Id.
Step 4: Make sure all of the required fields are filled and saved for the Consent Screen. Choose any name for Product.
Step 5: Select type of Application and give Redirect Url as:
Client ID and Client secret will be created and displayed.
Use these details for make request. If you’ve made a proper request, Google will return your OAuth2 token. The access token is what you need when sending requests to AdWords API services
Example: Report download.
Pull keyword data into Salesforce using the gclid (Google Click Id)
For pull keyword data we need to go for Report download API and report type is CLICK_PERFORMANCE_REPORT.
Use this API for get Keyword information:
Authorization: Bearer YOUR_ACCESS_TOKEN (Which is generated in Earlier Request)
DeveloperToken: YOUR_Developer_TOKEN(22 character)
clientCusomerId: xxx xxx xxxx
Sample Request Body is:
__rdquery“: contains the AWQL query string.
__fmt“: defines theÂ report download format either CSV OR XM