Contact Us

Google Ads Scripts Beginners Guide

Getting Started with Google Ads Scripts

AdWords (now Google Ads) can be optimised in a number of ways, with API’s or at a more basic level with Scripts, and a still more basic level with Rules.

We will take a quick dive into Google Ads Scripts, and show how they can help run campaigns, and also show some example code.

Firstly, Scripts are written directly into you individual account. So, if you manage many accounts from one MCC, then navigate to your customers account. From there, go to the Tools icon on the top right.

Then in the big drop down, go to the Bulk Actions column, and then click Scripts.

You will now have a screen with a “+” symbol, click on this and you’re good to start your first script. Here is an example with a script we made earlier.

The code used in this area of Google Ads is based on Javascript, but normally only a basic level of knowledge is needed.

A Simple Script to Stop Campaigns when Budget Reached

Here is a script which checks the total spend for the current month to date. You can set it to pause campaigns when the total spend is reached. What’s more, you can set it to check this daily or hourly for example.

var CUTOFF_COST = 5000;
var CUTOFF_LABEL = “Auto Stop Campaign”;

function main() {
var label = AdsApp.labels().withCondition(“Name='” + CUTOFF_LABEL + “‘”).get().next();
if(AdsApp.currentAccount().getStatsFor(“THIS_MONTH”).getCost() > CUTOFF_COST) {
var campaignIterator = label.campaigns().get();

while (campaignIterator.hasNext()) {
var campaign = campaignIterator.next();
campaign.pause();
}
}
}

It should look like this on the screen –

 

 

 

 

 

 

 

Then save it, and select authorise because Google requires that. You can now preview to test it. You will get an error, because we still need to do something.

The code above starts with two “var” lines, these are variables which the rest of the code has to check for. One of which is  var CUTOFF_LABEL = “Auto Stop Campaign”;

The part in quotation marks can be anything you want. It’s the same with the cutoff cost – We chose Auto Stop Campaign for the label, and for the other 500, but it would be whatever your budget is. Now nothing will happen yet when you run this code, because it is looking through the campaigns in your account to find ones with a label that matches those words. So, now go to your campaigns page area, tick all the campaigns you want this script to run on, and then click labels.

Now create a new label, and put in the full words Auto Stop Campaign, then apply. You have now applied the labels to your campaigns.

Next, go back to Scripts, and in the starting screen there is a column for Frequency. Select this to access the edit options, and select hourly. Go into the Script and preview to test it, then run if its all good.

In the example above, if you had a £500 monthly budget, it would be safer to set it at say a little under this as it can only check as fast as once an hour. You should now have your first Google Ads Script!

There are many scripts. Some can check URL’s to see if they are dead links. Others can apply bid modifiers to keywords, devices you name it. Still more can generate exports to email you at certain times.

Scripts use several main elements.

Variables, Functions, Objects, Entities, Selectors and more.

Variables appeared at the beginning of the script above, which you will set ( the “var” part).

Functions started in the main code, and begin with function main() { and is the code part which will run

Objects allow the script to go look into a data source. This will mainly be Google Ads itself, AdsApp. code above

There’s more which we would like to go through in other posts. But for now this should get you started.

Google link to some help and examples – https://developers.google.com/google-ads/scripts/

Happy exploring!

This article was posted by



Leave a Reply

What our clients say

"It’s like having your own in-house digital marketing consultancy rather than an external company. I no longer think about them as a supplier. They’re part of the team."
Marketing Manager, Education
"They have always been professional and focused on delivering results in a timely and cost effective manner. It is enlightening to have an organisation that takes the time to make recommendations on actual data analysis."
Business Manager, Charity
"They (Network Intellect) continue to exhibit their digital expertise by helping us to establish a competitive advantage by pushing the boundaries and innovating their technology and performance solutions."
Head of Marketing Communications, Education
"Because of their talent, expertise and level of service our on-line business has increased dramatically."
Founder, Electronics
"I would have no hesitation in recommending them as an analytics partner to understand and improve the performance of a website."
Vice President, Retail
Network Intellect continue to give us a fantastic service, fast and friendly and are always ready to go the extra mile. They have gone above and beyond the call of duty to deliver our results.
Director, E-Cigarette Web
"We found that Network Intellect had the depth of knowledge we needed and after speaking to them a few times we decided to go with them. It’s the best decision we’ve made in some time."
Owner, Retail
"Their services offered great value for money. I would not hesitate to recommend them as a digital partner to others."
Strategic Marketing Manager, Education
"Jason and his team at Network Intellect embody efficiency and efficacy. I would have no hesitation in recommending this excellent company to others."
Marketing Manager, Education
Network Intellect have managed our product data feeds with exceptional care and meticulous detail. I know I can trust them to make the right decisions for our business."
Director, E-Commerce
"It’s like having your own in-house digital marketing consultancy rather than an external company. I no longer think about them as a supplier. They’re part of the team."
Marketing Manager, Education
Read all testimonialsRead all testimonials

We can help you be great

We have friendly staff ready to help you get on your path to greatness...
Network Intellect Menu