Coder Social home page Coder Social logo

Comments (4)

eric-urban avatar eric-urban commented on May 20, 2024

@aleinv18 you can add up to 100 LocationCriterion per AddCampaignCriterions or AddAdGroupCriterions request. The maximum number of combined location and negative location criterions that you can specify per campaign or ad group is 10,000. Let's take AddCampaignCriterions as an example. You would create up to 100 BiddableCampaignCriterion objects, and each would contain a LocationCriterion. If you want to exclude any locations then use NegativeCampaignCriterion (instead of BiddableCampaignCriterion) that contains a LocationCriterion.

Please let me know if you have any follow up questions.

from advertising-docs.

aleinv18 avatar aleinv18 commented on May 20, 2024

hi @eric-urban,
thank you for your reply.
Ok, but at code level where i have to insert the array of location?
I would send an unique SOAP request with all locations included

Thank you

from advertising-docs.

eric-urban avatar eric-urban commented on May 20, 2024

@aleinv18 yes the result can be one SOAP request message. You can append BiddableCampaignCriterion objects to the array of campaign criteria. Here is a Python sample:

campaign_criterions=campaign_service.factory.create('ArrayOfCampaignCriterion')

us_campaign_location_criterion=set_elements_to_none(campaign_service.factory.create('BiddableCampaignCriterion'))
us_campaign_location_criterion.Type='BiddableCampaignCriterion'
us_campaign_location_criterion.CampaignId=campaign_ids['long'][0]
us_bid_multiplier=set_elements_to_none(campaign_service.factory.create('BidMultiplier'))
us_bid_multiplier.Type='BidMultiplier'
us_bid_multiplier.Multiplier=0
us_campaign_location_criterion.CriterionBid=us_bid_multiplier                
us_location_criterion=set_elements_to_none(campaign_service.factory.create('LocationCriterion'))
us_location_criterion.Type='LocationCriterion'
# United States
us_location_criterion.LocationId=190
us_campaign_location_criterion.Criterion=us_location_criterion
campaign_criterions.CampaignCriterion.append(us_campaign_location_criterion)

canada_campaign_location_criterion=set_elements_to_none(campaign_service.factory.create('BiddableCampaignCriterion'))
canada_campaign_location_criterion.Type='BiddableCampaignCriterion'
canada_campaign_location_criterion.CampaignId=campaign_ids['long'][0]
canada_bid_multiplier=set_elements_to_none(campaign_service.factory.create('BidMultiplier'))
canada_bid_multiplier.Type='BidMultiplier'
canada_bid_multiplier.Multiplier=0
canada_campaign_location_criterion.CriterionBid=canada_bid_multiplier                
canada_location_criterion=set_elements_to_none(campaign_service.factory.create('LocationCriterion'))
canada_location_criterion.Type='LocationCriterion'
# Canada
canada_location_criterion.LocationId=32
canada_campaign_location_criterion.Criterion=canada_location_criterion
campaign_criterions.CampaignCriterion.append(canada_campaign_location_criterion)

output_status_message("-----\nAddCampaignCriterions:")
add_campaign_criterions_response = campaign_service.AddCampaignCriterions(
    CampaignCriterions=campaign_criterions,
    CriterionType='Targets'
)

Here is the resulting SOAP request:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="https://bingads.microsoft.com/CampaignManagement/v13" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="https://bingads.microsoft.com/CampaignManagement/v13" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header>
      <tns:AuthenticationToken>YourAccessTokenGoesHere</tns:AuthenticationToken>
      <tns:CustomerAccountId>YourAccountIdGoesHere</tns:CustomerAccountId>
      <tns:CustomerId>YourCustomerIdGoesHere</tns:CustomerId>
      <tns:DeveloperToken>YourDeveloperTokenGoesHere</tns:DeveloperToken>
   </SOAP-ENV:Header>
   <ns1:Body>
      <ns0:AddCampaignCriterionsRequest>
         <ns0:CampaignCriterions>
            <ns0:CampaignCriterion xsi:type="ns0:BiddableCampaignCriterion">
               <ns0:CampaignId>YourCampaignIdGoesHere</ns0:CampaignId>
               <ns0:Criterion xsi:type="ns0:LocationCriterion">
                  <ns0:Type>LocationCriterion</ns0:Type>
                  <ns0:LocationId>190</ns0:LocationId>
               </ns0:Criterion>
               <ns0:Type>BiddableCampaignCriterion</ns0:Type>
               <ns0:CriterionBid xsi:type="ns0:BidMultiplier">
                  <ns0:Type>BidMultiplier</ns0:Type>
                  <ns0:Multiplier>0</ns0:Multiplier>
               </ns0:CriterionBid>
            </ns0:CampaignCriterion>
            <ns0:CampaignCriterion xsi:type="ns0:BiddableCampaignCriterion">
               <ns0:CampaignId>YourCampaignIdGoesHere</ns0:CampaignId>
               <ns0:Criterion xsi:type="ns0:LocationCriterion">
                  <ns0:Type>LocationCriterion</ns0:Type>
                  <ns0:LocationId>32</ns0:LocationId>
               </ns0:Criterion>
               <ns0:Type>BiddableCampaignCriterion</ns0:Type>
               <ns0:CriterionBid xsi:type="ns0:BidMultiplier">
                  <ns0:Type>BidMultiplier</ns0:Type>
                  <ns0:Multiplier>0</ns0:Multiplier>
               </ns0:CriterionBid>
            </ns0:CampaignCriterion>
         </ns0:CampaignCriterions>
         <ns0:CriterionType>Targets</ns0:CriterionType>
      </ns0:AddCampaignCriterionsRequest>
   </ns1:Body>
</SOAP-ENV:Envelope>

I hope this helps!

from advertising-docs.

aleinv18 avatar aleinv18 commented on May 20, 2024

u are very kind. Thank you so much!

from advertising-docs.

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.