How to select an existing custom goal when creating campaign

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"ttOn 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.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật