As code, I created the negative placement exclusion list and the list for 
the MMC account using Google Ads API. I have created code by referring 
https://developers.google.com/google-ads/api/samples/create-and-attach-shared-keyword-set
 
.
I want to apply the created negative placement exclusion list to the client 
customers (sub-accounts of MMC account) using Google Ads API, how can I do 
that? 
please check my attached code.

On Monday, September 2, 2024 at 9:57:12 AM UTC+5:30 Google Ads API Forum 
Advisor wrote:

> Hi,
>
> Thank you for reaching out to the Google Ads API support team.
>
> You can use the SharedSetService 
> <https://developers.google.com/google-ads/api/reference/rpc/v16/SharedSetService>
>  to 
> manage the shared sets. Also, to add an exclusion list to a campaign, you 
> may create campaign shared sets using *CampaignSharedSetService* 
> <https://developers.google.com/google-ads/api/reference/rpc/v11/CampaignSharedSetService>.
>  
> The *CampaignSharedSets* 
> <https://developers.google.com/google-ads/api/reference/rpc/v11/CampaignSharedSet>
>  are 
> used for managing the shared sets associated with a campaign. Also, you may 
> check the Java sample code 
> <https://developers.google.com/google-ads/api/samples/create-and-attach-shared-keyword-set#java>
>  for 
> creating a shared list of negative broad match keywords using the Google 
> Ads API. Hope this helps. Let us know if you have any further queries. 
>  
> If this is not what you are looking for, kindly provide us with the 
> uncropped UI screenshots of Placement Exclusion List with the visible 
> account that you are trying to use.
>   
> This message is in relation to case 
> "ref:!00D1U01174p.!5004Q02vFZ6O:ref" (ADR-00265759)
>
> Thanks,
>   
> [image: Google Logo] Google Ads API Team 
>
>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/e5049d55-46e3-4131-a347-aa35c25dd012n%40googlegroups.com.
using Google.Ads.Gax.Examples;
using Google.Ads.GoogleAds.Config;
using Google.Ads.GoogleAds.Examples.V17;
using Google.Ads.GoogleAds.Lib;
using Google.Ads.GoogleAds.Util;
using Google.Ads.GoogleAds.V17.Services;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;

namespace Google.Ads.GoogleAds.Examples
{
    /// <summary>
    /// The Main class for this application.
    /// </summary>
    internal class Program
        {
                public static int Main(string[] args)
                {
                        string developerToken = 
"INSERT_YOUR_DEVELOPER_TOKEN_HERE";
            string oAuth2clientId = "INSERT_OAUTH2_CLIENT_ID_HERE";
            string oAuth2Secret = "INSERT_OAUTH2_CLIENT_SECRET_HERE";
            string oAuth2RefreshToken = "INSERT_OAUTH2_REFRESH_TOKEN_HERE";
                        
                        GoogleAdsConfig googleAdsConfig = new GoogleAdsConfig()
                        {
                                DeveloperToken = developerToken,
                                OAuth2ClientId = oAuth2clientId,
                                OAuth2ClientSecret = oAuth2Secret,
                                OAuth2RefreshToken = oAuth2RefreshToken,
                        };
                        GoogleAdsClient googleAdsClient = new 
GoogleAdsClient(googleAdsConfig);
                }
                
                public static void CreatePlacementExclusionList()
                {
                        try
                        {
                                SharedCriterionServiceClient 
sharedCriterionService = client.GetService(
                                        Services.V17.SharedCriterionService);

                                GoogleAdsServiceClient googleAdsService = 
client.GetService(
                                        Services.V17.GoogleAdsService);

                                SharedSetServiceClient sharedSetService = 
client.GetService(
                                Services.V17.SharedSetService);

                                CampaignCriterionServiceClient 
campaignCriterionService = 
client.GetService(Services.V17.CampaignCriterionService);

                                CustomerServiceClient customerService = 
client.GetService(Services.V17.CustomerService);

                                List<long?> sharedSetIds = new List<long?>();
                                List<string> criterionResources = new 
List<string>();
                                List<string> placementUrlList = new 
List<string>();
                                placementUrlList = new List<string>()
                                {
                                        "testsite.com",
                                        "testsite2.com",
                                        "testsite3.com",
                                        "testsite4.com",
                                        "testsite5.com"
                                };
                                
                                SharedSet _sharedSet = new SharedSet()
                                {
                                        Name = "API Negative Placement list - " 
+ ExampleUtilities.GetShortRandomString(),
                                        Type = 
GoogleAds.V17.Enums.SharedSetTypeEnum.Types.SharedSetType.NegativePlacements,
                                };
                                SharedSetOperation _operation = new 
SharedSetOperation()
                                {
                                        Create = _sharedSet
                                };

                                MutateSharedSetsResponse _sharedSetResponse = 
sharedSetService.MutateSharedSets(
                                        customerId.ToString(), new 
SharedSetOperation[] { _operation });

                                string sharedSetResourceName = 
_sharedSetResponse.Results[0].ResourceName;
                                Console.WriteLine($"Created shared set 
{sharedSetResourceName}.");

                                // Finally, Create the criteria.
                                List<SharedCriterionOperation> operations = new 
List<SharedCriterionOperation>();
                                foreach (var url in placementUrlList)
                                {
                                        SharedCriterion sharedCriterion = new 
SharedCriterion()
                                        {
                                                Placement = new 
GoogleAds.V17.Common.PlacementInfo()
                                                {
                                                        Url = url
                                                },
                                                Type = CriterionType.Placement,
                                                SharedSet = 
sharedSetResourceName,
                                                
                                        };
                                        SharedCriterionOperation operation = 
new SharedCriterionOperation()
                                        {
                                                Create = sharedCriterion
                                                //Remove = criterionResource
                                        };
                                        operations.Add(operation);
                                }
                                
                                MutateSharedCriteriaResponse response =
                                sharedCriterionService.MutateSharedCriteria(
                                        customerId.ToString(), operations);
                                        
                                CustomerNegativeCriterion 
customerNegativeCriterion = new()
                                {
                                        ResourceName = sharedSetResourceName,
                                        
                                };

                                List<MutateOperation> mutateOperations = [];

                                MutateOperation mutateOperation = new()
                                {
                                        CustomerNegativeCriterionOperation = 
new CustomerNegativeCriterionOperation()
                                        {
                                                Create = 
customerNegativeCriterion
                                        }
                                };
                                mutateOperations.Add(mutateOperation);
                                MutateGoogleAdsResponse mutateGoogleAdsResponse 
= googleAdsService.Mutate("Client_customer_Id", mutateOperations);
                        }
                        catch (GoogleAdsException e)
                        {
                                Console.WriteLine("Failure:");
                                Console.WriteLine($"Message: {e.Message}");
                                Console.WriteLine($"Failure: {e.Failure}");
                                Console.WriteLine($"Request ID: {e.RequestId}");
                                throw;
                        }
                }
        }
}
  • Ap... Shannon
    • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum
      • ... HARDIK DEGDAWALA

Reply via email to