Hello!
I'm starting to get acquainted with the Google Ads API - migrating there the Adwords API scripts and met such a huge problem for me:
a cycle that took minutes in Adwords takes HOURS via the Ads API (( I hope I'm just doing something wrong...
The task is to get links from all ads from all campaigns and I need to get all these parametrs:
account_name,
campaign.status,
ad_group.status,
final_urls
In the Adwords I could get it with the AD_PERFORMANCE_REPORT
The API Google Ads migration tool recommended me ad_group_ad report and below is my request.
It works well when there are several ads on the account, but when there are hundreds of them (or thousands), the FOR ROW IN RESULTS loop takes hours
Also tried FOR BATCH IN RESPONSE - the same result
And it looks like the raw unload (with Results or Response cycle) does not allow to rewrite the data faster. Am I wrong? Is there any alternative?
//////////////////
ga_service = client.get_service("GoogleAdsService")
customer_service = client.get_service("CustomerService")
resource_name = customer_service.customer_path(customer_id)
customer = customer_service.get_customer(resource_name=resource_name)
ga_service = client.get_service("GoogleAdsService")
query = """
SELECT
customer.descriptive_name,
campaign.status,
ad_group.status,
ad_group_ad.ad.final_urls
FROM ad_group_ad
WHERE segments.date DURING TODAY AND campaign.status = 'ENABLED' AND ad_group.status = 'ENABLED' """
search_request = client.get_type("SearchGoogleAdsRequest")
search_request.customer_id = customer_id
search_request.query = query
results = ga_service.search(request=search_request)
for row in results:
campaign = row.campaign
ad_group = row.ad_group
ad_group_ad = row.ad_group_ad
print(
customer.descriptive_name,
campaign.status,
ad_group.status,
ad_group_ad.ad.final_urls
)