Posts tagged with google-ads-api

I’m building a custom Zap to integrate Google Local Service Ads API with our CRM. It appears everything is functioning properly however, I noticed several new leads are not coming through, which appears to be due to the API request sending nested data using the values nested under the same field .

Here is an example response:

    {     "leadId": "000000000",     "accountId": "000000000",     "businessName": "Acme, Inc",     "leadCreationTimestamp": "2022-08-09T16:21:14Z",     "leadType": "PHONE_CALL",     "leadCategory": "roofer",     "geo": "Miami,Florida,United States",     "phoneLead": {       "consumerPhoneNumber": "+15555555678"     },     "chargeStatus": "NOT_CHARGED",     "currencyCode": "USD",     "timezone": {       "id": "America/New_York"     },     "id": "0000000000"   },   {     "leadId": "000000000",     "accountId": "000000000",     "businessName": "Acme, Inc",     "leadCreationTimestamp": "2022-08-09T16:39:38Z",     "leadType": "MESSAGE",     "leadCategory": "roofer",     "geo": "Miami,Florida,United States",     "messageLead": {       "customerName": "Jane Doe",       "jobType": "attic_venting",       "postalCode": "33066",       "consumerPhoneNumber": "+15555555789"     },     "chargeStatus": "CHARGED",     "currencyCode": "USD",     "timezone": {       "id": "America/New_York"     },     "id": "1111111111"   },   {     "leadId": "000000000",     "accountId": "000000000",     "businessName": "Acme, Inc",     "leadCreationTimestamp": "2022-08-10T19:12:28Z",     "leadType": "PHONE_CALL",     "leadCategory": "window_repair",     "geo": "Miami,Florida,United States",     "phoneLead": {       "chargedCallTimestamp": "2022-08-10T19:12:28Z",       "chargedConnectedCallDurationSeconds": "280s",       "consumerPhoneNumber": "+15555555890"     },     "chargeStatus": "CHARGED",     "currencyCode": "USD",     "timezone": {       "id": "America/New_York"     },     "id": "2222222222"   }, 

The issue I’m running into is when mapping the data to our CRM, the trigger test data is providing multiple fields for ‘consumerPhoneNumber’ ( based on whether it is a message/phone lead and whether the call connected ). so we are unable to map phoneLead__consumerPhoneNumber and messageLead___consumerPhoneNumber to the same field.

duplicate fields example

How can I parse the API response to properly map the consumerPhoneNumber when the value changes based on messageLead_consumerPhoneNumber versus phoneLead_consumerPhoneNumber?

I understand some basic Javascript but parsing API data is new to me. Any help would be truly appreciated!

Here is the JavaScript code for our API request.

    const options = {   url: 'https://localservices.googleapis.com/v1/detailedLeadReports:search',   method: 'GET',   headers: {     'Authorization': `Bearer ${bundle.authData.access_token}`,     'X-QUERY': bundle.authData.query   },   params: {     'query': 'manager_customer_id:XXXXXXXXX',     'pageSize': '1000'   } } return z.request(options).then((response) => {   response.throwForStatus();   const results = response.json;   const lists = results["detailedLeadReports"].map((item) => {     return Object.assign(item, {       id: item["leadId"],     });   });   return lists; }); 

Does Boto3 client support connectors for GoogleAds and FacebookAds? According to documentation we can use Custom Connector but when i try to use it in the code i get the below error saying it should be one of the built in types.

[ERROR] ParamValidationError: Parameter validation failed: Unknown parameter in connectorProfileConfig.connectorProfileProperties: "CustomConnector", must be one of: Amplitude, Datadog, Dynatrace, GoogleAnalytics, Honeycode, InforNexus, Marketo, Redshift, Salesforce, ServiceNow, Singular, Slack, Snowflake, Trendmicro, Veeva, Zendesk, SAPOData Unknown parameter in connectorProfileConfig.connectorProfileCredentials: "CustomConnector", must be one of: Amplitude, Datadog, Dynatrace, GoogleAnalytics, Honeycode, InforNexus, Marketo, Redshift, Salesforce, ServiceNow, Singular, Slack, Snowflake, Trendmicro, Veeva, Zendesk, SAPOData Traceback (most recent call last):   File "/var/task/lambda_function.py", line 34, in lambda_handler     response = client.create_connector_profile(   File "/var/runtime/botocore/client.py", line 391, in _api_call     return self._make_api_call(operation_name, kwargs)   File "/var/runtime/botocore/client.py", line 691, in _make_api_call     request_dict = self._convert_to_request_dict(   File "/var/runtime/botocore/client.py", line 739, in _convert_to_request_dict     request_dict = self._serializer.serialize_to_request(   File "/var/runtime/botocore/validate.py", line 360, in serialize_to_request     raise ParamValidationError(report=report.generate_report()) 

Code in Lambda :

import json import boto3 def lambda_handler(event, context):     client = boto3.client('appflow')        ### Google Ads     response = client.create_connector_profile(     connectorProfileName='GoogleAdsConn',     connectorType='CustomConnector',     # connectorLabel='GoogleAds',     connectionMode='Public',     connectorProfileConfig= {       "connectorProfileProperties": {           'CustomConnector': {                 # 'profileProperties': {                 #     'string': 'string'                 # },                 'oAuth2Properties': {                     'tokenUrl': 'https://oauth2.googleapis.com/token',                     'oAuth2GrantType': 'AUTHORIZATION_CODE'                     # ,'tokenUrlCustomProperties': {                     #     'string': 'string'                     # }                 }             }             },       "connectorProfileCredentials": {         "CustomConnector": {              "authenticationType": "OAUTH2",             "oauth2": {                 "accessToken": "myaccesstoken",                "clientId": "myclientid",                "clientSecret": "myclientsecret",               "oAuthRequest": {                   "authCode": "string",                  "redirectUri": "string"               },                "refreshToken": "myrefreshtoken"             }       }     }        }    )     return {         'response': response     } 

Any leads on this will be appreciated.
Thanks!

I have a website hosted in AWS with a NodeJS backend.

I have Google Ads conversion events being sent from the frontend using gtag.js, but I noticed missing events and a lot of duplication (even if I use transaction IDs with my events)

I had similar issues with Facebook Pixel and was able to resolve the problem by sending simple vanilla http calls from my backend server.

Is it possible to do the same with Google Ads? I have not been able to find any documentation for server side APIs for Javascript. This documentation here seems promising, but no Javascript SDK exists. That's is why I would like to know what vanilla http calls to make.

I have seen documentation about GTM server side, but it seems I need to host a GTM container (server?) which I would prefer not to have to. Unless I misunderstood what hosting a GTM container means in the context of a AWS cloud solution.

So in short, my task is to extract data from Google, and I'm curious if it's possible to fetch data using Google Ads API for different customers without all the required keys (developer token, refresh token, client_id and client secret). Is this possible or not? If yes, what privileges do I need, and what are the steps? If you know where I can find some clear documentation about this, it will be a lifesaver.

Thanks!