{{ searchResult.published_at | date:'d MMMM yyyy' }}

Loading ...
Loading ...

Enter a search term such as “mobile analytics” or browse our content using the filters above.

No_results

That’s not only a poor Scrabble score but we also couldn’t find any results matching “”.
Check your spelling or try broadening your search.

Logo_distressed

Sorry about this, there is a problem with our search at the moment.
Please try again later.

Welcome back to our Intro to AdWords scripts series where we will train you to automate your account management using scripts.

As you'll have noticed in our earlier posts, we make frequent use of the AdWords scripts documentation, which is vitally important.

In this article we'll go through an example script making effective use of the documentation, we'll focus on the campaign selector and we'll give you an AdWords pro tip.

Example: pulling campaigns

The snippet of code below shows you how to retrieve a campaign from AdWords. 

The campaignSelector 

We define a campaignSelector on lines 2-3 using AdWordsApp.campaigns(). There are many options available to the campaignSelector, known as methods.

To make sure we're looking at just one campaign, we use the withLimit method which specifies the number of campaigns to use in the brackets (known as the argument).

If you don't include withLimit, the selector will try to pull all the campaigns stopping at a maximum of 50,000. 

You can see a list of possible methods below (the full page is available here). Clicking on the name of a method in the documentation will scroll you down to that section, Wikipedia-style.

(click image to enlarge)

An option you'll find yourself frequently using is the withCondition method where you can refine your search by choosing campaigns with certain names or those which have spent more than a threshold amount, for example.

Pro tip:

If you have multiple withCondition methods, the selected campaigns will satisfy all the conditions (think of it as a filter with conditions joined by an AND operator, e.g. cost >10 AND cost < 30).

For example, how would you be able to choose two campaigns that have completely unrelated names? Take a look at the first image below. We included two withCondition lines in our selector.

As a result all the campaigns pulled by the selector will have to satisfy both conditions - not very useful when trying to return data on unrelated campaign groups.

You'll notice that using multiple conditions can be quite restrictive because you can't specify campaigns which satisfy one of two conditions. The documentation won't help you here but we found a solution.

As in the second image, use an array containing a list of all the campaign names you want your selector to pull. This technique overcomes the problem in the first image as campaigns with either name are now retrieved by the selector.

Going through the campaign --> keyword hierarchy is time consuming and using a keyword selector with a campaign name condition such as the one shown in the second image is much more efficient. There will be more on this issue in our upcoming article on AdWords scripting best practices.  

 

Keep an eye out for our next article: Landing pages: putting an end to errors. We'll be showing you how to scan your destination URLs for error pages and email the results. 

Useful links:

CampaignSelector methods

CampaignIterator methods

Campaign methods

Daniel Gilbert

Published 7 May, 2014 by Daniel Gilbert

Daniel Gilbert is Managing Director at Brainlabs Digital and a contributor to Econsultancy. You can connect with Daniel on Google Plus

6 more posts from this author

Comments (2)

Avatar-blank-50x50

Jim Whittle

Great stuff, thanks for sharing. Look forward to the rest of the series.

almost 2 years ago

Daniel Gilbert

Daniel Gilbert, Managing Director at Brainlabs

Cheers Jim, glad you liked it!

almost 2 years ago

Comment
No-profile-pic
Save or Cancel
Daily_pulse_signup_wide

Enjoying this article?

Get more just like this, delivered to your inbox.

Keep up to date with the latest analysis, inspiration and learning from the Econsultancy blog with our free Daily Pulse newsletter. Each weekday, you ll receive a hand-picked digest of the latest and greatest articles, as well as snippets of new market data, best practice guides and trends research.