Google Campaign Keywords Data in Salesforce

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 “GclId” 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

Step 1:

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 new Manager Account follow the link.

https://www.google.com/adwords/myclientcenter/

Step 2:

Adwords API access:

For Adwords API access we need to submit the details, after logged in to your manager account:

Go to Gear IconàAccount Settings-àAdwords API Center.

Google Adwords API Center

Note:

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.

 

Step 3:

After completing Step 2, a link to a follow-up application form will be sent from adwordsapi-tokens@google.com to the email address listed in the AdWords API Centre. Please complete this follow-up form to continue your application. We need to take approve of our developer token for interacting with 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 make 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.

  1.  For 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

  1. 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 client account and there you can find Client Customer Id also.

  1. 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 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 account. For 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 request to

https://accounts.google.com/o/oauth2/token

Methodà –> Post.

Google Adwords API Sample Code

Here:

Redirect_uri =https://accounts.google.com/o/oauth2/token

grant_type=authorization_code

 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:

Google Adwords API JAVA

After you accept the request, you will get an authorization code that can be exchanged for an access token.

SampleCode

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:

Google Adwords API  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.

Google Adwords API  Credentials

Step 4: Make sure all of the required fields are filled and saved for the Consent Screen. Choose any name for Product.

Google Adwords API  OAuth

Step 5: Select type of Application and give Redirect Url as:

https://accounts.google.com/o/oauth2/token

Google Adwords API  Web App Creation

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:

https://adwords.google.com/api/adwords/reportdownload/v201506

Method: POST

Request headers:

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=SELECT+CriteriaId+FROM+CLICK_PERFORMANCE_REPORT+WHERE GclId=1234+DURING+20150901,20150901&__fmt=CSV

__rdquery“: contains the AWQL query string.

__fmt“: defines the report download format either CSV OR XM

 

Profile photo of HARIKRISHNA R

HARIKRISHNA R

Salesforce_Developer & Admin,Interest to learn new things in Technology, and Implement applications for Enterprises which are Multi National.
Posted in Apex Development, force.com app development, Force.com Offshore, Learn Salesforce, Salesforce, salesforce administrator, Salesforce Challenges, Salesforce cloud Implementation, salesforce connectors, salesforce consultant, salesforce customization, salesforce development, salesforce Tips & Tricks, Salesforce.com. Tagged with , .

One Response

Leave a Reply

Your email address will not be published. Required fields are marked *


× one = 1

CommentLuv badge
Skip to toolbar