Giter Site home page Giter Site logo

Comments (4)

devzer01 avatar devzer01 commented on July 4, 2024 1

Your support team has been a great resource for us in groups.google.com but the issue has reached beyond the limitation of what has been documented. Your kind assistance on this matter is greatly appreciated. Thank you

from google-ads-python.

BenRKarl avatar BenRKarl commented on July 4, 2024

Hi @shivam-2002 - thank you for filing this issue. Could you please paste a link to the forum post you mentioned? I'd like to follow up on it to ensure correct information is provided in the future.

To set an Ad Group to target and audience, you will need to create a new AdGroupCriterion, setting the audience field equal to the resource name of the audience you want to target.

The add_demographic_targeting_criteria example is a pretty decent approximation of the logic you will need to implement. Let me know if you need further details.

from google-ads-python.

shivam-2002 avatar shivam-2002 commented on July 4, 2024

Hi Ben, thank you for your attention, I already have created AdGroup Criterian but I am getting some error in that which I have reported to support forum, they told that it looks like a bug.
I can't paste link forum post because conversation happend in email thread with case id: "ref:!00D1U01174p.!5004Q02ryquU:ref"

import argparse
import sys

from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v15.common.types.criteria import CustomAudienceInfo

import logging


def main(client, customer_id, ad_group_id="<AD-GROUP-ID>"):
    try:
        custom_audience_resource_name = "customers/<CUSTOMER-ID>/customAudiences/<CUSTOM-AUDIENCE>"

        ad_group_service = client.get_service("AdGroupService")
        ad_group_criterion_service = client.get_service(
            "AdGroupCriterionService")

        ad_group_resource_name = ad_group_service.ad_group_path(
            customer_id, ad_group_id
        )
        ad_group_criterion_operation = client.get_type(
            "AdGroupCriterionOperation"
        )
        ad_group_criterion = ad_group_criterion_operation.create
        ad_group_criterion.ad_group = ad_group_resource_name
        ad_group_criterion.custom_audience = CustomAudienceInfo(
            custom_audience=custom_audience_resource_name
        )

        ad_group_criterion_response = (
            ad_group_criterion_service.mutate_ad_group_criteria(
                customer_id=customer_id,
                operations=[
                    ad_group_criterion_operation,
                ],
            )
        )

        for result in ad_group_criterion_response.results:
            print(result.resource_name)
    except Exception as ex:
        logging.DEBUG(ex)


if __name__ == "__main__":
    googleads_client = GoogleAdsClient.load_from_storage(version="v15")

    parser = argparse.ArgumentParser(
        description=(
            "Adds demographic targeting criteria to the provided"
            " ad group, for the specified customer."
        )
    )
    # The following argument(s) should be provided to run the example.
    parser.add_argument(
        "-c",
        "--customer_id",
        type=str,
        required=True,
        help="The Google Ads customer ID.",
    )
    # parser.add_argument(
    #     "-a", "--ad_group_id", type=str, required=True, help="The ad group ID."
    # )
    args = parser.parse_args()

    try:
        main(googleads_client, args.customer_id)
    except GoogleAdsException as ex:
        print(
            f'Request with ID "{ex.request_id}" failed with status '
            f'"{ex.error.code().name}" and includes the following errors:'
        )
        for error in ex.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)

The error
example.log
log file is attach to it.

Hi @shivam-2002 - thank you for filing this issue. Could you please paste a link to the forum post you mentioned? I'd like to follow up on it to ensure correct information is provided in the future.

To set an Ad Group to target and audience, you will need to create a new AdGroupCriterion, setting the audience field equal to the resource name of the audience you want to target.

The add_demographic_targeting_criteria example is a pretty decent approximation of the logic you will need to implement. Let me know if you need further details.

from google-ads-python.

BenRKarl avatar BenRKarl commented on July 4, 2024

@shivam-2002 Thanks for this, from my perspective your implementation looks correct. I took a look at the case and it does look like there is a bug in the API, or some other type of behavior that needs to be resolved there. So I'm going to close this out and recommend that you continue the conversion there. I'll make sure that any additional context from this issue gets included in that investigation.

from google-ads-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.