Posts under category google-ads-api

I'm pretty new to python and Flask development. I'm primarily a frontend JavaScript/React developer.

I am building a tool that uses the Google Ads api, and their documentation had me create a yaml file with my refresh tokens and other important info.

I'm trying to deploy my flask app to render.com and I'm unsure what to do with the yaml files since I want to keep my tokens secure. Any advice?

So far I've tried adding my tokens in an env file and reading them that way, but it looks like the google ads api needs the yaml file.

I'm encountering an issue with Google Ads where the square logo I uploaded doesn't fill the circular space on the platform. Despite uploading a square logo as per the requirements, it appears smaller within a circular frame on Google Ads.

Here are the steps I've taken so far:

  • Uploaded a square logo (e.g., 512x512 pixels) through the Google Ads interface.
  • Checked the preview, and the logo appears smaller and doesn't fill the circular space properly.
  • Verified the dimensions and file format (PNG or JPEG) are correct according to Google Ads guidelines.

Is there a specific format or setting I'm missing to ensure that my square logo appears correctly within the circular frame on Google Ads? Any insights or suggestions on how to resolve this issue would be greatly appreciated.

I am trying to set up some automated rules for a client. I want a script that can increase daily campaign budgets if certain results are met. More specifically, I want budget increased if they are limited by budget and their target ROAS is met. I am have problems doing this because metrics like conversion value, lost impression share (budget), impression share etc does not seem to be available.

I have tried several different ways. I was hoping that campaign status, impression share, conversion value etc was possible to use in scripts, but so far I have not found a solution for this. Is there any way possible to use these metrics?

I want to create a campaign through the Google Ads API. And I've successfully created a campaign. But when I compared it with the UI created one, I realized that I didn't choose a custom goal. In the UI I'll set it up like this. enter image description here

I can get all the custom goals via GAQL.

SELECT    custom_conversion_goal.resource_name,    custom_conversion_goal.id,    custom_conversion_goal.name,    custom_conversion_goal.conversion_actions,    custom_conversion_goal.status,    customer.id  FROM custom_conversion_goal  WHERE custom_conversion_goal.name='xxx' 

This is shown in the figure below.enter image description here

Now, I want to select the custom goal from the query while creating a campaign using google ads api.How should I write my python code?

Reference document link

Also, I've attached the sample code for the base campaign that I've successfully created, it's not much different from what's in the documentation.

import sys from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException _DATE_FORMAT = "%Y%m%d" def handle_googleads_exception(exception):     print(         f'Request with ID "{exception.request_id}" failed with status '         f'"{exception.error.code().name}" and includes the following errors:'     )     for error in exception.failure.errors:         print(f'\tError with message "{error.message}".')         if error.location:             for field_path_element in error.location.field_path_elements:                 print(f"\t\tOn field: {field_path_element.field_name}")     sys.exit(1) def create_campaign(client, customer_id):     campaign_budget_service = client.get_service("CampaignBudgetService")     campaign_service = client.get_service("CampaignService")     campaign_budget_operation = client.get_type("CampaignBudgetOperation")     campaign_budget = campaign_budget_operation.create     ampaign_budget.amount_micros = 50000000     campaign_budget.explicitly_shared = False     campaign_budget_response = None     try:         campaign_budget_response = campaign_budget_service.mutate_campaign_budgets(             customer_id=customer_id, operations=[campaign_budget_operation]         )     except GoogleAdsException as e:         handle_googleads_exception(e)     campaign_operation = client.get_type("CampaignOperation")     campaign = campaign_operation.create     campaign.name = 'campaign-test1'     campaign.status = client.enums.CampaignStatusEnum.PAUSED campaign.tracking_url_template = "{...}"     campaign.advertising_channel_type = client.enums.AdvertisingChannelTypeEnum.DISPLAY     campaign.targeting_setting.target_restrictions.targeting_dimension = client.enums.TargetingDimensionEnum.AUDIENCE     campaign.targeting_setting.target_restrictions.bid_only = False     campaign.audience_setting.use_audience_grouped = False     campaign.geo_target_type_setting.positive_geo_target_type = client.enums.PositiveGeoTargetTypeEnum.PRESENCE     campaign.geo_target_type_setting.negative_geo_target_type = client.enums.NegativeGeoTargetTypeEnum.PRESENCE     campaign.target_cpa.target_cpa_micros = 100000     campaign.campaign_budget = campaign_budget_response.results[0].resource_name     # Setting the specified custom goal but with an error     # AttributeError: Unknown field for Campaign: conversion_goal_campaign_config     campaign.conversion_goal_campaign_config.custom_conversion_goal = "customers/xxxx/customConversionGoals/xxxxx"     try:         campaign_response = campaign_service.mutate_campaigns(             customer_id=customer_id, operations=[campaign_operation]         )         print(f"Created campaign {campaign_response.results[0].resource_name}.")     except GoogleAdsException as ex:         handle_googleads_exception(ex) if __name__ == '__main__':     googleads_client = GoogleAdsClient.load_from_storage(         path=r"./google-ads-th.yaml",         version="v17"     )     customer_id = "xxxx"     create_campaign(googleads_client, customer_id) 

I never found in the documentation how to select a custom goal when creating campaign.and I had to specify the campaign type as DISPLAY. It can't be a performance max campaign or an app campaign. Both campaigns can specify a custom goal. Because it is clearly stated in the documentation.

Consider this query for querying keyword metrics daily

https://developers.google.com/google-ads/api/docs/query/overview

          SELECT              ad_group_criterion.criterion_id,             ad_group_criterion.type,             ad_group_criterion.keyword.text,             ad_group_criterion.keyword.match_type,             ad_group_criterion.status,             metrics.clicks,             metrics.impressions,             metrics.average_cost,             metrics.cost_micros,             metrics.average_cpm,             metrics.average_cpc,             metrics.ctr         FROM keyword_view         WHERE             segments.date DURING TODAY 

What timezone does the Google API use for segmenting metrics by date?

This was asked here: https://groups.google.com/g/adwords-api/c/XprkF_vnPmA?pli=1 But the answer is not clear.

I've asked the same question on the google developers video as well: https://www.youtube.com/watch?v=zwyFNi7wRgU

I've tried reading the docs on google ads but couldn't find a clear answer