1) Did Token review team has already approved my developer token, do you have the developer token ?
When you sign up for the AdWords API, a developer token is automatically generated for you. Right after you apply, your token will be pending approval. While waiting for token approval, you'll be able to make calls against test accounts. After token approval, you'll be able to target production Google Ads accounts.
2) If you developer token is in pending status you can create a Test Account, did you already created it ?
3) Do you have client ID and client secret.?
To enable your app to access the API, you need an OAuth2 client ID and client secret.
you can write a apex class which can call the google REST API and get the data in salesfoce if you already have all the required items i mentioned above
i can help you with sample code for calling the google API
Thanks fo your help .I have genrated refresh token using playground. I have a qussion do we ned any vf page to do authentication or we just need to call rest api to from apex?.
Plase guide me with sample code how stuctur looks like. I will write an let you know in case of any error
Yes if you are using APEX to send out the HTTP callout you need a public site setup and a public page which will be you call back URL other way is you can try JAVASCRIPT AND HTML try below page and see if it work for you you need ot chagne the API key and other paramter to adjust to make it work for you
To run this sample, set apiKey to your application's API key and clientId to your application's OAuth 2.0 client ID. They can be generated at: https://console.developers.google.com/apis/credentials?project=_ Then, add a JavaScript origin to the client that corresponds to the domain where you will be running the script. Finally, activate the People API at: https://console.developers.google.com/apis/library?project=_ --> <!DOCTYPE html> <html> <head> <title>Say hello using the People API</title> <meta charset='utf-8' /> </head> <body> <p>Say hello using the People API.</p> <!--Add buttons to initiate auth sequence and sign out--> <button id="authorize-button" style="display: none;">Authorize</button> <button id="signout-button" style="display: none;">Sign Out</button> <div id="content"></div> <script type="text/javascript"> // Enter an API key from the Google API Console: // https://console.developers.google.com/apis/credentials var apiKey = 'YOUR_API_KEY'; // Enter the API Discovery Docs that describes the APIs you want to // access. In this example, we are accessing the People API, so we load // Discovery Doc found here: https://developers.google.com/people/api/rest/ var discoveryDocs = ["https://people.googleapis.com/$discovery/rest?version=v1"]; // Enter a client ID for a web application from the Google API Console: // https://console.developers.google.com/apis/credentials?project=_ // In your API Console project, add a JavaScript origin that corresponds // to the domain where you will be running the script. var clientId = 'YOUR_WEB_CLIENT_ID.apps.googleusercontent.com'; // Enter one or more authorization scopes. Refer to the documentation for // the API or https://developers.google.com/people/v1/how-tos/authorizing // for details. var scopes = 'profile'; var authorizeButton = document.getElementById('authorize-button'); var signoutButton = document.getElementById('signout-button'); function handleClientLoad() { // Load the API client and auth2 library gapi.load('client:auth2', initClient); } function initClient() { gapi.client.init({ apiKey: apiKey, discoveryDocs: discoveryDocs, clientId: clientId, scope: scopes }).then(function () { // Listen for sign-in state changes. gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus); // Handle the initial sign-in state. updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get()); authorizeButton.onclick = handleAuthClick; signoutButton.onclick = handleSignoutClick; }); } function updateSigninStatus(isSignedIn) { if (isSignedIn) { authorizeButton.style.display = 'none'; signoutButton.style.display = 'block'; makeApiCall(); } else { authorizeButton.style.display = 'block'; signoutButton.style.display = 'none'; } } function handleAuthClick(event) { gapi.auth2.getAuthInstance().signIn(); } function handleSignoutClick(event) { gapi.auth2.getAuthInstance().signOut(); } // Load the API and make an API call. Display the results on the screen. function makeApiCall() { gapi.client.people.people.get({ 'resourceName': 'people/me', 'requestMask.includeField': 'person.names' }).then(function(resp) { var p = document.createElement('p'); var name = resp.result.names[0].givenName; p.appendChild(document.createTextNode('Hello, '+name+'!')); document.getElementById('content').appendChild(p); }); } </script> <script async defer src="https://apis.google.com/js/api.js" onload="this.onload=function(){};handleClientLoad()" onreadystatechange="if (this.readyState === 'complete') this.onload()"> </script> </body> </html>
I will go with first step and sorry for keep on asking questions. Do we need sites to autheticate ?? I saw one video in integation to gdrive using auth provide settings. Can we also reist fo Auth settings an call rest from salesfor. Will it work ?.
BY using VF page I am accesing the Google Authentitaion and gool tokn using VF page. Could you help me how to set the end point URL To access campaign prformance report but i am getting error not found
i am also new to Campaign but i think its a part of google adwords and you end point URL after authication will look like somthing https://adwords.google.com/api/adwords/cm/v201809
i am doing more research on it i will let you know if i find anything more on it
here is some refrence URL i found in my initial research which might help you
I want to pull the campaign report information from google adwords API. fo that i have used VF page to authenticate and fetch the token from Adwords . Using that token i want to pull the campaign report infromation like impression ,cost ,cost per conversion etc...
Have you checked the appexchange? is the Salesforce app store, with bundled solutions ready for you off the shelf. I always recommend a good browse there before reinventing the wheel.
Here some options: https://appexchange.salesforce.com/results?keywords=Google%20Adwords
Have you checked the appexchange? is the Salesforce app store, with bundled solutions ready for you off the shelf. I always recommend a good browse there before reinventing the wheel.
Using code and API here google document have some detils on it reporting did you already reviewd this https://developers.google.com/adwords/api/docs/guides/reporting
https://support.google.com/google-ads/answer/7538740
https://support.google.com/google-ads/answer/6179720?hl=en
if you provide more details what exatly you are tryign to achive here i may be able to help more
Hi @SRK,
We hav some campaign in goole adwords an want to pull ata from adwods API and display into spcific fiels.
https://developers.google.com/adwords/api/docs/guides/signup .
I found this document .
I want some basic steps of rest api to get the data into salesfo relatime basis.
1) Did Token review team has already approved my developer token, do you have the developer token ?
When you sign up for the AdWords API, a developer token is automatically generated for you. Right after you apply, your token will be pending approval.
While waiting for token approval, you'll be able to make calls against test accounts. After token approval, you'll be able to target production Google Ads accounts.
2) If you developer token is in pending status you can create a Test Account, did you already created it ?
3) Do you have client ID and client secret.?
To enable your app to access the API, you need an OAuth2 client ID and client secret.
you can write a apex class which can call the google REST API and get the data in salesfoce if you already have all the required items i mentioned above
i can help you with sample code for calling the google API
DO you have Client Id and Client secret ?
if not then look under this heading "Set up OAuth2 authentication" in from this link
https://developers.google.com/adwords/api/docs/guides/first-api-call
if you have the client id and client secret we can jump to playgroud
https://developers.google.com/adwords/api/docs/guides/authentication#webapp
I have a qussion do we ned any vf page to do authentication or we just need to call rest api to from apex?.
Plase guide me with sample code how stuctur looks like. I will write an let you know in case of any error
other way is you can try JAVASCRIPT AND HTML try below page and see if it work for you you need ot chagne the API key and other paramter to adjust to make it work for you
To run this sample, set apiKey to your application's API key and clientId to
your application's OAuth 2.0 client ID. They can be generated at:
https://console.developers.google.com/apis/credentials?project=_
Then, add a JavaScript origin to the client that corresponds to the domain
where you will be running the script. Finally, activate the People API at:
https://console.developers.google.com/apis/library?project=_
-->
<!DOCTYPE html>
<html>
<head>
<title>Say hello using the People API</title>
<meta charset='utf-8' />
</head>
<body>
<p>Say hello using the People API.</p>
<!--Add buttons to initiate auth sequence and sign out-->
<button id="authorize-button" style="display: none;">Authorize</button>
<button id="signout-button" style="display: none;">Sign Out</button>
<div id="content"></div>
<script type="text/javascript">
// Enter an API key from the Google API Console:
// https://console.developers.google.com/apis/credentials
var apiKey = 'YOUR_API_KEY';
// Enter the API Discovery Docs that describes the APIs you want to
// access. In this example, we are accessing the People API, so we load
// Discovery Doc found here: https://developers.google.com/people/api/rest/
var discoveryDocs = ["https://people.googleapis.com/$discovery/rest?version=v1"];
// Enter a client ID for a web application from the Google API Console:
// https://console.developers.google.com/apis/credentials?project=_
// In your API Console project, add a JavaScript origin that corresponds
// to the domain where you will be running the script.
var clientId = 'YOUR_WEB_CLIENT_ID.apps.googleusercontent.com';
// Enter one or more authorization scopes. Refer to the documentation for
// the API or https://developers.google.com/people/v1/how-tos/authorizing
// for details.
var scopes = 'profile';
var authorizeButton = document.getElementById('authorize-button');
var signoutButton = document.getElementById('signout-button');
function handleClientLoad() {
// Load the API client and auth2 library
gapi.load('client:auth2', initClient);
}
function initClient() {
gapi.client.init({
apiKey: apiKey,
discoveryDocs: discoveryDocs,
clientId: clientId,
scope: scopes
}).then(function () {
// Listen for sign-in state changes.
gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
// Handle the initial sign-in state.
updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
authorizeButton.onclick = handleAuthClick;
signoutButton.onclick = handleSignoutClick;
});
}
function updateSigninStatus(isSignedIn) {
if (isSignedIn) {
authorizeButton.style.display = 'none';
signoutButton.style.display = 'block';
makeApiCall();
} else {
authorizeButton.style.display = 'block';
signoutButton.style.display = 'none';
}
}
function handleAuthClick(event) {
gapi.auth2.getAuthInstance().signIn();
}
function handleSignoutClick(event) {
gapi.auth2.getAuthInstance().signOut();
}
// Load the API and make an API call. Display the results on the screen.
function makeApiCall() {
gapi.client.people.people.get({
'resourceName': 'people/me',
'requestMask.includeField': 'person.names'
}).then(function(resp) {
var p = document.createElement('p');
var name = resp.result.names[0].givenName;
p.appendChild(document.createTextNode('Hello, '+name+'!'));
document.getElementById('content').appendChild(p);
});
}
</script>
<script async defer src="https://apis.google.com/js/api.js"
onload="this.onload=function(){};handleClientLoad()"
onreadystatechange="if (this.readyState === 'complete') this.onload()">
</script>
</body>
</html>
Hi ,
I will go with first step and sorry for keep on asking questions.
Do we need sites to autheticate ??
I saw one video in integation to gdrive using auth provide settings. Can we also reist fo Auth settings an call rest from salesfor. Will it work ?.
https://www.youtube.com/watch?v=4nm1G3OtDaY
BY using VF page I am accesing the Google Authentitaion and gool tokn using VF page.
Could you help me how to set the end point URL To access campaign prformance report but i am getting error not found
i am also new to Campaign but i think its a part of google adwords and you end point URL after authication will look like somthing https://adwords.google.com/api/adwords/cm/v201809
i am doing more research on it i will let you know if i find anything more on it
here is some refrence URL i found in my initial research which might help you
https://developers.google.com/doubleclick-advertisers/libraries
https://developers.google.com/adwords/api/docs/guides/reporting
I am still looking for help.did you find any information
HI Ragula
Sorry i carried away with other tasks in hand, can you please post the problem statement once again
I want to pull the campaign report information from google adwords API. fo that i have used VF page to authenticate and fetch the token from Adwords .
Using that token i want to pull the campaign report infromation like impression ,cost ,cost per conversion etc...
Have you checked the appexchange? is the Salesforce app store, with bundled solutions ready for you off the shelf. I always recommend a good browse there before reinventing the wheel.
Here some options:
https://appexchange.salesforce.com/results?keywords=Google%20Adwords
Using code and API here google document have some detils on it reporting did you already reviewd this
https://developers.google.com/adwords/api/docs/guides/reporting
Hi SRK,
Finally i could able to get the data from rest api using code .
Http http = new Http(); HttpRequest
httpReq = new HttpRequest();
HttpResponse httpRes = new HttpResponse();
String Query='SELECT campaign.advertising_channel_type,campaign.resource_name, metrics.all_conversions, metrics.cost_per_conversion,metrics.impressions,metrics.interaction_rate ,metrics.interactions,metrics.conversions_from_interactions_rate,metrics.cost_per_all_conversions FROM campaign'; httpReq.setEndpoint('https://googleads.googleapis.com/v3/customers/customerid/googleAds:search');
httpReq.setMethod('POST');
httpReq.setHeader('developer-token', 'developer token');
httpReq.setHeader('Authorization','Bearer + Access token');
httpReq.setHeader('login-customer-id', 'customerid');
httpReq.setBody('query='+EncodingUtil.urlEncode(Query, 'UTF-8'));
httpRes = (new Http()).send(httpReq); if(httpRes.getStatusCode() == 200){
string response1= httpRes.getBody();
System.debug('#### HtteRes '+HttpRes.getBody()); Map<String, Object> responseMap = (Map<String, Object>)JSON.deserializeUntyped(response1);
system.debug('response map values to verify'+ responseMap);
}
Now the problem is how to deserializeUntyped the code
Response:
results": [
{
"campaign": {
"resourceName": "customers/773028222/campaigns/6813606220",
"advertisingChannelType": "SEARCH"
},
"metrics": {
"allConversions": 1,
"costPerConversion": 5031270000,
"impressions": "12296",
"interactionRate": 0.00975192713077423558,
"interactions": "1260",
"costPerAllConversions": 5031270000,
"conversionsFromInteractionsRate":
}
},
DO you haev any idea>??