AdsApp.​SitelinkSelector for active sitelinks?

230 views
Skip to first unread message

Aaron Weiner

unread,
Jun 22, 2022, 5:46:45 PM6/22/22
to Google Ads Scripts Forum
How do I grab all sitelinks from within an account that are actually being used in active campaigns and ad groups?

For example:
var sitelinkSelector = AdsApp.extensions()
    .sitelinks()
    .withCondition("metrics.impressions != 0")
    .forDateRange("LAST_7_DAYS")

var sitelinkIterator = sitelinkSelector.get();
while (sitelinkIterator.hasNext()) {
    var sitelink = sitelinkIterator.next();
    Logger.log(sitelink.urls().getFinalUrl());
}


The problem is that this code works with accounts that have feed-based ad extensions but not for asset-based ad extensions.

When I have upgraded sitelinks in an account, I see the following error:

"Call to GoogleAdsService.Search failed: Cannot select or filter on the following metrics: 'impressions'(could not support requested resources: 'ASSET'), since metric is incompatible with the resource in the FROM clause or other selected segmenting resources."

What is the best way to handle this?

Thanks and I look forward to your reply.

Aaron

Google Ads Scripts Forum Advisor

unread,
Jun 23, 2022, 3:21:11 AM6/23/22
to adwords...@googlegroups.com
Hi Aaron,

Thank you for reaching out to us.

With regard to your concern, I'm afraid that it will be expected to get an error since the new experience can only retrieve asset-based extensions. The only solution is to migrate those feed-based to asset-based. You can continue to work with your current feed-based extensions through the legacy Google Ads Scripts experience. However, feed-based extensions will soon become unavailable and asset-based extensions are only available on the new Google Ads Scripts experience. We recommend migrating your legacy Google Ads Scripts to the new Google Ads Scripts experience as soon as feasible. More information can be found here.

Regards,
Google Logo
Teejay Wennie
Google Ads Scripts Team
 

 

ref:_00D1U1174p._5004Q2bzHx6:ref

Aaron Weiner

unread,
Jun 23, 2022, 8:04:49 AM6/23/22
to Google Ads Scripts Forum
But that doesn't answer the question. 

Even if I migrate all feed extensions to asset-based extensions, how do I only get the currently used sitelinks at the account, campaign or ad group levels?

For example:
var sitelinkSelector = AdsApp.extensions().sitelinks();

var sitelinkIterator = sitelinkSelector.get();
while (sitelinkIterator.hasNext()) {
    var sitelink = sitelinkIterator.next();
    Logger.log(sitelink.urls().getFinalUrl());
}

How do I only return sitelinks that are associated to an account, campaign or ad group? 

Thanks and I look forward to your reply.

Aaron



Google Ads Scripts Forum Advisor

unread,
Jun 24, 2022, 4:50:31 AM6/24/22
to adwords...@googlegroups.com

Hi Aaron,


Thank you for getting back to us. I work with Teejay and allow me to assist you here.


So our team can better check this concern. Could you please provide the CID and the full screenshot Google Ads UI that display a sitelinks of a campaign or ad group? So that we can take a closer look at your concern and provide guidance on this matter.
 

You can provide it via Reply privately to author option. If this option is not available, then send it instead on this email address googleadsscr...@google.com

Regards,

Google Logo
Darwin
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2bzHx6:ref

Aaron Weiner

unread,
Jun 24, 2022, 9:26:05 AM6/24/22
to Google Ads Scripts Forum
Okay, I emailed the information. 

Google Ads Scripts Forum Advisor

unread,
Jun 27, 2022, 5:29:19 AM6/27/22
to adwords...@googlegroups.com
Hello,

Thank you for providing the requested information.

I've checked your script and it appears that you iterating directly through sitelinks level. Please do note that AdsApp.sitelinks don't have a method to get its base campaign or base adgroup (unlike other entity level which has a getCampaign() method). With that said, what I could suggest to iterate first on the upper level before iterating to the sitelinks. I've created a simple script which iterates through your campaign, then get all the sitelinks added on the campaign.
 
function main() {
    
  var campaignSelector = AdsApp
  .campaigns()
  //.withCondition("metrics.impressions > 100")
  //.forDateRange("LAST_MONTH")
  //.orderBy("metrics.clicks DESC")
  ;

 var campaignIterator = campaignSelector.get();
 while (campaignIterator.hasNext()) {
   var campaign = campaignIterator.next();
   
   
   
   var sitelinkSelector = campaign.extensions().sitelinks();
   
   var sitelinkIterator = sitelinkSelector.get();
   while (sitelinkIterator.hasNext()) {
     var sitelink = sitelinkIterator.next();

     //GET ID
     Logger.log(campaign.getName() + " -- " + sitelink.getDescription1());


   }
   
   
   Logger.log("---------------");
   
   
   
   
 }
  
  
  
  
  
}

Regards,
Google Logo
Teejay Wennie
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2bzHx6:ref

Aaron Weiner

unread,
Jun 27, 2022, 7:47:47 AM6/27/22
to Google Ads Scripts Forum
Let me try to ask this a different way. 

Let's say I have 10 asset-based sitelinks in the system, and only 4 of them are actually associated at the account level. 

How do I identify only those 4 sitelinks that are associated at the account level?

Thanks and I look forward to your reply.

Aaron





ahmad Awa

unread,
Jun 28, 2022, 2:59:14 AM6/28/22
to Aaron Weiner via Google Ads Scripts Forum
I have suspended advertising accounts, suspended, reconsider activating the account at the same time

‫في الاثنين، 27 يونيو 2022 في 7:47 ص تمت كتابة ما يلي بواسطة ‪Aaron Weiner via Google Ads Scripts Forum‬‏ <‪adwords...@googlegroups.com‬‏>:‬
--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/df854e8e-a749-4c38-9587-7ccb87c3a3dan%40googlegroups.com.

Google Ads Scripts Forum Advisor

unread,
Jun 28, 2022, 3:21:47 AM6/28/22
to adwords...@googlegroups.com

Hi Aaron,
 

Thank you for getting back to us. I work with Teejay and allow me to assist you here.
 

Moving forward to your concern, I'm afraid that there is no AdsApp to get what you want. However, If you want to get these 10 asset-based sitelinks, you need to use the Reports and Google Ads query language below.
 

SELECT customer_asset.asset, customer_asset.status, customer_asset.field_type, metrics.clicks, metrics.cost_micros FROM customer_asset WHERE customer_asset.field_type IN ('SITELINK') AND customer_asset.status (ENABLE)


Regards,

Google Logo
Darwin
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2bzHx6:ref

Aaron Weiner

unread,
Jun 28, 2022, 7:50:58 AM6/28/22
to Google Ads Scripts Forum
Hello Darwin,

This is absolutely a step in the right direction. 

There was a slight issue with your query. It should have had customer_asset.status IN ('ENABLED')

Aside from that, what is the best way to then get the sitelink URL from the asset field?

The asset field looks something like this:
customers/1111111111/assets/33333333333
customers/1111111111/assets/44444444444
customers/1111111111/assets/55555555555

Is there a special function that parses that data, or do I need to extract the asset ID and then perform this type of query?

var sitelinkIds = ['33333333333', '44444444444', '55555555555'];
 selector = selector.withIds(sitelinkIds);

Thanks and I look forward to your reply.

Aaron





Google Ads Scripts Forum Advisor

unread,
Jun 28, 2022, 11:37:50 PM6/28/22
to adwords...@googlegroups.com

Hello Aaron,

James here, also from the Google Ads scripts support team. Allow me to assist you further.

I confirm that you need to extract those asset IDs within the retrieved data in the mentioned asset field, so that you can utilize it within a specific selector or query. Now, to retrieve the sitelink URL, I believe that you may use the getFinalUrl method of the AdsApp.​SitelinkUrls that returns the final URL of a specific sitelink in your account.

Let me know if the method mentioned above is what you are looking for.

Regards,

Google Logo
James Howell
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2bzHx6:ref

Aaron Weiner

unread,
Jun 29, 2022, 9:55:33 AM6/29/22
to Google Ads Scripts Forum
Hello, 

What if I were to go about this in a different way? 

My main goal here is to check all final URLs within an account.

Instead of trying to extract all the final URLs from ads and then sitelinks and then other types, what if I were to use the landing_page_view report? 

A query like this:

SELECT
        landing_page_view.unexpanded_final_url,
        segments.click_type,
        ad_group.status,
        campaign.status
FROM landing_page_view
WHERE
        ad_group.status IN ('ENABLED')
        AND campaign.status IN ('ENABLED')
        AND segments.date DURING LAST_7_DAYS
        AND metrics.impressions > 0 


If I use the AdsApp.​AdSelector it will only return these types of ads:
EXPANDED_TEXT_ADGMAIL_IMAGE_ADGMAIL_SINGLE_PROMOTION_ADGMAIL_MULTI_PRODUCT_ADHTML5_ADIMAGE_ADMOBILE_ADMOBILE_IMAGE_ADPRODUCT_ADRESPONSIVE_DISPLAY_ADRICH_MEDIA_ADTEMPLATE_ADTEXT_AD

No video ad final URLs, no performance max final URLs, no discovery ads and so on. 

I would also still need to deal with the issues with sitelinks (asset-based or feed-based). Then I would need to grab any other types of ad extensions that have URLs, for example, price extensions. 

It seems that if I were to use the the landing_page_view report, it would cut out all these issues.

What's the downside of using the landing_page_view report? 

The only issues that I can see are the following:

1) It could return a final URL that is no longer used but saw impressions in the segmented date range. That's because there doesn't seem to be a way for me to do "ad_group_ad.status = ENABLED" in the landing_page_view report.

2) I'm not sure, but does the landing_page_view report return final URLs that had impressions but no clicks?


Thanks and I look forward to your reply.

Aaron


Google Ads Scripts Forum Advisor

unread,
Jun 30, 2022, 2:53:45 AM6/30/22
to adwords...@googlegroups.com

Hello Aaron,

Thank you for your response. However, if there is a specific field or data that you’re trying to retrieve using the AdsApp root object of the Google Ads scripts but wasn’t able to fetch so. Then, I’m afraid that we can no longer provide depth insights regarding this. I said this because the new Google Ads script experience only utilizes the Google Ads API infrastructure or reporting as stated in this migration guide

Therefore, I believe that it’s best if you raise those stated questions or concerns with the Google Ads API support team through this forum channel as they are more knowledgeable and much capable of providing accurate answers with your Google Ads reporting concerns.

Regards,

Reply all
Reply to author
Forward
0 new messages