Getting Labels for Ads

161 views
Skip to first unread message

Geoff Procter

unread,
May 26, 2023, 8:27:40 AM5/26/23
to Google Ads Scripts Forum
Hi all,

It's rare that I reach out for help, normally I slog away countless hours until I finally get the solution I'm after, but this time I'm stumped - anything you can offer would be appreciated. I'm new to Google Scripts, but not to coding in general.

I'm trying to pull a bunch of info associated with individual Responsive Search Ads, including any labels attached to them. I've got everything I want except the labels. No matter how I attempt it, I get nothing returned. It's these red labels that I'm trying to get:

Screenshot 2023-05-25 114110.png

My code so far is:

function main(){
  var query =
    ' SELECT campaign.name, ad_group.name, ad_group_ad.labels, ad_group_ad.ad.id, ad_group_ad.ad_strength, ad_group_ad.ad.responsive_search_ad.headlines, ad_group_ad.ad.responsive_search_ad.descriptions FROM ad_group_ad WHERE ad_group_ad.ad.type=RESPONSIVE_SEARCH_AD AND ad_group_ad.status="ENABLED" ORDER BY campaign.name ASC, ad_group.name ASC';
 
  var rows = AdsApp.report(query).rows();
  while(rows.hasNext()){
    var row = rows.next();
   
    var subquery="SELECT label.name FROM ad_group_ad_label WHERE ad_group_ad.ad.id='"+row['ad_group_ad.ad.id']+"'";
    /*var subquery="SELECT label.name FROM ad_group_ad_label";*/
    var subrows = AdsApp.report(subquery).rows();
    Logger.log(subrows.totalNumEntities()); //RETURNS 0
   
    while(subrows.hasNext()){
      var subrow=subrows.next();
      Logger.log(subrow['label.name']); 

//THIS IS WHERE I'M EXPECTING TO SEE THE LABEL NAME
 
      }
   
    var labelSelector = AdsApp.labels();
    var labelIterator = labelSelector.get();
    Logger.log(labelIterator.totalNumEntities());
    while (labelIterator.hasNext()){
      var label = labelIterator.next();
     
      Logger.log(label.getName());
      }

   

    var headlines = row['ad_group_ad.ad.responsive_search_ad.headlines'];
    var headlineCount = headlines.length;
   
    var descriptions = row['ad_group_ad.ad.responsive_search_ad.descriptions'];
    var descriptionCount = descriptions.length;
   
    Logger.log(
      row['ad_group_ad.ad.id']+' | '+
      row['campaign.name']+' | '+
      row['ad_group.name']+' | '+
      headlineCount+' | '+
      descriptionCount
      );
    }}

Even if I try to just pull labels only for the whole account, I get nothing:

  var labels = AdsApp.labels().get();
  Logger.log(labels.totalNumEntities());
//RETURNS ZERO

What I'm trying to achieve (in case there is a better way of doing it) is to effectivley name each Ad so that I can compare outside of the Google Ads interface. Campagins and Ad Groups have the ability to be named, but ads do not. If I'm trying a new type of Ad (often across Ad Groups and Campaign) then I want to be able to see how that works across the account. I'm using labels as names in this case.

Any help would be appreciated.

Cheers,

Geoff



Google Ads Scripts Forum Advisor

unread,
May 26, 2023, 2:20:48 PM5/26/23
to adwords...@googlegroups.com

Hi Geoff,

I'm from the Google Ads Scripts team. I hope you're doing well today.

Could you provide more information to this, such as the following, so we're able to further investigate this on our end and assist you?:

You may send these to us via Reply privately to author option.

 
This message is in relation to case "ref:_00D1U1174p._5004Q2ltdHR:ref"

Thanks,
 
Google Logo Google Ads Scripts Team


Geoff Procter

unread,
May 27, 2023, 2:24:16 PM5/27/23
to Google Ads Scripts Forum
Hey,

Google Ads Account ID =  947-035-1788
Name of the Script = DailyDataExport
Screenshot = in original post (just the coloured tags I'm after)
Spreadsheet = just an empty sheet with an empty tab named "Data"

Thanks,

Geoff

Google Ads Scripts Forum Advisor

unread,
May 30, 2023, 1:32:59 PM5/30/23
to adwords...@googlegroups.com

Hi Geoff,

Thank you for providing more details.

Upon checking, I'm unable to find the labels indicated in the screenshot you provided. Can you please confirm which Google Ads account ID does the labels reside? Also, kindly provide the uncropped and unredacted version of the screenshot you provided so we can take a closer look on our end.

Regards,
 

Geoff Procter

unread,
May 30, 2023, 1:45:57 PM5/30/23
to Google Ads Scripts Forum
Hey,

No problem - Google Ads Account ID is 947-035-1788. Screenshot attached. The labels also show up in the web version of the Google Ads interface but are not showing up in the downloaded Google Ads Editor program if that is of any help?

Message has been deleted

Google Ads Scripts Forum Advisor

unread,
Jun 2, 2023, 3:22:44 AM6/2/23
to adwords...@googlegroups.com

Hi Geoff,

 

Thank you for providing the requested information. I would like to inform you, however, that I had to remove your message as it had contained private information. Kindly refrain from posting messages containing private information as this forum is public, moving forward. Please do scrub any private data when posting information or images here.

 

It appears that there's an issue when retrieving labels created at the MCC level. I'll have to take this up to our internal team for further investigation. Rest assured that we'll get back to you when we have any relevant information to share.

 

In the meantime, your patience is greatly appreciated.

Geoff Procter

unread,
Jun 2, 2023, 2:11:00 PM6/2/23
to Google Ads Scripts Forum
Thanks,

You did ask me to post an "uncropped and unredacted" screenshot of the problem...

Cecil Victor

unread,
Jun 22, 2023, 7:54:59 AM6/22/23
to Google Ads Scripts Forum
Hi, 

I am facing a similar issue as well where the script is unable to find labels at the mcc level but I can see them on the web client. Any help or direction would be greatly appreciated. 

Thanks!

Google Ads Scripts Forum Advisor

unread,
Jun 23, 2023, 7:25:13 AM6/23/23
to adwords...@googlegroups.com

Hi Cecil,

 

Thank you for reaching out. I would like to inform you that the aforementioned issue being tracked in this thread has been raised to our wider team for further investigation.

 

Could you please provide the following details for us to confirm the behaviour you've experienced on our end?:

    • Google Ads account ID or CID
    • Name of the script
    • Complete and uncropped UI screenshot of the data you want to retrieve via Google Ads Scripts

     

    You may send these privately via the Reply to author option. Note that you may need to join the Google Group for you to use this option. If this option is not available on your end still, you may send it through our email (googleadsscr...@google.com) instead.

    Reply all
    Reply to author
    Forward
    0 new messages