update keyword's bidding not working

69 views
Skip to first unread message

Wizard Meccup

unread,
Nov 23, 2016, 8:18:10 AM11/23/16
to AdWords API Forum
Hi,

I try to set(update) keyword's bidding with BatchJobService on PHP.
I create several operation:

foreach ($keywordsData as $keywordData) {
   
// Create ad group criterion.
    $adGroupCriterion
= new BiddableAdGroupCriterion();
    $adGroupCriterion
->adGroupId = $keywordData['adGroupId'];
    $adGroupCriterion
->criterion = new Criterion($keywordData['id'], 'KEYWORD');

   
// Set bids (optional).
    $bid
= new CpcBid();
    $bid
->bid = new Money($keywordData['bid'] * self::MICRO_AMOUNT);
    $bid
->cpcBidSource = 'CRITERION';

    $biddingStrategyConfiguration
= new BiddingStrategyConfiguration();
    $biddingStrategyConfiguration
->biddingStrategyType = 'MANUAL_CPC';
    $biddingStrategyConfiguration
->biddingStrategySource = 'CRITERION';

    $cpcBiddingScheme
= new ManualCpcBiddingScheme();
    $cpcBiddingScheme
->enhancedCpcEnabled = false;
    $biddingStrategyConfiguration
->biddingScheme = $cpcBiddingScheme;

    $biddingStrategyConfiguration
->bids[] = $bid;
    $adGroupCriterion
->biddingStrategyConfiguration = $biddingStrategyConfiguration;

   
// Create operation.
    $operation
= new AdGroupCriterionOperation();
    $operation
->operand = $adGroupCriterion;
    $operation
->operator = 'SET';

    $operations
[] = $operation;
}



There is one of operation:

[4] => AdGroupCriterionOperation Object
    (
        [operand] => BiddableAdGroupCriterion Object
            (
                [userStatus] =>
                [systemServingStatus] =>
                [approvalStatus] =>
                [disapprovalReasons] =>
                [destinationUrl] =>
                [experimentData] =>
                [firstPageCpc] =>
                [topOfPageCpc] =>
                [firstPositionCpc] =>
                [qualityInfo] =>
                [biddingStrategyConfiguration] => BiddingStrategyConfiguration Object
                    (
                        [biddingStrategyId] =>
                        [biddingStrategyName] =>
                        [biddingStrategyType] => MANUAL_CPC
                        [biddingStrategySource] => CRITERION
                        [biddingScheme] => ManualCpcBiddingScheme Object
                            (
                                [enhancedCpcEnabled] =>
                                [BiddingSchemeType] =>
                                [_parameterMap:BiddingScheme:private] => Array
                                    (
                                        [BiddingScheme.Type] => BiddingSchemeType
                                    )

                            )

                        [bids] => Array
                            (
                                [0] => CpcBid Object
                                    (
                                        [bid] => Money Object
                                            (
                                                [microAmount] => 51300000
                                                [ComparableValueType] =>
                                                [_parameterMap:ComparableValue:private] => Array
                                                    (
                                                        [ComparableValue.Type] => ComparableValueType
                                                    )

                                            )

                                        [cpcBidSource] => CRITERION
                                        [BidsType] =>
                                        [_parameterMap:Bids:private] => Array
                                            (
                                                [Bids.Type] => BidsType
                                            )

                                    )

                            )

                    )

                [bidModifier] =>
                [finalUrls] =>
                [finalMobileUrls] =>
                [finalAppUrls] =>
                [trackingUrlTemplate] =>
                [urlCustomParameters] =>
                [adGroupId] => 8427124XXX
                [criterionUse] =>
                [criterion] => Criterion Object
                    (
                        [id] => 41399813XXX
                        [type] => KEYWORD
                        [CriterionType] =>
                        [_parameterMap:Criterion:private] => Array
                            (
                                [Criterion.Type] => CriterionType
                            )

                    )

                [labels] =>
                [forwardCompatibilityMap] =>
                [baseCampaignId] =>
                [baseAdGroupId] =>
                [AdGroupCriterionType] =>
                [_parameterMap:AdGroupCriterion:private] => Array
                    (
                        [AdGroupCriterion.Type] => AdGroupCriterionType
                    )

            )

        [exemptionRequests] =>
        [operator] => SET
        [OperationType] =>
        [_parameterMap:Operation:private] => Array
            (
                [Operation.Type] => OperationType
            )
    )

Then i try to upload it:

$batchJobUtils = new BatchJobUtils($uploadUrl);
$batchJobUtils
->UploadBatchJobOperations($operations);


There is an uploading result as XML object:

[result] => SimpleXMLElement Object
    (
        [AdGroupCriterion] => SimpleXMLElement Object
            (
                [adGroupId] => 8427124XXX
                [criterion] => SimpleXMLElement Object
                    (
                        [id] => 41399813XXX
                        [type] => KEYWORD
                        [Criterion.Type] => Keyword
                        [text] => XXXXXXXXXX XXXXXXXX XX
                        [matchType] => PHRASE
                    )

                [AdGroupCriterion.Type] => BiddableAdGroupCriterion
                [userStatus] => ENABLED
                [systemServingStatus] => ELIGIBLE
                [approvalStatus] => APPROVED
                [biddingStrategyConfiguration] => SimpleXMLElement Object
                    (
                        [biddingStrategyType] => MANUAL_CPC
                        [biddingStrategySource] => CRITERION
                        [biddingScheme] => SimpleXMLElement Object
                            (
                                [BiddingScheme.Type] => ManualCpcBiddingScheme
                                [enhancedCpcEnabled] => false
                            )

                        [bids] => Array
                            (
                                [0] => SimpleXMLElement Object
                                    (
                                        [Bids.Type] => CpmBid
                                        [bid] => SimpleXMLElement Object
                                            (
                                                [ComparableValue.Type] => Money
                                                [microAmount] => 7000000
                                            )

                                        [cpmBidSource] => ADGROUP
                                    )

                                [1] => SimpleXMLElement Object
                                    (
                                        [Bids.Type] => CpcBid
                                        [bid] => SimpleXMLElement Object
                                            (
                                                [ComparableValue.Type] => Money
                                                [microAmount] => 100000000
                                            )

                                        [cpcBidSource] => ADGROUP
                                    )

                            )

                    )

            )

    )
)

But bids are not setted from operation bid. And cpcBidSource equal to "ADGROUP", but must be equal to "CRITERION".
Campaing has type "Only Search Network".

Why i can't set the bid to keywords?
What wrong with my code?

Anthony Madrigal

unread,
Nov 23, 2016, 10:22:23 AM11/23/16
to AdWords API Forum
Hi,

CpcBidSource and BiddingStrategySource are read-only fields so they will be ignored when using them. However, if you set the Cpc bids for keywords they should turn to CRITERION level, which is not happening like you said. Because of this, could you please provide me with the SOAP request and response for this API call and the adgroup Id and keyword Id that you are trying to set through reply privately to author?

Thanks,
Anthony
AdWords API Team

Wizard Meccup

unread,
Nov 24, 2016, 2:35:39 AM11/24/16
to AdWords API Forum
However, when i try to set bids not using BatchJob, it works fine and all bids are setted. What wrong with BatchJob?


public function updateKeywordsBidSingle(array $keywordsData)
{
    $return = array();
    try {
        foreach ($keywordsData as $key => $keywordData) {
            $adGroupCriterionService = $this->getUser()->GetService('AdGroupCriterionService', self::API_VERSION);

            // Create ad group criterion.
            $adGroupCriterion = new BiddableAdGroupCriterion();
            $adGroupCriterion->adGroupId = $keywordData['adGroupId'];
            $adGroupCriterion->criterion = new Criterion($keywordData['id']);

            // Set bids (optional).
            $bid = new CpcBid();
            $bid->bid = new Money($this->calcMoney($keywordData['bid']));
            $biddingStrategyConfiguration = new BiddingStrategyConfiguration();
            $biddingStrategyConfiguration->biddingStrategyType = 'MANUAL_CPC';
            $biddingStrategyConfiguration->bids[] = $bid;
            $adGroupCriterion->biddingStrategyConfiguration = $biddingStrategyConfiguration;

            // Create operation.
            $operation = new AdGroupCriterionOperation();
            $operation->operand = $adGroupCriterion;
            $operation->operator = self::OPERATOR_SET;

            $operations = array($operation);

            // Make the mutate request.
            $result = $adGroupCriterionService->mutate($operations);

            $return[$key] = $result->value[0];
        }
    } catch (Exception $e) {
        throw $e;
    }

    return $return;
}





среда, 23 ноября 2016 г., 18:22:23 UTC+3 пользователь Anthony Madrigal написал:

Thanet Knack Praneenararat (AdWords API Team)

unread,
Nov 24, 2016, 10:08:25 AM11/24/16
to AdWords API Forum
Hello Wizard,

I can't reproduce the issue you've reported. Everything looks fine on my side.
I can set the CpcBids by using both AdGroupCriterionService and BatchJobService.

Could you please double-check your code?
It looks like you might accidentally override the bids at ad group level somewhere in your code.
Could you remove $bid->cpcBidSource = 'CRITERION'; and try again, maybe, only on one keyword first?

Thanks in advance.

Best,
Thanet, AdWords API Team
Reply all
Reply to author
Forward
0 new messages