How to PAUSE a Managed Placement of AdGroup

115 views
Skip to first unread message

K Raza

unread,
Mar 3, 2021, 1:13:55 PM3/3/21
to AdWords API and Google Ads API Forum
Hi Support,

I am using python to build a app for my client.   I want to PAUSE a specific Placement using my code.  How can I do that? There is no example for this 

Here is image,  for example I want to PAUSE latimes.com placement
google_placement.png

K Raza

unread,
Mar 3, 2021, 1:17:20 PM3/3/21
to AdWords API and Google Ads API Forum
I am using google Ads API  v6

Google Ads API Forum Advisor Prod

unread,
Mar 4, 2021, 10:52:53 AM3/4/21
to kalimr...@gmail.com, adwor...@googlegroups.com
Hello,

Unfortunately, we don't have an example on how to pause placements. However, you can use this example as a reference. This example shows how to enable a keyword using AdGroupCriterionService. You will need to modify it to use PAUSED and the Id of your placements.

Cheers,
Anthony

Google Logo
Anthony
Google Ads API Team
 


ref:_00D1U1174p._5004Q2DKpxV:ref

Google Ads API Explorer

unread,
Mar 4, 2021, 11:31:52 AM3/4/21
to AdWords API and Google Ads API Forum
Can I pause placement using CampaignCriterion or AdGroupCriterion service ?

Google Ads API Explorer

unread,
Mar 4, 2021, 12:30:53 PM3/4/21
to AdWords API and Google Ads API Forum
@anthony,

I did this but not able to pause the placements

$adGroupCriterion = new AdGroupCriterion([
                    'resource_name' => ResourceNames::forAdGroupCriterion(
                        $customerId,
                        $adGroupId,
                        $placementcriterionId
                    ),
                    'status' => AdGroupCriterionStatus::PAUSED
                ]);

                
                $adGroupCriterionOperation = new AdGroupCriterionOperation();
                $adGroupCriterionOperation->setUpdate($adGroupCriterion);
                $adGroupCriterionOperation->setUpdateMask(FieldMasks::allSetFieldsOf($adGroupCriterion));

                // Issues a mutate request to update the ad group criterion.
                $adGroupCriterionServiceClient = $googleAdsClient->getAdGroupCriterionServiceClient();
                $response = $adGroupCriterionServiceClient->mutateAdGroupCriteria(
                    $customerId,
                    [$adGroupCriterionOperation]
                );


K Raza

unread,
Mar 4, 2021, 12:54:51 PM3/4/21
to AdWords API and Google Ads API Forum
I have a python example and that worked for me to pause the placement.
+++++++++++++++++++
def pause_placement (client, customer_id, ad_group_id, criterion_id):
    agc_service = client.get_service("AdGroupCriterionService", version="v6")

    ad_group_criterion_operation = client.get_type(
        "AdGroupCriterionOperation", version="v6"
    )

    ad_group_criterion = ad_group_criterion_operation.update
    ad_group_criterion.resource_name = agc_service.ad_group_criteria_path(
        customer_id, ResourceName.format_composite(ad_group_id, criterion_id)
    )
    ad_group_criterion.status = client.get_type(
        "AdGroupCriterionStatusEnum", version="v6"
    ).PAUSED
    
    fm = protobuf_helpers.field_mask(None, ad_group_criterion)
    ad_group_criterion_operation.update_mask.CopyFrom(fm)

    try:
        agc_response = agc_service.mutate_ad_group_criteria(
            customer_id, [ad_group_criterion_operation]
        )
    except google.ads.google_ads.errors.GoogleAdsException as ex:
        print(
            'Request with ID "%s" failed with status "%s" and includes the '
            "following errors:" % (ex.request_id, ex.error.code().name)
        )
        for error in ex.failure.errors:
            print('\tError with message "%s".' % error.message)
            if error.location:
                for field_path_element in error.location.field_path_elements:
                    print("\t\tOn field: %s" % field_path_element.field_name)
        sys.exit(1)

    print("Updated placement status %s." % agc_response.results[0].resource_name)

Google Ads API Explorer

unread,
Mar 4, 2021, 1:05:57 PM3/4/21
to AdWords API and Google Ads API Forum
Thanks for sharing your worked code.

My PHP code is seems to be same but I am not able to pause the placement? neither giving me any error.

@anthony if you could help?

Thanks,
Message has been deleted

Google Ads API Explorer

unread,
Mar 4, 2021, 1:52:25 PM3/4/21
to AdWords API and Google Ads API Forum
I figured out the issue.

Thanks It is worked now.

Google Ads API Forum Advisor Prod

unread,
Mar 4, 2021, 4:25:37 PM3/4/21
to apideve...@gmail.com, adwor...@googlegroups.com
Hello,

Please let me know if you face any other issues.

K Raza

unread,
Mar 5, 2021, 12:49:11 PM3/5/21
to AdWords API and Google Ads API Forum
Hi @Anthony

I notice that Google Ads Python Library give error on  CENTOS6 with Python 3.8.  It worked ok On Windows.

Here is what I am getting even all is good.

ad_group_criterion.resource_name = agc_service.ad_group_criteria_path(customer_id, ResourceName.format_composite(ad_group_id, criterion_id))
AttributeError: 'AdGroupCriterionServiceClient' object has no attribute 'ad_group_criteria_path'

Any idea?

K Raza

unread,
Mar 5, 2021, 2:29:53 PM3/5/21
to AdWords API and Google Ads API Forum
This is resolved. v6 have some fixes and my script was using old object.

Sorry for this.

Reply all
Reply to author
Forward
0 new messages