Excluding pending products in Google Merchant Disapproval checker?

47 views
Skip to first unread message

Peter Agerholm

unread,
May 18, 2020, 5:43:59 AM5/18/20
to Google Ads Scripts Forum
Hi

Regarding the script on this link:
https://searchengineland.com/tired-of-manually-checking-for-google-merchant-center-disapprovals-this-script-has-you-covered-325070

The email notifies me if the wished threshold (% of disapproved products) is met or exceeded. I do miss the possibility though to make the script distinguish between disapproved and pending products in terms of approval status? At the moment it only sets the products as "disapproved" if the approval status isn't equal to "approved". Therefore, I get notified of "disapproved" products, even though their status is "pending".

Anyone with a solution on how to exclude pending products in this script?

Google Ads Scripts Forum Advisor

unread,
May 18, 2020, 6:27:52 AM5/18/20
to adwords...@googlegroups.com
Hi Peter,

Thanks for posting your concern.

Could you confirm if you want to have a script that will exclude pending products in your merchant center account? If yes, then, I am afraid that this is out of our scope already. However, you may reach out to the Google Apps scripts team to get further support on implementing Content Shopping on script editor and to have this specific script.

Otherwise, please provide more details so we can provide support.

Regards,
Ejay
Google Ads Scripts Team

ref:_00D1U1174p._5004Q1zpwic:ref

Peter Agerholm

unread,
May 18, 2020, 6:38:06 AM5/18/20
to Google Ads Scripts Forum
Hi Ejay

To elaborate on my request, I would like for the script to ignore products that has an approval status of either "approved/active items" or "pending items".

When I therefore get the notification (see example), I know that the script has only taken into account the products that are "disapproved" and not "pending"?

199 of 645 products in your GMC (123459876) were disapproved - 30.85%


I hope this makes sense? :)

Google Ads Scripts Forum Advisor

unread,
May 18, 2020, 1:10:19 PM5/18/20
to adwords-scripts+apn2wqe4kvzom6uj...@googlegroups.com, adwords-scripts+apn2wqe4kvzom6uj...@googlegroups.co, adwords...@googlegroups.com
Hi Peter,

The third party script checks for approval status and increments the number of disapproved ads starting on line 71:
 
if (product['destinationStatuses'][0]['approvalStatus'] == 'disapproved') {
  numberDisapprovedProducts++;

Looking in the Apps scripts shopping service documentation that Ejay referenced, you can find 'approvalPending' in the JSON representation.  

You can alter the script based on a product's approval pending status similarly to how the script author checked the approvalStatus:
 
if (product['destinationStatuses'][0]['approvalPending'] == true) { //approvalPending type is boolean
  //Work based on product pending

Hope this helps.

Thanks,
Matt

Peter Agerholm

unread,
May 19, 2020, 3:33:19 AM5/19/20
to Google Ads Scripts Forum
Hi Matt

Thanks for this - I do need the script to give me the following notification if the product approvalstatus is Pending:

199 of 645 products in your GMC (123459876) were pending - 30.85%

How to do this? Currently it's still not distinguishing between disapproved and pending?

// If the 'approvalStatus' of our product is not 'approved' then we say it is disapproved.
    if (productStatuses.resources) {
      for (var i = 0; i < productStatuses.resources.length; i++) {
        product = productStatuses.resources[i];
        if (satisfiesAllFilters(product)) {
          totalProducts += 1;
          if (product['destinationStatuses'][0]['approvalStatus'] == 'disapproved') {
            numberDisapprovedProducts++;
          }
        }
      }
    } else {
      Logger.log('No more products in account ' + merchantId);
    }
    // We then pull our next PageToken from our response and use it to make a new request.
    // If there is no next PageToken then we exit our iteration.
    pageToken = productStatuses.nextPageToken;
  } while (pageToken);

  disapprovalPercentage = (numberDisapprovedProducts * 100) / totalProducts;
  Logger.log(numberDisapprovedProducts + ' of ' + totalProducts
    + ' products in your GMC account (' + merchantId + ') were disapproved - '
    + disapprovalPercentage.toFixed(2) + '%')

  // If our threshold is exceeded then we assemble an email with details of the alert and send it to our contact emails.
  if (disapprovalPercentage >= threshold) {

    var subject = merchantId + ' GMC Disapproval Alert Email';
    var message = numberDisapprovedProducts + ' of ' + totalProducts
      + ' products in your GMC (' + merchantId + ') were disapproved - '
      + disapprovalPercentage.toFixed(2) + '%' + '\n';

Google Ads Scripts Forum Advisor

unread,
May 19, 2020, 1:29:10 PM5/19/20
to adwords-scripts+apn2wqe4kvzom6uj...@googlegroups.com, adwords-scripts+apn2wqe4kvzom6uj...@googlegroups.co, adwords...@googlegroups.com
Hi Peter,

The shopping API distinguishes between approvalStatus and approvalPending. To use approvalPending instead, switch the conditional:

 
if (product['destinationStatuses'][0]['approvalStatus'] == 'disapproved') {

for:

 
if (product['destinationStatuses'][0]['approvalPending'] == true) { 

Note that the second conditional uses 'approvalPending' instead. Please see this product statuses document for more information.

Peter Agerholm

unread,
May 20, 2020, 6:46:59 AM5/20/20
to Google Ads Scripts Forum
Hi

I don't want to use it instead, but simultaneously - meaning that I would like the script to distinguish between disapproved AND pending. 

So when the products are disapproved, I will get this notification:

199 of 645 products in your GMC (123459876) were disapproved - 30.85%

And if the product status is "pending", I will get this:


199 of 645 products in your GMC (123459876) were pending - 30.85%

How to do this??

Google Ads Scripts Forum Advisor

unread,
May 20, 2020, 11:45:54 AM5/20/20
to adwords-scripts+apn2wqe4kvzom6uj...@googlegroups.com, adwords-scripts+apn2wqe4kvzom6uj...@googlegroups.co, adwords...@googlegroups.com
Hi Peter,

This would require multiple changes throughout the script. However, this support channel does not provide third party custom script implementations. An easy way to get both the approval pending and approval status email alerts would be to create two separate scripts: the original solution and one with the modification I provided above. You can also change the email alert messaging between lines 92 and 95 for the approval pending version:

 
    var subject = merchantId + ' GMC Disapproval Alert Email';
    var message = numberDisapprovedProducts + ' of ' + totalProducts
      + ' products in your GMC (' + merchantId + ') were disapproved - '
      + disapprovalPercentage.toFixed(2) + '%' + '\n';

Hope this helps.

Regards,
Reply all
Reply to author
Forward
0 new messages