How do I filter by campaign type?

1,292 views
Skip to first unread message

Dawson Reid

unread,
Feb 18, 2016, 8:56:07 AM2/18/16
to AdWords Scripts Forum
Hi all,

I was wondering how I would go about retrieving only campaigns that are either search xor display. Alternatively, how would I check if a campaign is a search or a display campaign?

All the best,
Dawson.

Sander

unread,
Feb 18, 2016, 9:11:33 AM2/18/16
to AdWords Scripts Forum
Hi,

Will this help?

 
function main() {  

  var report = AdWordsApp.report("SELECT CampaignName, AdNetworkType1 " +
        "FROM CAMPAIGN_PERFORMANCE_REPORT " +
        "DURING TODAY");
  
  
  var rows = report.rows()
    while (rows.hasNext()) {
    var row = rows.next();
      Logger.log(row['CampaignName'] + ": - " + row['AdNetworkType1']) }
  
  
  } 

Dawson Reid

unread,
Feb 18, 2016, 9:33:58 AM2/18/16
to AdWords Scripts Forum
I believe that will. It is a hacky solution, but nice to know I can do that. Thank you :)

Tyler Sidell (AdWords Scripts Team)

unread,
Feb 18, 2016, 9:53:12 AM2/18/16
to AdWords Scripts Forum
Thanks Sander.

@Dawson, let us know if you have any further questions.

Regards,
Tyler Sidell
AdWords Scripts Team

AussieWeb Conversion

unread,
Feb 19, 2016, 12:32:37 AM2/19/16
to AdWords Scripts Forum
Hi Dawson

Whilst not mentioned in the docs that it can be done this way, I use this code which seems to work
  var campaignIterator = AdWordsApp.campaigns()
       
.withCondition('Status = "ENABLED"')
       
.withCondition("AdvertisingChannelType = SEARCH")  //Only check Search campaigns
       
.get();

Regards
Nigel

David Stockelberg

unread,
Feb 19, 2016, 1:25:48 AM2/19/16
to AdWords Scripts Forum
Hi

And how about retrieving campaign subtypes, such as dynamic search?

/ David

Tyler Sidell (AdWords Scripts Team)

unread,
Feb 19, 2016, 9:29:25 AM2/19/16
to AdWords Scripts Forum
Hi David,

It is not possible to retrieve dynamic search campaigns.  These are the available campaign subtypes.

Thanks,
Tyler Sidell
AdWords Scripts Team

David Stockelberg

unread,
Feb 19, 2016, 9:44:06 AM2/19/16
to AdWords Scripts Forum
Cheers
Any suggestions for how to filter those campaigns (and/or search queries and/or ads in them)?

/ David

Tyler Sidell (AdWords Scripts Team)

unread,
Feb 19, 2016, 10:05:49 AM2/19/16
to AdWords Scripts Forum
Hi David,

You should be able to accomplish this by using the following snippet.  However, as established, you won't be able to filter by Dynamic Search campaigns using this technique.
function main() {

 
var campaignIterator = AdWordsApp.campaigns()
       
.withCondition('Status = "ENABLED"')
       
.withCondition("AdvertisingChannelType = SEARCH")  //Only check Search campaigns

       
.withCondition("AdvertisingChannelSubType = SEARCH_MOBILE_APP")
       
.get();
 
 
while (campaignIterator.hasNext()){
   
var camp = campaignIterator.next();
   
Logger.log(camp.getName());
}
}

Alternatively, you could use labels if you want to filter by these campaigns.  You would apply a label on each of the Dynamic Search campaigns and then run the following:
function main() {

 
var campaignIterator = AdWordsApp.campaigns()
       
.withCondition('Status = "ENABLED"')
 
       
.withCondition("LabelNames CONTAINS_ANY ['Xmas', 'New Year']")
       
.get();
 
 
while (campaignIterator.hasNext()){
   
var camp = campaignIterator.next();
   
Logger.log(camp.getName());
}
}

Thanks,
Tyler Sidell
AdWords Scripts Team

Dawson Reid

unread,
Feb 19, 2016, 10:56:36 AM2/19/16
to AdWords Scripts Forum
Thanks all for the input! This is great, and exactly what I was looking for. In my case I was hoping to pull only display campaigns.

Looking into this further lead me to finding the AdWords Query Language (https://developers.google.com/adwords/api/docs/guides/awql) which is great! As well, query-able fields can be found here - https://developers.google.com/adwords/api/docs/appendix/selectorfields#v201601-LabelService

This discussion has greatly improved my ability to interact with Ad Words entities so thank you all :)
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Aleksandar V

unread,
Jun 23, 2020, 4:26:43 AM6/23/20
to Google Ads Scripts Forum

Here's a function that returns the campaign type by campaign name:

```
function getCampaignType(campaign_name){
  
  Logger.log('getting campaign type for ' + campaign_name);


  var report = AdWordsApp.report(
        "SELECT CampaignName, AdvertisingChannelType " +
        "FROM CAMPAIGN_PERFORMANCE_REPORT " + 
        "WHERE CampaignName = '" + campaign_name + "'");
  
  
  var row = report.rows().next();
  Logger.log('campaign type ' +  row['AdvertisingChannelType']);
  
  return row['AdvertisingChannelType'];
  
}
```

Damian Suchodolski

unread,
Nov 4, 2020, 8:30:42 PM11/4/20
to Google Ads Scripts Forum
I want to get campaigns of SEARCH type that have "Display network" turned on.
How can I recognize this type of  campaigns? 
I see that for both types I get  type=Search  and subtype =--  in the performance report.  

Google Ads Scripts Forum Advisor

unread,
Nov 5, 2020, 2:29:10 AM11/5/20
to adwords...@googlegroups.com

Hi Damian,

 

Thanks for reaching out and allow me to assist you. Are you also pertaining to the AdvertisingChannelType and the AdvertisingChannelSubType from Campaign Performance Reports? For your reference, kindly check out this link for available AdvertisingChannelType values and this link for AdvertisingChannelSubType values.

 

If you would require further assistance in implementing your script, can you kindly share with us your CID and the script ID via Reply privately to author or Reply to author option instead, so we could check on our end? If those options aren't working on your end, you can send those requested details on this email (googleadsscr...@google.com) and include the link of this thread so we could keep track of this existing conversation.

 

Thanks,

Google Logo
Harry Cliford Rivera
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q277H0H:ref

Google Ads Scripts Forum Advisor

unread,
Nov 6, 2020, 6:23:08 AM11/6/20
to adwords...@googlegroups.com

Hi Damian,

 

Thank you for the information you have shared privately. I will reach out to the rest of the team regarding your concern. I will get back to you as soon as I have more information.

Google Ads Scripts Forum Advisor

unread,
Nov 10, 2020, 12:33:07 AM11/10/20
to adwords...@googlegroups.com

Hi Damian,

 

Upon consulting, there is no corresponding attribute available in the API's Campaign object with regard to the Network Campaign Settings in the UI. For example, a Search-only campaign created via the API will always be an All features campaign from the UI perspective. See Campaign subtypes section in this link for reference.

Reply all
Reply to author
Forward
0 new messages