Changing frequency capping on display campaigns using JAVA api

55 views
Skip to first unread message

Aba

unread,
Nov 19, 2016, 10:26:39 PM11/19/16
to AdWords API Forum
Hi all,

How would I change the frequency capping on display campaigns using the JAVA adwords api ? 

Thanks for all your help,
Aba

Aba

unread,
Nov 19, 2016, 10:39:34 PM11/19/16
to AdWords API Forum
                                                   

campaign.getFrequencyCap().setImpressions((long)theNumber);
CampaignOperation operation = new CampaignOperation();
operation.setOperand(campaign);
operation.setOperator(Operator.SET);
  CampaignOperation[] operations = new CampaignOperation[] {operation};
 CampaignReturnValue result = campaignService.mutate(operations);

is the solution .

Peter Oliquino

unread,
Nov 21, 2016, 12:28:53 AM11/21/16
to AdWords API Forum
Hi Aba,

My apologies for the delay. I believe it should be campaign.setFrequencyCap() instead of campaign.getFrequencyCap() if you wish to change the frequency capping. You may refer below to the sample code snippet and SOAP request on how to update your campaign with a new frequency cap :

    //Set your preferred impressions value (1000000000L), Time Unit and Level
    FrequencyCap frequencyCap = new FrequencyCap(1000000000L, TimeUnit.DAY, Level.CAMPAIGN);
    // Create campaign with updated status.
    Campaign campaign = new Campaign();
    campaign.setId(campaignId);
    campaign.setStatus(CampaignStatus.PAUSED);
    campaign.setFrequencyCap(frequencyCap);
    // Create operations.

    CampaignOperation operation = new CampaignOperation();
    operation.setOperand(campaign);
    operation.setOperator(Operator.SET);
    CampaignOperation[] operations = new CampaignOperation[] {operation};


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header>
        <ns1:RequestHeader xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201609" soapenv:mustUnderstand="0">
            <ns1:clientCustomerId>YOUR_CUSTOMER_ID</ns1:clientCustomerId>
            <ns1:developerToken>YOUR_DEVELOPER_TOKEN</ns1:developerToken>
            <ns1:userAgent>YOUR_USER_AGENT</ns1:userAgent>
            <ns1:validateOnly>false</ns1:validateOnly>
            <ns1:partialFailure>false</ns1:partialFailure>
        </ns1:RequestHeader>
    </soapenv:Header>
    <soapenv:Body>
        <mutate xmlns="https://adwords.google.com/api/adwords/cm/v201609">
            <operations>
                <operator>SET</operator>
                <operand>
                    <id>YOUR_CAMPAIGN_ID</id>
                    <status>PAUSED</status>
                    <frequencyCap>
                        <impressions>1000000000</impressions>
                        <timeUnit>DAY</timeUnit>
                        <level>CAMPAIGN</level>
                    </frequencyCap>
                </operand>
            </operations>
        </mutate>
    </soapenv:Body>
</soapenv:Envelope>

I hope this helps and kindly let me know if you require more help with the issue.

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