Where can I check the adjusted bid I made in a placement?

114 views
Skip to first unread message

br...@blvnp.com

unread,
Oct 3, 2017, 1:53:39 AM10/3/17
to AdWords API Forum

Good day,


I am just wondering if where can I view or check the adjusted bid that I made in a placement?

I would want to view the adjustment to make sure that the changes or the code that I run thru the API was successful. 


Is it on VIEW HISTORY, like the image below?



or in the Display Network? Please see the image below.


Am I doing it right?

Here is my code:


const BID_MODIFIER = '2';


     public static function runExample(AdWordsServices $adWordsServices,

     AdWordsSession $session, $campaignId, $bidModifier) {

     campaignCriterionService =

     $adWordsServices->get($session, CampaignCriterionService::class);

     $urlPlacement = new Placement();

     $urlPlacement->setUrl('websitehere.com');

     $urlPlacement->setId(30000);

    // Create a criterion with modified bid.

    $criterion = new CampaignCriterion();

    $criterion->setCampaignId($campaignId);

    $criterion->setCriterion($urlPlacement);

    $criterion->setBidModifier($bidModifier);


    $operation = new CampaignCriterionOperation();

    $operation->setOperator(Operator::SET);

    $operation->setOperand($criterion);

    $operations = [$operation];


    $results = $campaignCriterionService->mutate($operations);


    // Print out some information about the updated campaign criterion.

    foreach ($results->getValue() as $campaignCriterion) {

      printf(

          "Campaign criterion with campaign ID %d, criterion ID %d, "

              . "and type '%s' was modified with bid %.2f.\n",

          $campaignCriterion->getCampaignId(),

          $campaignCriterion->getCriterion()->getId(),

          $campaignCriterion->getCriterion()->getType(),

          $campaignCriterion->getBidModifier());

    }

  }


Thank you so much,

Ben

Vincent Racaza (AdWords API Team)

unread,
Oct 3, 2017, 4:56:02 AM10/3/17
to AdWords API Forum
Hi,

You can use the 2nd screenshot (Display network tab) to check if the changes to your bidModifier for placement was applied. You may also use the "View history" if you want to check for the detailed change history of an entity.

Also, based on your second screenshot for the "listverse.com" placement, your placement is under an ad group, therefore, you need to use the BiddableAdGroupCriterion of AdGroupCriterionService in setting the bidModifier, and not the CampaignCriterion. You can refer to the sample SOAP request below so you can emulate:

<soapenv:Body>
   
<mutate xmlns="https://adwords.google.com/api/adwords/cm/v201708">
       
<operations>
           
<operator>SET</operator>
           
<operand xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201708" xsi:type="ns2:BiddableAdGroupCriterion">
               
<ns2:adGroupId>XXXXXXXXXXX</ns2:adGroupId>
               
<ns2:criterion xsi:type="ns2:Placement">
                   
<ns2:id>XXXXXXXXXXX</ns2:id>
                   
<ns2:url>site.www.hello.com</ns2:url>
               
</ns2:criterion>
               
<ns2:bidModifier>1.5</ns2:bidModifier>
           
</operand>
       
</operations>
   
</mutate>
</soapenv:Body>

Let me know if you have further clarifications.

Thanks,
Vincent
AdWords API Team

br...@blvnp.com

unread,
Oct 3, 2017, 5:08:43 AM10/3/17
to AdWords API Forum
Hello Vincent,

Thank you for your reply. Do you have a sample code that I can based my code on? I am using PHP. But I will just convert your answer code to PHP. I will start from there.
Thank you so much for answering, this would be very useful.

Ben

Vincent Racaza (AdWords API Team)

unread,
Oct 3, 2017, 5:39:43 AM10/3/17
to AdWords API Forum
Hi Ben,

You can refer to the below Java code on which you can convert to PHP as this is just a simple code:

Placement urlPlacement = new Placement();
urlPlacement
.setId(XXXXXXXXXXX);
urlPlacement
.setUrl("site.www.hello.com");

BiddableAdGroupCriterion adGroupCriterion = new BiddableAdGroupCriterion();
adGroupCriterion
.setAdGroupId(XXXXXXXXXXX);
adGroupCriterion
.setCriterion(urlPlacement);
adGroupCriterion
.setBidModifier(BID_MODIFIER);
   
AdGroupCriterionOperation operation = new AdGroupCriterionOperation();
operation
.setOperand(adGroupCriterion);
operation
.setOperator(Operator.SET);
   
AdGroupCriterionServiceInterface adGroupCriterionService =
adWordsServices
.get(session, AdGroupCriterionServiceInterface.class);
   
AdGroupCriterionReturnValue result =
    adGroupCriterionService
.mutate(new AdGroupCriterionOperation[] {operation});

Let me know if this helps.

br...@blvnp.com

unread,
Oct 4, 2017, 1:36:40 AM10/4/17
to AdWords API Forum
Thank you so much for the answer, Vincent. 

May I know the whole Java code for this? Do you have a link for the sample? I kept on getting errors after replacing some lines on my code.
Sorry, I am just new in adwords api but this is not an excuse. I just want to know the whole code, maybe I miss something.

Thank you,
Ben

May I ask the whole

Vincent Racaza (AdWords API Team)

unread,
Oct 4, 2017, 3:09:55 AM10/4/17
to AdWords API Forum
Hi Ben,

Please see attached file for my complete Java code for setting bid modifier in a placement. Also, as a suggestion, please enable your SOAP logs if you haven't done so by following the "Configuring logging" section of this document. The SOAP logs is helpful to know if your request is successful, or if there are errors, you can check for the actual reason of the error.
SetBidModifierInPlacement.txt

br...@blvnp.com

unread,
Oct 4, 2017, 3:14:45 AM10/4/17
to AdWords API Forum
Thank you so much, Vincent. I will based the of the code from here. Thank you for the suggestion. I will let you know if I got it right.

Thanks,
Ben

br...@blvnp.com

unread,
Oct 4, 2017, 4:12:31 AM10/4/17
to AdWords API Forum
Hi Vincent, 

I just want to clarify something

    Placement urlPlacement = new Placement();
    urlPlacement.setId(XXXXXXXXXXXXXXXXX);
    urlPlacement.setUrl("site.www.hello.com");

Where can I find the "urlPlacement.setId"? 

Thank you so much,
Ben

Vincent Racaza (AdWords API Team)

unread,
Oct 4, 2017, 5:03:30 AM10/4/17
to AdWords API Forum
Hi Ben,

If what you meant is the actual value of the placement ID, then you can use the AdGroupCriterionService.get() and filter it by PLACEMENT criterionType (and other fields that you can filter) to get the id and other fields of the placement. You can refer to the sample SOAP request snippet below:

<soapenv:Body>
   
<get xmlns="https://adwords.google.com/api/adwords/cm/v201708">
       
<serviceSelector>
           
<fields>Id</fields>
           
<fields>CriteriaType</fields>
           
<fields>BidModifier</fields>
           
<fields>PlacementUrl</fields>
           
<predicates>
               
<field>CriteriaType</field>
               
<operator>EQUALS</operator>
               
<values>PLACEMENT</values>
           
</predicates>
           
<paging>
               
<startIndex>0</startIndex>
               
<numberResults>100</numberResults>
           
</paging>
       
</serviceSelector>
   
</get>
</soapenv:Body>

For the urlPlacement.setId(XXXX) line, the ID must be the preferred placement ID on which you would like to update. In your scenario, it would be the ID of your "listverse.com" placement. 

br...@blvnp.com

unread,
Oct 5, 2017, 1:55:48 AM10/5/17
to AdWords API Forum
Good day Vincent,

I am still confused why I can't update the bid of the placement.
Here is my code:

<?php
/**
 * Copyright 2017 Google Inc. All Rights Reserved.
 */
namespace Google\AdsApi\Examples\AdWords\v201705\CampaignManagement;

require __DIR__ . '/../../vendor/autoload.php';

use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSession;
use Google\AdsApi\AdWords\AdWordsServicesInterface;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201705\cm\AdGroupCriterionOperation;
use Google\AdsApi\AdWords\v201705\cm\AdGroupCriterionReturnValue;
use Google\AdsApi\AdWords\v201705\cm\AdGroupCriterionService;
use Google\AdsApi\AdWords\v201705\cm\BiddableAdGroupCriterion;
use Google\AdsApi\AdWords\v201705\cm\Operator;
use Google\AdsApi\AdWords\v201705\cm\Placement;
use Google\AdsApi\AdWords\v201705\cm\Platform;
use Google\AdsApi\Common\OAuth2TokenBuilder;

/**
 * This example sets a bid modifier on a campaign.
 */
class SetBidModifierInPlacement {
  const AD_GROUP_ID = '49443081811';
  const BID_MODIFIER = '1.5';

  public static function runExample(AdWordsServices $adWordsServices,
      AdWordsSession $session) {
    $campaignCriterionService =
        $adWordsServices->get($session, AdGroupCriterionService::class);

    //Create a mobile platform. The ID can be found in the documentation.
    $desktop= new Platform();
    $desktop->setId(30000); // HighEndMobile = 30001
    $urlPlacement = new Placement();
    $urlPlacement->setUrl('listverse.com');
    $urlPlacement->setId('0');
    // Create a criterion with modified bid.
    $adGroup = new BiddableAdGroupCriterion();
    $adGroup->setAdGroupId($AD_GROUP_ID );
    $adGroup->setCriterion($urlPlacement);
    $adGroup->setBidModifier($bidModifier);

    // Create a campaign criterion operation and add it to the operations list.
    $operation = new AdGroupCriterionOperation();
    $operation->setOperator(Operator::SET);
    $operation->setOperand($adGroup);
    $operations = [$operation];

    // Update campaign criteria on the server.
    $results = $adGroupCriterionService->mutate($operations);

    // Print out some information about the updated campaign criterion.
    foreach ($results->getValue() as $adGroupCriterion) {
      printf(
          "Campaign criterion with campaign ID %d, criterion ID %d, "
              . "and type '%s' was modified with bid %.2f.\n",
          $AdGroupCriterion->getAdGroupId(),
          $AdGroupCriterion->getCriterion()->getId(),
          $AdGroupCriterion->getCriterion()->getType(),
          $AdGroupCriterion->getBidModifier());
    }
  }

  public static function main() {
    // Generate a refreshable OAuth2 credential for authentication.
    $oAuth2Credential = (new OAuth2TokenBuilder())
        ->fromFile()
        ->build();

    // Construct an API session configured from a properties file and the OAuth2
    // credentials above.
    $session = (new AdWordsSessionBuilder())
        ->fromFile()
        ->withOAuth2Credential($oAuth2Credential)
        ->build();
   self::runExample(new AdWordsServices(), $session, intval(self::AD_GROUP_ID),
       floatval(self::BID_MODIFIER));
  }
}

SetBidModifierInPlacement::main();

End

I am getting the error:

Fatal error: Call to a member function mutate() on null.

Please enlighten me.

Thank you so much,
Ben

Vincent Racaza (AdWords API Team)

unread,
Oct 5, 2017, 3:44:38 AM10/5/17
to AdWords API Forum
Hi Ben,

I was able to replicate your issue in my test account. This was due to incorrect variable referencing in your code. Please see updates below in your PHP code (in bold) which works successfully on my end:

public static function runExample(AdWordsServices $adWordsServices,

     
AdWordsSession $session, $AD_GROUP_ID, $bidModifier) {
   
$adGroupCriterionService =

        $adWordsServices
->get($session, AdGroupCriterionService::class);

   
//Create a mobile platform. The ID can be found in the documentation.
   
//https://developers.google.com/adwords/api/docs/appendix/platforms
    $desktop
= new Platform();
    $desktop
->setId(30000); // HighEndMobile = 30001
 
    $urlPlacement
= new Placement();
    $urlPlacement
->setUrl('listverse.com');

    $urlPlacement
->setId('XXXXXXXXXX');

 
   
// Create a criterion with modified bid.
    $adGroup
= new BiddableAdGroupCriterion();
    $adGroup
->setAdGroupId($AD_GROUP_ID );
    $adGroup
->setCriterion($urlPlacement);
    $adGroup
->setBidModifier($bidModifier);

   
// Create a campaign criterion operation and add it to the operations list.
    $operation
= new AdGroupCriterionOperation();
    $operation
->setOperator(Operator::SET);
    $operation
->setOperand($adGroup);
    $operations
= [$operation];

   
// Update campaign criteria on the server.
    $results
= $adGroupCriterionService->mutate($operations);

   
// Print out some information about the updated campaign criterion.
   
foreach ($results->getValue() as $adGroupCriterion) {
      printf
(
         
"Campaign criterion with campaign ID %d, criterion ID %d, "
             
. "and type '%s' was modified with bid %.2f.\n",

         
$adGroupCriterion->getAdGroupId(),
         
$adGroupCriterion->getCriterion()->getId(),
         
$adGroupCriterion->getCriterion()->getType(),
         
$adGroupCriterion->getBidModifier());
   
}
 
}

Also, if you have further clarifications on this, I suggest to create a new forum thread so we can track your concerns better as this concern is already on the syntax of your code.

br...@blvnp.com

unread,
Oct 5, 2017, 4:09:35 AM10/5/17
to AdWords API Forum
Thank you so much, Vincent.

My bad. I am very sloppy. It works now. All I need to do is to set the status of the Placement to Manage so that I can get the criterion id. The Status sets to automatic in which I can't get or see the criterion ID.

Anyways, thank you for helping me with this. I really appreciate it.

Thank you so much,
Ben 
Reply all
Reply to author
Forward
0 new messages