Extracting conversions, conversion value, conversion action and conversion action name through the API.

72 views
Skip to first unread message

Alexander Hristov

unread,
Apr 13, 2021, 9:11:05 AM4/13/21
to AdWords API and Google Ads API Forum
Hey everyone,

I've tested several different solutions but none of them seems to be the right answer, In essence I'm afer the following:

  SELECT
    customer.id,
    metrics.conversions,
    metrics.conversions_value,
    segments.conversion_action,
    segments.conversion_action_name
  FROM customer

I'm using an mcc login in this particular case. Here's what I've tried so far:

credentials = Credentials(
    None,
    refresh_token="**refresh_token**",
    token_uri="**uri**",
    client_id="**client_id**",
    client_secret="**client_secret**",
)
client= GoogleAdsClient(
    credentials,
    login_customer_id = '**login_customer_id**',
    developer_token="**developer_token",
)
service = client.get_service("GoogleAdsService", 'v6')
response = ga_service.search_stream(customer_id=client.login_customer_id, query=query)
for batch in response:
    for row in batch.results:
        logger.debug(row)

Which(understandably) returns an error: 

    ...errors { error_code { query_error: REQUESTED_METRICS_FOR_MANAGER } message: "Metrics cannot be requested for a manager account. To retrieve metrics, issue separate requests against each client account under the manager account." }...

So with that, I decided to go over each of the accessible customers:

ee = []
rr = []

client_ids = client.get_service(
    'CustomerService',
    version='v6',
).list_accessible_customers().resource_names
for client_id in client_ids:
    client_id = client_id.split('/')[1]
    logger.debug(client_id)
    try:
        results = iter(
            service.search_stream(client_id, query),
        )
    except Exception as e:
        ee.append(e)
        continue
    for xxx in results:
        rr.append(xxx)

In which case all the requests fail with the following error:

Request made: ClientCustomerId: *****, Host: googleads.googleapis.com:443, Method: /google.ads.googleads.v6.services.GoogleAdsService/SearchStream, RequestId: ****, IsFault: True, FaultMessage: Metrics cannot be requested for a manager account. To retrieve metrics, issue separate requests against each client account under the manager account.

All except for one, the one being the manager account itself, which fails with the first error. So The question is what am I doing wrong here?

Kind regards,
Alex.

Google Ads API Forum Advisor Prod

unread,
Apr 13, 2021, 10:50:38 PM4/13/21
to alex.hr...@gmail.com, adwor...@googlegroups.com
Hi Alexander,

Thank you for reaching out. 

Generally, metrics are associated to entities belonging to a specific client account. That said, retrieving these metrics would require customers to specify which client account ID (customer ID) they wish to retrieve the metrics from.

In your scenario, it appears that you are querying the metrics using a manager account. This is unfortunately not possible due to the above mentioned details.

To avoid this error, you need to ensure that the customer ID you specify in your request header (customer_id / ClientCustomerId field) belongs to a client account under your manager account.

Best regards,

Google Logo
Peter Laurence Napa Oliquino
Google Ads API Team
 


ref:_00D1U1174p._5004Q2FY6tx:ref

Alexander Hristov

unread,
Apr 14, 2021, 3:24:08 AM4/14/21
to AdWords API and Google Ads API Forum
Hi,

Thanks for the reply. Could you please elaborate on that? I modified the second example to set the ClientCustomerId in the client(second example) but I still get the exact same errors when I request metrics.

Kind regards,
Alex.

Google Ads API Forum Advisor Prod

unread,
Apr 14, 2021, 8:18:20 PM4/14/21
to alex.hr...@gmail.com, adwor...@googlegroups.com
Hi Alex,

I work with Peter and let me provide support to your concern.

Since you've mentioned that the error still persists even though you used the client account's customer ID, then please provide the complete request and response logs with request ID generated on your end to further investigate. You can provide it via Reply privately to author option.

Regards,
Google Logo
Ernie John Blanca Tacata
Google Ads API Team
 


ref:_00D1U1174p._5004Q2FY6tx:ref
Reply all
Reply to author
Forward
0 new messages