COUNT(...) function counts the number of contained items that match an optional filter. When counting, you specify the types for which contained items should be counted, and optionally a child filter condition to indicate which contained items should be counted. Contained items not matching the child filter or not of the specified types aren't counted. If the filter isn't specified, the function will count all items of the specified types.
types-- the types of contained items to count.
filter[optional] -- contained items must match this filter to be counted.
You can count items relative to a certain number:
- Greater than >
- Greater than or equal to >=
- Less than <
- Less than or equal to <=
- Equal =
- Does not equal - =
COUNT(keywords, labels = ("abc", "xyz") ) < 5
Checks if there are fewer than 5 keywords that have the labels "abc" or "xyz" contained in the campaign or ad group. In this example, "keywords" is the the type of item being counted, while
labels = ("abc", "xyz") is the child filter.
COUNT(callextensions; sitelinks, approvalstatus = approved) >= 2
Checks if there are at least 2 approved sitelinks or call assets associated with the campaign or ad group.
COUNT(ads) > 3
Checks if there are more than 3 ads of any type in the campaign or ad group.
COUNT(labels) = 2
Checks if there are exactly 2 labels applied to the item being filtered. This can even be applied to non-containers, such as keywords, to see all keyword that contain exactly 2 labels.
- If there are multiple conditions in the filter, they must all match for the item to be counted. They can be wrapped in an OR function to count items matching any of the conditions. For example,
COUNT(ads, OR(status = paused approvalstatus = disapproved)) > 10will check if there are more than 10 ads which are either paused, disapproved, or both.
- The filter can contain conditions that only apply to some types and those conditions will be ignored for the types they don't apply to. For example:
COUNT(keywords; sitelinks, keywordwordcount = 2 linktext : "local")will count the number of contained keywords having exactly 2 words plus the number of associated sitelinks that contain "local" in their link text.
Using the COUNT function with campaigns and ad groups
For items that can only be contained within ad groups, counting at the campaign level will total all items from all ad groups. For example,
COUNT(keywords) at the campaign level gets the total number of keywords in all ad groups of the campaign.
For items that can be contained within ad groups or campaigns, counting at the campaign level will only count the items directly within the campaign. For example,
COUNT(audiences) at the campaign level will only count campaign-level audiences. It will not also total up ad group-level audiences within the campaign. The same is true for assets:
COUNT(sitelinks) at the campaign level will only count campaign-level sitelinks, not ad group-level sitelinks within the campaign.