Campaign settings using Google Ads API

284 views
Skip to first unread message

cv

unread,
Aug 6, 2020, 11:02:11 AM8/6/20
to AdWords API and Google Ads API Forum
Hi,

I wanted to get All Campaign settings, how would I get same using Google Ads API beta?

I wanted to get

Network Targetting
Set Locations
Set Languages
Set Budget Settings (Accelarate/Standard etc..)

Any other settings we can set for campaigns.

Thanks,



Google Ads API Forum Advisor Prod

unread,
Aug 6, 2020, 3:54:14 PM8/6/20
to chirag....@gmail.com, adwor...@googlegroups.com

Hi,

Thank you for reaching out. You could refer to this code sample on how to set the budget on the campaign. You could refer to this code sample on how to set the targeting criteria on the campaign.

Thanks and regards,
Xiaoming, Google Ads API Team



ref:_00D1U1174p._5004Q23I8vx:ref

cv

unread,
Aug 7, 2020, 1:13:05 AM8/7/20
to AdWords API and Google Ads API Forum
Hi, Xiaoming,

I wanted to get those data and not set the data.
If you could help how I can get all campaign settings would be helpful.

Thanks,

Google Ads API Forum Advisor Prod

unread,
Aug 7, 2020, 12:07:44 PM8/7/20
to chirag....@gmail.com, adwor...@googlegroups.com

Hi,

Thank you for reaching out. You could see a list of the CampaignCriterion that you can apply to the campaign and then query the campaign_criterion resource to fetch the corresponding data. For Network and Budget, you could query them from the campaign resource.



Thanks and regards,
Xiaoming, Google Ads API Team



ref:_00D1U1174p._5004Q23I8vx:ref

cv

unread,
Aug 10, 2020, 9:36:23 AM8/10/20
to AdWords API and Google Ads API Forum
Hello Xiaoming,

campaign_criterion I can only access through GAQL?

Is there no other way to directly get those values? Means like v201809 we can get the data through service usage.

Thanks,

Google Ads API Forum Advisor Prod

unread,
Aug 10, 2020, 2:26:23 PM8/10/20
to chirag....@gmail.com, adwor...@googlegroups.com

Hi,

Thank you for reaching out. Yes, you could get the same results by calling the service CampaignCriterionService.GetCampaignCriterion() but getting them through the report is always recommended since the get call in the Google Ads API is more expensive.



Thanks and regards,
Xiaoming, Google Ads API Team



ref:_00D1U1174p._5004Q23I8vx:ref

cv

unread,
Aug 12, 2020, 10:32:23 AM8/12/20
to AdWords API and Google Ads API Forum
Hi Xiaoming,
I am not able to get Location and Language using campaignCriterion Service.
I was using like this
Query:
SELECT
                        campaign.id,
                        campaign.name,
                        campaign.status,
                        campaign.serving_status,
                        campaign.network_settings.target_content_network,
                        campaign.network_settings.target_partner_search_network,
                        campaign.network_settings.target_google_search,
                        campaign.network_settings.target_search_network,
                        campaign_criterion.location.geo_target_constant,
                        campaign_criterion.language.language_constant,
                        campaign.advertising_channel_type,
                        campaign.ad_serving_optimization_status,
                        campaign.bidding_strategy,
                        campaign.bidding_strategy_type,
                        campaign.frequency_caps
                    FROM
                       campaign_criterion

and Reading google Ads row reason

$googleAdsRow->getCampaignCriterion()->getLocation()->getGeoTargetConstantUnwrapped() 
$googleAdsRow->getCampaignCriterion()->getLanguage()->getLanguageConstantUnwrapped() 
                    
This is giving error.

Also I would like to use repeat fields like frequency caps is giving object how I can retrive same?
$googleAdsRow->getCampaign()->getFrequencyCaps() 

Google\Protobuf\Internal\RepeatedField Object

                (

                )

Thanks,

Google Ads API Forum Advisor Prod

unread,
Aug 12, 2020, 3:12:38 PM8/12/20
to chirag....@gmail.com, adwor...@googlegroups.com

Hi,

Thank you for reaching out. Please confirm that you have set the Location and Language using CampaignCriterionService. For frequency_caps, as it contains both key and value so it is returned as an object. You would need to query the campaign resource to fetch the campaign.frequency_caps



Thanks and regards,
Xiaoming, Google Ads API Team



ref:_00D1U1174p._5004Q23I8vx:ref

cv

unread,
Aug 13, 2020, 1:28:34 AM8/13/20
to AdWords API and Google Ads API Forum

Hello Xiaoming,

Yes,  I was fetching like this only.

$googleAdsRow->getCampaignCriterion()->getLocation()->getGeoTargetConstantUnwrapped() 
$googleAdsRow->getCampaignCriterion()->getLanguage()->getLanguageConstantUnwrapped() 

It was already set by the user in the UI, I am just getting those values through API. I am not setting any values.
For that I was using campaign_criterion resource as suggested by you.

I want to get those values.

For that I was using as explained in my previous reply.

For frequency cap as well. I was getting the value but it only return object instead value.
As you can see that I was quesrying campaign resource only 
$googleAdsRow->getCampaign()->getFrequencyCaps() 

So my question here is how I can get those repeated fields object using API?

Thanks,

cv

unread,
Aug 13, 2020, 6:47:34 AM8/13/20
to AdWords API and Google Ads API Forum
Hi,

When I tried to fetch Location and Language through campaign_criterion view.
I am getting error that Call to a member function getLanguageConstant() on null

I cannot use campaign_criterion.location.geo_target_constant using campaign_criterion view?
If this is the case how I can identify what view need to be use to get those data?
There must be simpler API explanation which view I need to use?

I am using like this
$googleAdsRow->getCampaignCriterion()->getLocation()->getGeoTargetConstantUnwrapped() 
$googleAdsRow->getCampaignCriterion()->getLanguage()->getLanguageConstantUnwrapped()

when doc said I can get those using campaign_criterion resource It must be used.


Thanks


Google Ads API Forum Advisor Prod

unread,
Aug 13, 2020, 2:51:08 PM8/13/20
to chirag....@gmail.com, adwor...@googlegroups.com

Hi,

Thank you for reaching out. For the frequency cap, you would need to query campaign.frequency_caps from campaign resource first and then you can use $googleAdsRow->getCampaign()->getFrequencyCaps() to get the object. The result is object representing key-value pair which is expected. Could you also please share the complete request and response logs along with the client customer id and the report results via the Reply privately to author option?



Thanks and regards,
Xiaoming, Google Ads API Team



ref:_00D1U1174p._5004Q23I8vx:ref

cv

unread,
Aug 14, 2020, 1:21:59 AM8/14/20
to AdWords API and Google Ads API Forum
Hi Xiaoming,

Reply privately to author is disabled for me. I am not able to post.

But My main question is ignored.

When I tried to fetch Location and Language through campaign_criterion view.
I am getting error that Call to a member function getLanguageConstant() on null

I cannot use campaign_criterion.location.geo_target_constant using campaign_criterion view?
If this is the case how I can identify what view need to be use to get those data?
There must be simpler API explanation which view I need to use?

I am using like this
$googleAdsRow->getCampaignCriterion()->getLocation()->getGeoTargetConstantUnwrapped() 
$googleAdsRow->getCampaignCriterion()->getLanguage()->getLanguageConstantUnwrapped()

when doc said I can get those using campaign_criterion resource It must be used.

Thanks

cv

unread,
Aug 14, 2020, 11:12:29 AM8/14/20
to AdWords API and Google Ads API Forum
I have shared the log on the email.

Google Ads API Forum Advisor Prod

unread,
Aug 14, 2020, 12:41:41 PM8/14/20
to chirag....@gmail.com, adwor...@googlegroups.com

Hi,

We have received the logs and will discuss further in the new thread.



Thanks and regards,
Xiaoming, Google Ads API Team



ref:_00D1U1174p._5004Q23I8vx:ref

cv

unread,
Mar 3, 2021, 2:53:44 AM3/3/21
to AdWords API and Google Ads API Forum
Hi,

I need to get FrequencyCapMaxImpressions from Adwords API to Google Ads API.

I am not able to get those details in Google Ads API.
I am using campaign.frequency_caps fields in SELECT agsing FROM campaign.

Can you please check which fields I need to use?

cv

unread,
Mar 3, 2021, 5:17:26 AM3/3/21
to AdWords API and Google Ads API Forum
Hi,

When I tried to retrieved frequency cap like this It is giving me error.

Call to undefined method Google\Protobuf\Internal\RepeatedField::getCap()


Is this  not correct way to get repeated fields?

                   foreach ($campaign->getFrequencyCaps()  as $frequencyCapEntry) {
                        $freCaps[] = array($frequencyCapEntry->getCap());
                    }

                   foreach ($campaign->getFrequencyCaps() as $frequencyCapEntry) {
                    $freCaps[] = array(
                        'key' => array(
                            'level'=> $frequencyCapEntry->getKey()->getLevel(),
                            'event_type'=> $frequencyCapEntry->getKey()->getEventType(),
                            'time_unit'=> $frequencyCapEntry->getKey()->getTimeUnit(),
                            'time_length'=> $frequencyCapEntry->getKey()->getTimeLength()
                        ),
                        'cap' => $frequencyCapEntry->getCap()
                    );
                }
                

Google Ads API Forum Advisor Prod

unread,
Mar 3, 2021, 12:27:31 PM3/3/21
to chirag....@gmail.com, adwor...@googlegroups.com

Hi,

Thank you for reaching out. You could query the campaign.frequency_caps from the campaign resource. You could refer to this code snippet on how to for loop the results.



Thanks and regards,
Xiaoming, Google Ads API Team
 


Google Logo
Xiaoming
Google Ads API Team
 


ref:_00D1U1174p._5004Q23I8vx:ref
Reply all
Reply to author
Forward
0 new messages