AdWords AdWords Scripts Blog Google AdWords Marketing online PPC

Pause keywords based on KPIs in bulk

Reviewing and pausing keywords with low performance in all our accounts can take a very long time. This script can prevent that job.

Within the 2016 version of the superior course of Google AdWords (of which I shall be a coach in this edition of 2017), Enrique Del Valle informed me that he would discover it very useful a script that might permit him to pause keywords based on several KPIs, in addition to with the ability to filter by accounts (on the MCC degree), campaigns, ad groups and particular keywords.

At the moment I deliver you that script!

Then, I'll break down the functionalities of this script, and the way to configure it step by step:

Previous configuration of the script

Earlier than beginning to assessment the KPIs, these are the choices that we should configure in the primary place:

  • mccLevelScript is the variable with which we will select whether or not to execute the script on the MCC degree (leaving the worth “true”) or at the account degree, change the value to “false” (without the quotes).
  • RECIPIENT_EMAIL accommodates the e-mail, or emails (separated by commas), recipient to notify the outcomes of the script or if there has been an error through the execution. If you don’t want to receive any notification, simply depart the two quotes with none e mail inside, and the semicolon on the best: That’s: “”;
  • timePeriod is the time period that we need to analyze. The potential values ​​that can be utilized are:

You can too select a selected date range by setting the start and finish dates as follows: YYYYMMDD. For example, to specify the range of dates from January 1, 2017 to January 31, 2017, it might seem like this:

You’ll be able to seek the advice of extra detailed info on this web page of Google Builders.

AdWords metrics and attributes obtainable

We will filter the keywords that we need to pause for the next KPIs and attributes:

  • Key phrase matches. We will choose any mixture between: broad, phrase and / or actual. The script does not distinguish between large and broad modified.
  • Minimum and most high quality degree. It also permits adding or excluding keywords with neutral high quality degree “-“.
  • Minimal and most clicks
  • Minimum and maximum impressions
  • Minimum and most conversions
  • Minimum and maximum cumulative value

As you possibly can see in the code itself, you specify what values ​​each variable can take. On this case, the variables of high quality degree, impressions, clicks, conversions, collected value and conversions with view, solely admit entire numbers (with out decimals).

  • Minimal and most conversion fee.
  • Minimal and most CTR

These variables admit percentages written in decimal format. For instance, 0% is represented as zero.00, 5% as zero.05, 53.47% as 0.5347, and so on.

  • Common position of the minimal and most ad. On this case, keep in mind that a better common position signifies that the ad comes out in worse positions and vice versa.
  • Value per minimum and maximum conversion.

CPA and Middle Position metrics help integer and decimals numeric values.

The KPI value per minimal conversion requires clarification:

When we’ve got a price per conversion of ZERO, AdWords treats it (for filtering functions) as if it have been “infinite” offered that the keyword has accrued some value (even zero.01 €). For example, if we filter by CPA higher than € 5, the script may also select those keywords with € 0 CPA which have collected some value, although that value does not exceed € 5.

Because of this, I have programmed the script to behave in the following method:

  1. If the amassed minimum value filter is NOT used, the script will solely pause the keywords without conversions which have accrued no less than the identical value as the CPA. Within the earlier instance, of the keywords which have a CPA of € zero, you’d solely pause the keywords with a cumulative minimum value of € 5 or extra.
  2. If the cumulative minimal value filter is used and that is decrease than the CPA filter, for keywords with CPA zero €, it’s going to pause those with the minimum accrued value that the consumer has set. For example, if I set a minimal value of € 3 and a minimum CPA of € 5, the script will pause the keywords with CPA higher than or equal to € 5 and, in addition, the keywords with CPA € zero and collected value of € three or more .

Filtered by labels

One other filtering choice provided by this script is to filter by accounts, if we execute the script at the MCC degree, campaigns, advert teams and keywords. All these filtrates (each by labels and by KPIs) are restrictive. That’s, each one of many circumstances have to be met in order for the keyword to be paused. We’ve got the following variables:

  • mccLabelText accommodates the text of the label by which we need to filter the advertising accounts of an MCC.
  • campaignLabelText incorporates the text of the tag to filter campaigns.
  • adGroupLabelText, equally, accommodates the text of the tag to filter ad teams.
  • keywordLabelText, lastly, incorporates the text of the tag to filter keywords.

The worth 'no label' causes the label NOT for use. By default, all tags have filtering disabled (they’ve the worth 'no label').

You should use the identical tag to filter each accounts, campaigns, advert teams and / or keywords. You just should put the textual content on every label that you simply need to use. For example, I'll filter accounts using the “MCC Tag” tag, and I'll also filter campaigns and ad groups with the tag “AccountTab”. I’ll NOT use filtering by keywords. It might appear to be this:

Right here the configuration choices for the consumer finish. All these options are grouped in the higher a part of the script, just after the preliminary explanatory remark.

If, in addition, you are interested in figuring out the interior operation of the script, maintain reading ?

How AdWords Script works

Constructing the Query Language Question Language

The primary action that the script performs, even before checking if it must be executed at the MCC or account degree, is to construct the AdWords Query Language (AWQL) query with all of the filtering options configured by the consumer:

By following good practices in terms of cleansing the code, a name is made to the perform buildQuery (), which incorporates all the required checks to determine which parameters to include, and which don’t.

question and queryQs are auxiliary variables declared at the start of the script

  • The query will include all of the filtering circumstances by KPIs (those filtered by labels are accomplished in another approach later), excluding filtering by quality degree.
  • queryQs will include the a part of the AWQL question akin to the minimum and maximum high quality degree filters. I isolate it in this variable because AWQL doesn’t help the OR operator and, in the case of wanting to incorporate the keywords with neutral quality degree “-“, the coding can be rather more complicated and inefficient.

Execution at MCC degree or account? That is the query

Simply after the above, the script checks if you want to run on the MCC degree or at the account degree:

For this part of the script, I have based on the template I revealed to make scripts that can be executed each at the MCC degree and at the account degree.

Primary perform: run ()

As soon as we have now a specific promoting account (either as a result of it is executed on the account degree or for every account on the MCC degree), the “run ()” perform will probably be executed, which incorporates the core of the script. These are the primary steps that the perform follows:

Filtering labels

We get hold of the prevailing labels in the promoting account

We verify them with the filter tags for campaigns, ad teams and keywords (because the account filtering has already been achieved on the MCC degree) configured in the Script checking, for each tag of the account, if it matches one or more of the Filtering tags:

Once all the tags of the account have been checked, we confirm that, for every filter tag enabled (it has a unique value than 'no label'), we’ve detected whether or not or not it exists in the account.

If we now have not detected any of the filter tags enabled in the advertising account, the script ends its execution for that account, since this means that there’s a filter tag enabled which has not been utilized to the account, so it doesn’t make sense to keep operating the script on that account as there isn’t any key phrase that can fulfill all of the circumstances.

Filtering campaigns

We verify if we have now the filter tag enabled by campaigns and, in that case, we get the Iterator of campaigns filtered by the tag:

Subsequent, we examine if the Iterator incorporates at the least one marketing campaign. In case of not containing any, again, the execution of the script ends for that account since, in this case, it will mean that, although there is a label in the account, it has not been applied to any campaign, so we won’t have any keyword that meets all circumstances.

Within the occasion that we wouldn’t have any marketing campaign filtering tag enabled, we get the Iterator with all campaigns in the account:

In any case these checks, and with the campaign Iterator processed, we undergo the Iterator extracting the IDs of the campaigns, to proceed with the filtering in the next steps.

This part is practically the identical as the previous one (marketing campaign filtering), with one exception: the following further situation is added:

In this means, we’ll solely acquire the advert groups that, in addition to fulfilling the other circumstances, belong to any of the campaigns already filtered in the earlier step.

Key phrase filtering

The particularity of this filtering with respect to the earlier ones is in the KPI of quality degree. On the one hand, we will discover keywords with numerical quality degree, for which we use the variable queryQs, which incorporates the part of the AWQL question akin to this KPI as we now have seen beforehand.

However, if the consumer consists of the keywords with impartial quality degree “-“, we must make one other further question:

And, once the Iterators are processed, we examine if there’s a minimum of one key phrase that meets all of the circumstances. If the result’s destructive, that’s, the Iterator is empty, the script ends its execution for that account, since it might mean that, after all the leaked, there isn’t any keyword that meets all the necessities (of KPIs and labels) for the chosen time period (using the variable timePeriod).

Getting ready the script change control tag

After applying all of the filters, and before starting to pause the resulting keywords, we verify if the tag scriptLabel (auxiliary variable) exists in the account. If it doesn’t exist, it’ll create it.

Pause keywords ensuing from filtering

As the last step of the run () perform, we undergo the keywords Iterators to pause them and apply the script's change management tag

Send script notification by e-mail

As soon as the execution of the script in the account ends, or accounts if we execute it at the MCC degree, it checks if an e mail has been configured for the notification of outcomes and, in that case, sends the notification, whose message is constructed dynamically:

You possibly can examine the newest obtainable version of the script on this GitHub hyperlink.

I hope it helps you or, at the least, inspiration to develop your personal scripts. And if in case you have any comments, options or concepts to develop, can you allow it in the comments under?

#AdWordsScript: Pause keywords in bulk relying on KPIs you want #AdWords #ppcchat Click To Tweet