How to get impression from google ads using google-ads-node( met one issue; INVALID CUSTOMER ID even though it is set correctly.)
Hope you are safe and good for this pandemic time. I am developing some functional to fetch data from google ads using google-ads-node. But for now I met one issue.
Error: 3 INVALID_ARGUMENT: Invalid customer ID '... .... ...'.
However it is set correctly on ads account. Please understand me messy picture. The code I used like this.
const auth = await authenticateGoogle(`keys/${process.env.GOOGLE_YT3_API_CREDENTIAL_PATH}`, 'installed'); const client = new GoogleAdsClient({ access_token: auth.credentials.access_token, developer_token: process.env.DEV_TOKEN, parseResults: true, }); const service = client.getService("GoogleAdsService", { useStreaming: true }); const request = new SearchGoogleAdsStreamRequest(); request.setQuery(` SELECT campaign.resource_name, metrics.impressions, segments.date FROM campaign WHERE segments.date BETWEEN "2019-01-01" AND "2020-01-01" `); request.setCustomerId(process.env.CUSTOMER_ID); const call = service.searchStream(request); const chunks = []; call.on("error", err => reject(err)); call.on("data", (chunk) => chunks.push(chunk)); call.on("end", () => resolve(chunks));
Would you help me how I can figure out this issue please? Thank you.
The only thing you need is to pass the CustomerID without dash (-). More specifically, you just need passing the CustomerID with XXXXXXXXXX format instead of XXX-XXX-XXXX.
You dear stack overflow user, deserves a medal. I haven't found that anywhere in the documentation
google-ads-api need client_id and login_customer_id.
i think CUSTOMER_ID need to change as "client_customer_Id" not a "login_customer_id"
For the ones that ended up here in 2021+.. the "google-ads-node" does not recieve any more support from Opteo, they now support the "google-ads-api" lib that themselves made.