opteo / google-ads-node Goto Github PK
View Code? Open in Web Editor NEWGoogle Ads API client library for Node.js
Home Page: https://opteo.com
Google Ads API client library for Node.js
Home Page: https://opteo.com
Setting a url_custom_parameters throws error:
Error: Field 'ad.url_custom_parameters' cannot be modified by 'UPDATE' operation.
await customer.adGroupAds.update({
resource_name: 'customers/00000000/adGroupAds/00000000~00000000',
ad : {
url_custom_parameters: [
{ key:'test', value: 'test_value' },
],
}
});
Is this possibly related to Repeated types?
Working with Protobuf Types - Repeated types
Several of us on newer M1 laptops were unable to perform several upgrade steps:
yarn
, which in turn runs compileProtos
from google-gax
, failsmake protos
at the Bazel build stepEverything worked fine when using an older chip. Perhaps some dependency in google-gax and Bazel is incompatible on M1 for the time being?
v13 was released on 2023-02-15 (and v13.1 is coming in April/May)
https://developers.google.com/google-ads/api/docs/release-notes#v13
Hi,
I've some time to invest in order to optimize this lib so it will be more suitable for production use (#83 #87 #84)
But I'm not getting the structure of it.
I did understood that it gets generated from googles protobuf defs.
build/src
folder and the build/protos/protos.js
file?build/src
on production usage? (is google-ads-api
uses it?)Any help will be really appreciated.
Large sets of mutations cause a RESOURCE_EXHAUSTED
error with the following details:
"failure":{
"code": 8,
"details": "received trailing metadata size exceeds limit"
}
This seems to be a problem with gRPC response size being capped as part of this library. When a response size is too large, a generic received trailing metadata size exceeds limit
error is sent back, which obfuscates the actual cause of the error.
Spoke to Google support about this (provided them a request id) and they said the following (note I linked them to a similar issue from their officially-supported Python API Wrapper):
The Python issue you referenced has since been resolved, as we increased the grpc metadata size in September. However, since the error message from nodejs appears to be the same grpc error, there is a good chance that either the metadata size increase was not large enough for this particular response, or that the response size limit that's set in the nodejs library here is actually separate from the metadata size limit. I will follow up with the team about this issue to see what we can do, and will respond here as soon as I have updates for you.
and
I have investigated more deeply into the issue and confirmed that the longest response metadata for your requests (~42kb) is still shorter than what we have bumped the metadata size limit to (64kb). Since the equivalent issue has been resolved for Google-owned client libraries, even for response metadata longer that what is causing problems for you, the most likely case is that this error is manifesting due an Opteo-specific gRPC setup. Our recommendation is to file a Github Issue with the NodeJS client library open sourced by Opteo to have them look into the issue, and hopefully then you will have a resolution soon.
I see that you increase the message here but according to the email from Google above, my response payload for the problematic request was only ~42kb which is obviously well under the 1gb being set in the gRPC client for this library.
This has been a frequent issue for us in specific parts of our application, and would love to help get it fixed!
This is a follow-up to this issue. After investigating, I found out that Label's interface in resources.ts
is missing fields specified in the API. As a result, the fields are also missing from the compiled version of the resources. I tried adding the fields on my fork here.
However, I could not compile the resources and investigate further because I don't have the Docker permissions. I was wondering if someone could please provide an ETA on this issue. Also, is there an option of relaxing the permissions so that I could investigate further myself and open up a PR?
This is blocking me significantly. Any info would be very much appreciated. I can provide more details if needed.
Thanks a lot!
Is there any way to get the manager id (login_customer_id) of a client account programatically?
Hi,
Thank you for building these libraries!
I've successfully been using the companion google-ads-api library but I can't see how to add developerToken / authorize the services in this library. Specifically I need to run UserDataServiceClient.
Here is my code sample & I think/hope it should work if I can just authorize it correctly. (The google-ads-api constructor takes clientId, clientSecret, and developerToken & then Customer adds a refreshToken - I can't work out how to specify the developer_token).
const client = new UserDataServiceClient(
{
clientOptions: {
clientId: ADS_CLIENT,
clientSecret: ADS_SECRET,
refreshToken
}
}
)
const result = await client.uploadUserData({
customer_id: googleAdAccount,
operations: [
{
create: new common.UserData({
user_identifiers
}),
}
],
customer_match_user_list_metadata: {
user_list: googleAudience,
}
})
Hope this makes sense.
Again - thank you for making this awesome library.
Regards
Sam
Copied from google-ads-api issue (thought this repo is more suitable)
Couldn't find 'UserDataService' which is offered since Google Ads API v3.1.0
The proto file is also in the proto files
But not in the src/lib/services.ts
Can this service be added?
Hey guys!
Currently i am started to working with this library, because I needs some things from google API v10, and library google-ads-api currently supports only v9.
And my question is:
How to authorize with my Google Ads Account?
In the case of working with google-ads-api, everything works, so it is not the fault of bad data.
My current code looks like this:
import { CustomerServiceClient } from "google-ads-node";
async function makeCall() {
const client = new CustomerServiceClient({
clientOptions: {
clientId: "myClientId",
clientSecret: "myClientSecret",
refreshToken: "myRefreshToken"
},
});
const response = await client.listAccessibleCustomers();
return response;
}
I receive: Error: 7 PERMISSION_DENIED: Request had insufficient authentication scopes.
I am more then sure that is because I didn't pass developer token.
And question is: how to pass it/and and is the rest okay (I mean clientOptions)?
Upgrade Google Ads to v6
Forge fixed a potential prototype pollution security issue when used with unsafe inputs (see changelog). This library is used by google-auth-library which got patched already and thus an upgrade here would be very appreciated:
Line 39 in 256ba15
$ npm audit --audit-level=high
=== npm audit security report ===
Manual Review
Some vulnerabilities require your attention to resolve
Visit https://go.npm.me/audit-guide for additional guidance
High Prototype Pollution in node-forge
Package node-forge
Patched in >= 0.10.0
Dependency of google-ads-api
Path google-ads-api > google-ads-node > google-auth-library >
gtoken > google-p12-pem > node-forge
More info https://npmjs.com/advisories/1561
There is a new Google Ads API version (1.2.0) out! We'll have to wait for google to release the protocol buffers before this upgrade can be done.
Release Notes: https://developers.google.com/google-ads/api/docs/release-notes#120_2019-04-29
Hi,
Google released a beta version for "lead_form_submission_data" resource, which seems to be missing from this package, which affects google-ads-api package too.
Is there any chance we'll get a new release along with the https://github.com/Opteo/google-ads-api package?
Thank you and have a nice day.
See here Opteo/google-ads-api#164
We are using the module for our lambda functions and the size of the package when deployed is over 42Mb. Are there some dependencies that could be move to dev depends and minimized code?
Running node 10.10 in AWS Lambda
This is the code that I am using to create a Campaign
// assuming all required properties
const campaign = {};
campaign.target_spend = {
cpc_bid_ceiling_micros: 1000000
};
const response = await customer.campaigns.create(campaign);
It creates the campaign and in response I do have a campaign whose bidding strategy is target_spend
{
"resource_name": "customers/9999999999/campaigns/1111111111",
"bidding_strategy_type": 9,
"id": 9999999999,
"name": "Campaign Name",
"status": 3
}
Now, I want to change this bidding strategy to Maximize Conversions. As per API Docs, I just have to specify maximize_conversions property of type MaximizeConversions.
But MaximizeConversions type has no property. I am not sure what value I have to set it in update object.
I have tried it like below, that did not work.
const campaign = {
"resource_name": "customers/9999999999/campaigns/1111111111",
"maximize_conversions": ""
};
const response = await customer.campaigns.update(campaign);
How to set the maximize_conversions property in update object ?
I want to use the latest version of google's definitions. I checked out an updated commit on the submodule and then tried to compile (make protos
), without success. Any clarification on the procedure to compile the protos from the submodule to the google-ads-node package would be appreciated. Thanks :)
In some cases, large Google Ads requests will fail as they exceed the gRPC response limit (roughly ~4mb). This can be solved by adding streamed responses. We'll need to add an experiment branch for this feature, and do some research on how they've been implemented in grpc-node.
While following the example code given, I tried to make my first request. (Used a python project to get set up with my tokens through a Google login dialog and copied the refreshtoken)
However I'm getting the error Error: 13 INTERNAL: Internal error encountered
, see more below:
I used a invalid login_customer_id aswell and that returns as expected. Granted API-keys to a bigger project I have binded with Google Analytics as well, which permisions works well.
Code used
const {
GoogleAdsClient,
SearchGoogleAdsRequest,
KeywordMatchTypeEnum,
} = require("google-ads-node");
// // 1. Create a new client with valid authentication
const client = new GoogleAdsClient({
client_id:'my-client-id',
client_secret:'my-secret',
refresh_token:'my-refresh-token',
developer_token:'my-dev-token',
login_customer_id:'123-456-7890',
});
async function example() {
// 2. Load a Google Ads service
const service = client.getService("GoogleAdsService");
// 3. Create a request
const request = new SearchGoogleAdsRequest();
const result = await service.search(request)
.then((data) => {
return data.data
})
.catch((err) => {
console.log("--- Error in search ---");
console.log(err);
})
}
example();
Error
Error: 13 INTERNAL: Internal error encountered.
at Object.exports.createStatusError (/home/the-hive/node-reporter/node_modules/grpc/src/common.js:91:15)
at Object.onReceiveStatus (/home/the-hive/node-reporter/node_modules/grpc/src/client_interceptors.js:1209:28)
at InterceptingListener._callNext (/home/the-hive/node-reporter/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (/home/the-hive/node-reporter/node_modules/grpc/src/client_interceptors.js:618:8)
at Object.onReceiveStatus (/home/the-hive/node-reporter/node_modules/google-ads-node/build/lib/interceptor.js:108:17)
at InterceptingListener._callNext (/home/the-hive/node-reporter/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (/home/the-hive/node-reporter/node_modules/grpc/src/client_interceptors.js:618:8)
at callback (/home/the-hive/node-reporter/node_modules/grpc/src/client_interceptors.js:847:24) {
code: 13,
metadata: Metadata { _internal_repr: {}, flags: 0 },
details: 'Internal error encountered.'
}
It would be good to have protoc setup in the circleci config so we can run proto compilation checks with every new commit/version bump.
Instructions for installing protoc can be found here: https://github.com/protocolbuffers/protobuf/blob/master/src/README.md
hi, when i updated my lambda function to the very latest version of google-ads-node i could no longer update my lambda function that doesn't use any other dependency because the max size for a lambda function was exceeded
so, i had no choice but to use an older version that will be deprecated before the end of the summer
currently my node_modules take 327mb, when i use the most recent version i go over 400mb,
80 megabytes more for a library that calls web services ?
it would be nice to be able to include just the required functions, or at least group them, campaigns, reporting etc
or, minimise the code in some way ?
is there another way to call the API ? should i make the calls to the webservices using axios instead ?
Edit: entered 8.1.0 instead of 8.10
Great project btw! following for sure
Google docs:
https://developers.google.com/google-ads/api/docs/samples/upload-offline-conversion#java
I need to be able to report offline conversion to Google Ad account. I couldn't find this method in "conversion_upload_service_pb.d.ts", Is there a way to do it?, or is it just a regular UploadClickConversionsRequest?
Much appreciated ahead of time!
I am getting an error when creating a campaign with google-ads-node
and I am not sure what the problem is here. I've been following the callstack up to compiled-resources where the error seems to be.
Does anybody know what the issue might be? Is there a bug or might I be doing something wrong?
This is what the code looks like:
const client = new GoogleAdsApi({
client_id: process.env.ADWORDS_CLIENT_ID,
client_secret: process.env.ADWORDS_SECRET,
developer_token: process.env.ADWORDS_DEVELOPER_TOKEN
});
const customer = client.Customer({
customer_account_id: clientAccountId,
login_customer_id: process.env.ADWORDS_CUSTOMER_ID,
refresh_token: process.env.ADWORDS_REFRESH_TOKEN
});
const { results } = await customer.campaigns.create(
campaignData
);
TypeError: Cannot read property 'googleads' of undefined
at Function.Campaign.fromObject (/Users/alexanderlotvall/GoogleAdsService/node_modules/google-ads-node/build/protos/compiled-resources.js:1:2603399)
at GoogleAdsClient.buildResource (/Users/alexanderlotvall/GoogleAdsService/node_modules/google-ads-node/build/lib/client.js:95:30)
at GrpcClient.buildResource (/Users/alexanderlotvall/GoogleAdsService/node_modules/google-ads-api/build/grpc.js:121:28)
at CampaignService.buildResource (/Users/alexanderlotvall/GoogleAdsService/node_modules/google-ads-api/build/services/service.js:228:32)
at CampaignService.<anonymous> (/Users/alexanderlotvall/GoogleAdsService/node_modules/google-ads-api/build/services/service.js:110:33)
at Generator.next (<anonymous>)
at /Users/alexanderlotvall/GoogleAdsService/node_modules/google-ads-api/build/services/service.js:8:71
at new Promise (<anonymous>)
at __awaiter (/Users/alexanderlotvall/GoogleAdsService/node_modules/google-ads-api/build/services/service.js:4:12)
at CampaignService.serviceCreate (/Users/alexanderlotvall/GoogleAdsService/node_modules/google-ads-api/build/services/service.js:93:16)
The bid_modifier
field in the campaign_crtierion
struct has an incorrect definition.
Current definition is { value: number }
. The definition should be just number
.
At the moment if you try to perform any operation with campaign_criterion with bid modifier usage - it fails with assertion error.
{ AssertionError: Assertion failed
at new goog.asserts.AssertionError (/app/node_modules/google-protobuf/google-protobuf.js:81:876)
at Object.goog.asserts.doAssertFailure_ (/app/node_modules/google-protobuf/google-protobuf.js:82:257)
at Object.goog.asserts.assert (/app/node_modules/google-protobuf/google-protobuf.js:83:83)
at jspb.BinaryEncoder.writeFloat (/app/node_modules/google-protobuf/google-protobuf.js:466:384)
at jspb.BinaryWriter.writeFloat (/app/node_modules/google-protobuf/google-protobuf.js:489:142)
at proto.google.protobuf.FloatValue.serializeBinaryToWriter (/app/node_modules/google-protobuf/google/protobuf/wrappers_pb.js:447:12)
at jspb.BinaryWriter.writeMessage (/app/node_modules/google-protobuf/google-protobuf.js:491:336)
at proto.google.ads.googleads.v2.resources.CampaignCriterion.serializeBinaryToWriter (/app/node_modules/google-ads-node/build/protos/google/ads/googleads/v2/resources/campaign_criterion_pb.js:1:14157)
at jspb.BinaryWriter.writeMessage (/app/node_modules/google-protobuf/google-protobuf.js:491:336)
at proto.google.ads.googleads.v2.services.CampaignCriterionOperation.serializeBinaryToWriter (/app/node_modules/google-ads-node/build/protos/google/ads/googleads/v2/services/campaign_criterion_service_pb.js:1:12066)
at jspb.BinaryWriter.writeRepeatedMessage (/app/node_modules/google-protobuf/google-protobuf.js:504:385)
at Function.proto.google.ads.googleads.v2.services.MutateCampaignCriteriaRequest.serializeBinaryToWriter (/app/node_modules/google-ads-node/build/protos/google/ads/googleads/v2/services/campaign_criterion_service_pb.js:1:6297)
at proto.google.ads.googleads.v2.services.MutateCampaignCriteriaRequest.serializeBinary (/app/node_modules/google-ads-node/build/protos/google/ads/googleads/v2/services/campaign_criterion_service_pb.js:1:5992)
at serialize_google_ads_googleads_v2_services_MutateCampaignCriteriaRequest (/app/node_modules/google-ads-node/build/protos/google/ads/googleads/v2/services/campaign_criterion_service_grpc_pb.js:1:2147)
at Object.final_requester.sendMessage (/app/node_modules/grpc/src/client_interceptors.js:807:37)
at InterceptingCall._callNext (/app/node_modules/grpc/src/client_interceptors.js:419:43)
message: 'Assertion failed',
reportErrorToServer: true,
messagePattern: 'Assertion failed'}
Hi,
please regenerate proto for recently published v11.1. Lots of fields were added.
https://developers.google.com/google-ads/api/docs/release-notes#v11_1
Hello!
Here's the error I am getting:
Error: Attempted to set value "001" on invalid path "name" in resource
at toProtoValueFormat (c:\Users\ackht\projects\add3-be\node_modules\google-ads-node\src\lib\utils.ts:202:11)
at unroll (c:\Users\ackht\projects\add3-be\node_modules\google-ads-node\src\lib\utils.ts:192:11)
at Object.convertToProtoFormat (c:\Users\ackht\projects\add3-be\node_modules\google-ads-node\src\lib\utils.ts:187:22)
at GoogleAdsClient.buildResource (c:\Users\ackht\projects\add3-be\node_modules\google-ads-node\src\lib\client.ts:138:29)
at GrpcClient.buildResource (c:\Users\ackht\projects\add3-be\node_modules\google-ads-api\build\grpc.js:134:28)
at LabelService.buildResource (c:\Users\ackht\projects\add3-be\node_modules\google-ads-api\build\services\service.js:212:32)
at LabelService.<anonymous> (c:\Users\ackht\projects\add3-be\node_modules\google-ads-api\build\services\service.js:103:33)
at Generator.next (<anonymous>)
at c:\Users\ackht\projects\add3-be\node_modules\google-ads-api\build\services\service.js:8:71
at new Promise (<anonymous>) {stack: 'Error: Attempted to set value "001" on invaliโฆvice.js:8:71
at new Promise (<anonymous>)', message: 'Attempted to set value "001" on invalid path "name" in resource'}
Here's what I am doing:
const label = {
name: `00${result.label}`,
text_label: {
background_color: '#e993eb',
description: `Label ${result.label}`
},
}
const genLabelResult = await customer.labels.create(label);
The name seems to be a part of the labels API as per https://opteo.com/dev/google-ads-api/#label
So I was wondering if this is a bug?
Thank you!
Today, when google releases new enums under a minor version update, and these enums are not in the protos of this library, things break. We should automatically assign any unknown enums to the UNKNOWN
enum, which is the expected behavior.
There seems to be an issue with the ListAccessibleCustomersRequest
API call on latest Google Ads v3.
This piece of code throws an Argument mismatch
error and doens't work as expected:
import { GoogleAdsClient, ListAccessibleCustomersRequest } from 'google-ads-node'
const client = new GoogleAdsClient({
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
developer_token: DEVELOPER_TOKEN,
refresh_token: REFRESH_TOKEN
})
const service = client.getService('CustomerService')
const request = new ListAccessibleCustomersRequest()
const response = await service.listAccessibleCustomers(request) // throws the error
The same exact code works fine on API v2, and on latest version this API has not been changed.
The error thrown is: Argument mismatch in "makeUnaryRequest"
(from grpc dependency)
Hi there,
did you consider moving from grpc
to grpc-js
dependency? I think it is quite stable now to be used instead of the native dependency.
Hello,
I don't think this is an issue with this module and more likely my implementation but I've tried searching the docs and the issues tab here for any understanding and have not been able to make any progress to get things to work.
I'm using Next.js to build a web app that would show google ads related data for accounts I manage and so I installed this module as a dependency using npm, however, when I import it into my Next.js app and instantiate a new client I get this error:
error - ./node_modules/google-auth-library/build/src/auth/googleauth.js:17:0
Module not found: Can't resolve 'child_process'
null
Could not find files for / in .next/build-manifest.json
Could not find files for / in .next/build-manifest.json
I did some digging around and thought I might be instantiating this module on the client side when it is maybe a server side only module? In order to work around that, I tried to instantiate it through Next.js's API routes and then called the endpoint using a hook on the front end but it gave me the same error.
I also tried to implement a separate node application running just express and tried to import this module and it gave me the Must use import to load ES Module:
error since node applications don't accept import/export functions from what I remember.
I feel entirely lost and would love if someone could help.
Thanks!
Thank you for this library.
I am trying to use the KeywordPlanIdeaService. The sample example call given in the reposiotry works fine for me. So connection and credentials are fine. But using below code, I am getting the Argument mismatch in makeUnaryRequest
error that I assume occurs during the request building process. On a side note, is this the right way to set request params ? Initializing each class and calling setters looks too much for a simple request.
const oGoogleAdsClient = new GoogleAdsClient({
client_id: GOOGLE_CLIENT_ID,
client_secret: GOOGLE_CLIENT_SECRET,
developer_token: GOOGLE_ADS_DEVELOPER_KEY,
login_customer_id: GOOGLE_ADS_ACCOUNT_ID, // my manager account id
refresh_token: GOOGLE_ADS_ACCOUNT_REFRESH_TOKEN,
parseResults: true,
});
const customerId = CUSTOMER_ID; // client inside my Manager account
const service = oGoogleAdsClient.getService("KeywordPlanIdeaService");
const request = new GenerateKeywordIdeasRequest();
const language = new StringValue();
language.setValue("EN");
request.setLanguage(language);
const urlValue = new StringValue();
urlValue.setValue("https://example.com/");
const url = new UrlSeed();
url.setUrl(urlValue);
request.setUrlSeed(url);
request.setCustomerId(customerId);
const response: GenerateKeywordIdeaResponse = await service.generateKeywordIdeas(
request
);
console.log(response);
[Node] Error: Argument mismatch in makeUnaryRequest
[Node] at ServiceClient.Client.makeUnaryRequest (/home/xxxx/dev/xxxx/node_modules/grpc/src/client.js:530:11)
[Node] at ServiceClient.method_func [as generateKeywordIdeas] (/home/xxxx/dev/xxxx/node_modules/grpc/src/client.js:1000:43)
[Node] at /home/xxxx/dev/adconnector-api/dist/controllers/googleAds/search.js:270:36
[Node] at Generator.next (<anonymous>)
[Node] at fulfilled (/home/xxxx/dev/xxxx/dist/controllers/googleAds/search.js:5:58)
[Node] at processTicksAndRejections (internal/process/task_queues.js:97:5)
We should add a variety of detailed examples
Base examples on the official client libraries, e.g. google-ads-python
No matter what I do I can't get a conversion_action
object accepted by conversionActions.create()
. (These are built on top of ConversionActionServiceClient
)
This is for a client and I would really appreciate some help, am willing to pay for some mentorship if need be, thanks!
I am trying to use this code:
customer.conversionActions.create(conversion_action);
I get this issue:
Error: The required field was not present.
Here is a photo of the conversion_action
object I'm trying to use:
https://i.gyazo.com/2d987777c1a091339801114bb69ca30b.jpg
Here are the docs for the ConversionAction Object structure:
Here are the docs for this create ConversionAction API:
I have tried every combination I could think of but even with all fields uncommented it shows this issue.
Examples:
With all fields uncommented, I get this same error.
With all fields uncommented except Immutable
ones, I get this same error.
With all fields uncommented except Immutable
and id
, I get this same error.
With all fields uncommented except Immutable
and owner_customer
, I get this same error.
With all fields uncommented except Immutable
and owner_customer
, I get this same error.
and many more combos...
//google-apis-test.js
const { GoogleAdsApi } = require('google-ads-api');
const client = new GoogleAdsApi({
client_id: 'client_id',
client_secret: 'client_secret',
developer_token: 'developer_token',
});
const customer = client.Customer({
customer_account_id: 'ADWORDS-ACCOUNT-ID',
login_customer_id: 'MANAGER-ACCOUNT-ID', // Optionally provide a login-customer-id
refresh_token: 'TOKEN',
});
// Error: The required field was not present.
const conversion_action = {
//resource_name: '', //Immutable
//id: 420420420, //Output only
attribution_model_settings: {
attribution_model: 101//,
//data_driven_model_status: 5 //Output only
},
category: 4,
click_through_lookback_window_days: 30,
counting_type: 3,
include_in_conversions_metric: true,
name: 'My API Created conversion action',
//owner_customer: 'customers/9105817791', //Output only
phone_call_duration_seconds: 60,
status: 2,
//type: 0, //Immutable
value_settings: {
always_use_default_value: false,
default_currency_code: 'USD',
default_value: 1
},
view_through_lookback_window_days: 1,
//tag_snippets: [], //Output only
app_id: ''
};
// Passing in a single entity to create
const conversionActionResult = customer.conversionActions.create(conversion_action);
setTimeout(async () => {
console.log(await conversionActionResult);
}, 5000);
Sotacan-MBP:google-api-tests sotacan$ node google-apis-test.js
(node:40797) UnhandledPromiseRejectionWarning: Error: The required field was not present.
at ConversionActionService.<anonymous> (/Users/sotacan/Documents/Projects/contract-work/Google-Tracker-Shopify-App/google-api-tests/node_modules/google-ads-api/build/services/service.js:199:23)
at Generator.throw (<anonymous>)
at rejected (/Users/sotacan/Documents/Projects/contract-work/Google-Tracker-Shopify-App/google-api-tests/node_modules/google-ads-api/build/services/service.js:6:65)
(node:40797) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:40797) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:40797) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(node:40797) UnhandledPromiseRejectionWarning: Error: The required field was not present.
at ConversionActionService.<anonymous> (/Users/sotacan/Documents/Projects/contract-work/Google-Tracker-Shopify-App/google-api-tests/node_modules/google-ads-api/build/services/service.js:199:23)
at Generator.throw (<anonymous>)
at rejected (/Users/sotacan/Documents/Projects/contract-work/Google-Tracker-Shopify-App/google-api-tests/node_modules/google-ads-api/build/services/service.js:6:65)
(node:40797) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
Sotacan-MBP:google-api-tests sotacan$
When using:
let result = await customer.campaigns.list()
It fetches all the remote campaigns but not the campaigns of discovery type https://support.google.com/google-ads/answer/9176876?hl=en
v14 was released on 2023-06-07 (and v14.1 is coming in July/August 2023)
https://developers.google.com/google-ads/api/docs/release-notes#v14
When querying any type of simulations (i.e. ad_group_simulation
or campaign_criterion_simulation
) with the report()
method any fields ending in list
are not shown.
This is the list of all the missing fields :
campaign_criterion_simulation.bid_modifier_point_list
ad_group_simulation.cpc_bid_point_list
ad_group_simulation.target_cpa_point_list
ad_group_criterion_simulation.cpc_bid_point_list
Hi , i cant find how to use in the TrafficEstimator Service
I am trying to understand how to use this module with JWT authentication. I have a simple Lambda that will run every few hours, get reports from Google Ads and store it in one of our DBs. The Ads account is internal (and server-to-server) so as I understand I don't need OAuth. I setup a Google service account and download the JSON file but I didn't understnad how to use it with this module. I also have a developer token I got from Google Ads.
This is the information I have in the JSON:
{
"type": "service_account",
"project_id": "XXX",
"private_key_id": "XXX",
"private_key": "-----BEGIN PRIVATE KEY-----XXXXXXXXX-----END PRIVATE KEY-----\n",
"client_email": "[email protected]",
"client_id": "XXX",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "XXXXXXXXX"
}
I am runing this code
const {
GoogleAdsApi,
services: { KeywordSeed },
} = require('google-ads-api'); // package v5.2.0 = Google Ads API to v7
(async () => {
const client = new GoogleAdsApi({
client_id: "107229fasdfasdf.apps.googleusercontent.com",
client_secret: "GOCSPX-fasdfasdfasdfasdfa",
developer_token: "fasdfadfasdfasdf",
});
const customer = client.Customer({
customer_id: "1fasfasdfasdf9446",
refresh_token: "1//0g-fasdfasdfaasdf-LfasdfasdfjbuMWel-fo",
});
const keywordSeed = new KeywordSeed({ keywords: ['content marketing'] });
const generateKeywordIdeaResponse = await customer.keywordPlanIdeas.generateKeywordIdeas({
customer_id: customer.credentials.customer_id,
page_size: 10,
keyword_seed: keywordSeed,
}).catch((e) => console.error(e));
console.log(JSON.stringify(generateKeywordIdeaResponse, null, 2));
})();
This console logs
[
{
"keyword_idea_metrics": {
"monthly_search_volumes": [
{
"month": "JANUARY",
"year": "2021",
"_year": "year",a
"monthly_searches": "880",
"_monthly_searches": "monthly_searches"
},
{
"month": "FEBRUARY",
"year": "2021",
"_year": "year",
"monthly_searches": "1000",
"_monthly_searches": "monthly_searches"
},
{
"month": "MARCH",
"year": "2021",
"_year": "year",
"monthly_searches": "1000",
"_monthly_searches": "monthly_searches"
},
{
"month": "APRIL",
"year": "2021",
"_year": "year",
"monthly_searches": "1000",
"_monthly_searches": "monthly_searches"
},
{
"month": "MAY",
"year": "2021",
"_year": "year",
"monthly_searches": "1000",
"_monthly_searches": "monthly_searches"
},
{
"month": "JUNE",
"year": "2021",
"_year": "year",
"monthly_searches": "1600",
"_monthly_searches": "monthly_searches"
},
{
"month": "JULY",
"year": "2021",
"_year": "year",
"monthly_searches": "1600",
"_monthly_searches": "monthly_searches"
},
{
"month": "AUGUST",
"year": "2021",
"_year": "year",
"monthly_searches": "1900",
"_monthly_searches": "monthly_searches"
},
{
"month": "SEPTEMBER",
"year": "2021",
"_year": "year",
"monthly_searches": "3600",
"_monthly_searches": "monthly_searches"
},
{
"month": "OCTOBER",
"year": "2021",
"_year": "year",
"monthly_searches": "1600",
"_monthly_searches": "monthly_searches"
},
{
"month": "NOVEMBER",
"year": "2021",
"_year": "year",
"monthly_searches": "880",
"_monthly_searches": "monthly_searches"
},
{
"month": "DECEMBER",
"year": "2021",
"_year": "year",
"monthly_searches": "880",
"_monthly_searches": "monthly_searches"
}
],
"competition": "LOW",
"avg_monthly_searches": "1600",
"_avg_monthly_searches": "avg_monthly_searches",
"competition_index": "10",
"_competition_index": "competition_index",
"low_top_of_page_bid_micros": "207450549",
"_low_top_of_page_bid_micros": "low_top_of_page_bid_micros",
"high_top_of_page_bid_micros": "1022202884",
"_high_top_of_page_bid_micros": "high_top_of_page_bid_micros"
},
"keyword_annotations": {
"concepts": []
},
"text": "content marketing world",
"_text": "text"
}
]
But if you notice there are lots of dumb fileds, look at the last two properties.
"text": "content marketing world",
"_text": "text"
Why i am warry about this?
Because this behavior increases the size of data which increases the time to response from the server which leads us to slow APIs.
Hello.
Here is current typing definition:
export interface CriterionCategoryAvailability {
channel?: CriterionCategoryChannelAvailability;
locale?: CriterionCategoryLocaleAvailability[];
}
Should be:
export interface CriterionCategoryAvailability {
channel?: CriterionCategoryChannelAvailability;
locale_list?: CriterionCategoryLocaleAvailability[];
}
BR, Vlad
Error: Cannot find module 'lodash.snakecase'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (/home/rohit/Hardik/api-marketing/node_modules/google-ads-node/build/lib/utils.js:17:44)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (/home/rohit/Hardik/api-marketing/node_modules/google-ads-node/build/lib/interceptor.js:8:17)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
i tried to install lodash module but no effect
Google docs:
https://developers.google.com/google-ads/api/docs/account-management/listing-accounts
Need to be able to return the Google Ad accounts associated with a google account. Is there currently a way todo this? much appreciated ahead of time!
v15 was released on 2023-10-18, are you planning to update the library soon ?
Thanks for your lib btw !
https://developers.google.com/google-ads/api/docs/release-notes#v15
best regards,
Nicolas
Simple TypeScript installation of the latest google-ads-api
fails to compile due to the following error:
node_modules/google-ads-node/build/lib/utils.d.ts(1,8): error TS1192: Module '"/usr/app/node_modules/@types/google-protobuf/google/protobuf/field_mask_pb"' has no default export.
tsconfig.json
in this repo has esModuleInterop: true
, which is a non-default compiler option.
Projects that don't have this enabled are unable to use google-ads-api
and google-ads-node
as a result.
Enabling esModuleInterop
on my project fixes the above error but created many more errors (unrelated to google-ads-node
as a result.
Hi, first of all thank you for this package ๐๐ผ
I've noticed that my service at production env get's restarted due to high memory usage.
I've debugged it, and looks like proto.js
is 17% of my entire app memory usage!
There is anything we can do in order to improve it?
Maybe it is better to split this file into separate "domain" based files?
For the first usage of something from the lib, it takes ~10sec to load the proto.js
file.
Simple report query like
await client.report({
entity: 'campaign',
attributes: [
'campaign.id',
'campaign.name',
'campaign.labels',
'campaign.advertising_channel_type',
'campaign.advertising_channel_sub_type',
'campaign.start_date',
'campaign.end_date',
'campaign.campaign_budget',
'campaign.bidding_strategy',
'campaign.bidding_strategy_type',
'campaign.manual_cpc.enhanced_cpc_enabled',
'campaign.network_settings.target_content_network',
'campaign.network_settings.target_google_search',
'campaign.network_settings.target_partner_search_network',
'campaign.network_settings.target_search_network',
'campaign.targeting_setting.target_restrictions',
],
constraints: [{ key: 'campaign.id', op: 'IN', val: [].concat(campaignIds) }],
})
Probably related to the fact that proto.js
file is huge!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.