Need Help on Audience Data

45 views
Skip to first unread message

Harshitha

unread,
Dec 11, 2024, 3:46:44 AM12/11/24
to Google Ads API and AdWords API Forum
Hi Team,

I'm trying to pull the audience data at campaign level. However, i'm unable to get the audience id and name from the below code

First Initial Query: SELECT campaign_criterion.user_list.user_list, campaign.id, metrics.conversions, metrics.conversions_value, metrics.impressions, metrics.cost_micros, metrics.ctr, metrics.clicks, segments.date, campaign.name FROM campaign_audience_view WHERE segments.date BETWEEN '2024-11-01' AND '2024-11-01' ORDER BY segments.date DESC

code is:
if schema_key == "audience":
                audience_resource_name = row.campaign_criterion.resource_name.split("~")[1]
                print("Extracted audience_resource_name:", audience_resource_name)

                audience_query = f"""
                SELECT user_list.name, user_list.type
                FROM user_list
                WHERE user_list.resource_name = 'customers/{customer_id}/userLists/{audience_resource_name}'
                """

                audience_request = google_ads_client.get_type("SearchGoogleAdsRequest")
                audience_request.customer_id = customer_id
                audience_request.query = audience_query

                try:
                    audience_response = google_ads_service.search(audience_request)
                    print("Audience response type:", type(audience_response))
                    print(audience_response)
                    audience_results = list(audience_response)
                    print(f"Number of results/pages: {len(audience_results)}")

                    if not audience_results:
                        print("No results returned. Check your query or permissions.")

                    for page in audience_results:
                        print("Processing page...")
                        for audience_row in page.results:
                            print("Audience Row:", audience_row)
                            audience_name = audience_row.user_list.name
                            audience_type = audience_row.user_list.type
                            print("Audience Name:", audience_name)
                            print("Audience Type:", audience_type)
                except Exception as e:
                    print("Error fetching audience data:", e)


Response from the above code is:
Extracted audience_resource_name: 51668103655
INFO:google.ads.googleads.client:Request made: ClientCustomerId: 1234567890, Host: googleads.googleapis.com, Method: /google.ads.googleads.v18.services.GoogleAdsService/Search, RequestId: -VCpxQwbpw_NyJIjkMxWSw, IsFault: False, FaultMessage: None
Audience response type: <class 'google.ads.googleads.v18.services.services.google_ads_service.pagers.SearchPager'>
SearchPager<field_mask {
  paths: "user_list.name"
  paths: "user_list.type"
}
>

I'm audience able to get the criterion id which is 51668103655. However, i'm unable to get the audience name, type and it is saying like SearchPager<field_mask {
  paths: "user_list.name"
  paths: "user_list.type"
}

Please help me on how to acheive this.


Google Ads API Forum Advisor

unread,
Dec 11, 2024, 8:04:56 AM12/11/24
to adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

I understand that you are unable to fetch the audience id, name and type using the campaign_audience_view report. The provided CID is invalid. In order to analyze the issue further, please share the below details :
  • CID (customer ID) / client customer ID
  • Uncropped screenshot of the Google Ads UI (from Google Ads account) which shows the fields audience id, name and type at campaign audience level.
You can send the details via Reply privately to the author option, or direct private reply to this email.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02vGoRE:ref" (ADR-00278384)

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5



Reply all
Reply to author
Forward
0 new messages