Pause out-of-stock products with this Google Ads script


Black Friday and the holiday season are fast approaching, it's a period of strong expansion for retailers, but in a rapidly changing environment, products are quickly coming out of the stock, with ads being always broadcast, resulting in a loss of budget.

inventories, it is almost impossible to manually control the suspension of ads for products out of stock.

We did not like to see retailers wasting their paid media budget. Our developer team has created this Google Ads script that runs every hour and automatically pauses ads pointing to out of stock products on Shopify.

How the script works

The logic behind the script is quite simple. It tracks the URLs of all active ads on the landing page and looks for a certain text string in it, for example: "out of stock".

If the product is out of stock, the ads are paused and the ads must be marked "Pause – out of stock".

The script also activates the automatically delivered ads. It reviews all ads labeled "Suspended – Out of Stock" to see if the product is in stock and will reactivate it.

Note that if you have a multi-product variant (for example, sizes) and your URL leads to an out of stock choice, it will be classified as out of stock.

How to configure the script

The script has a number of options that you can configure according to the use you want to make

At line 16:

Enter a common element of all the campaigns you want to include. If you want the script to work for all campaigns, leave this field blank. We suggest only running this script on product-level campaigns where ads point directly to the URL of a product page, as opposed to a category page or another page of the product page. website.

Online 19: Enter a common element of all the campaigns you want to exclude. If you want the script to work for all campaigns, leave this field blank.

At line 22 Enter the html element that you can find using the detail of the element inspected in the page string. For example, "sold_out".

At line 25: Enter the part of the URL that identifies the product pages. This is important, otherwise the script will also scan the category pages. If you have a product out of stock, all ads that point to the category you want to pause can be paused. For example, if your site is gymshark.com/products/gymshark-scrunchie-black, select Enter / product / because this is the common element for all product pages.

Once the script is set up, make sure that you test it to make sure that you have it correctly configured and that the functionality complies with expectations.

Finally, you will have to configure the script according to a planned schedule. He will then check all your ads to make sure they are not pointing to out of stock products and if they are paused.

The Script


The opinions expressed in this article are those of the guest author and not necessarily. Earth search engine. The authors are listed here .


About the Author

Wesley is General Manager of Clicteq . He currently manages a Google Ads portfolio of more than $ 4 million in various sectors. He writes regularly in leading marketing publications such as Econsultancy and Campaign Magazine.



Source link