Recipe v2 Quickstart

Updated
February 7, 2025

Recipes V2

The new recipe syntax allows for more powerful and flexible queries.

What's New and Helpful

- Compare different time periods (like this month vs. last month)

- Perform math with your metrics (like finding items where sales are dropping)

// Find products where sales have dropped significantly

// (current month is 10% lower than average of last 3 months)

sales(30d) < sales(90d) / 3 * 0.9

// Find ads where clicks have dropped by more than 10%

// compared to the previous month

clicks(30d) < clicks(30d..60d) * 0.9

Overview

We've updated the recipe syntax to make it more powerful and easier to use. While it might look similar to what you're used to, it can now do much more to help you find exactly what you need in your campaigns.

If you're familiar with our previous version, you'll feel right at home - we've kept many things similar while adding helpful new features.

No more over the last x days or over the lifetime.

We've made it easier to specify when you want to look at your data. Instead of writing out "over the last X days", you can now use simple shortcuts.

Here's a basic example:

// Old way

over the last 30 days clicks > 10

// New way

clicks(30d) > 10

When you look at multiple metrics (like clicks and sales), you'll need to specify the time period for each one:

// Looking at clicks, impressions, and sales for the last 30 days

clicks(30d) > 10 and impressions(30d) > 100 and sales(30d) = 0

This new approach makes it much clearer when you're looking at different time periods:

clicks(30d) > 10

   and acos(30d) > 50%

   and sales(90d) > $10

   and sales(lifetime) > $100

compared to the old way:

// V1 Syntax

(over the last 30 days clicks > 10 and acos > 50%)

   and over the last 90 days sales > $10

   and over the lifetime sales > $100

Metrics & Properties

Metrics (Performance Data)

These are numbers that change over time and are tied

to a specific time period, like:

- Number of clicks

- Amount of sales

- Number of impressions

- ACoS (Advertising Cost of Sale)

Metrics always need a time period:

clicks(30d)           // ✓ Correct: Looking at clicks over 30 days

clicks                // ✗ Wrong: Need to specify a time period

Properties

These are current settings or details about your campaigns, like:

- Campaign name

- Budget

- Bid

- Ad group name

Properties don't use time periods:

bid > $0.25          // ✓ Correct: Checking current bid

bid(30d) > $0.25     // ✗ Wrong: Bids don't use time periods

Enhanced time periods

You have three flexible ways to look at your data:

1. Relative Time Periods

Look back a certain number of days:

clicks(30d)    // Last 30 days

clicks(90d)    // Last 90 days

For example, if today is January 31st, 2025:

- clicks(30d) looks at January 1st through January 31st, 2025

This is an inclusive time period, including both the start and end dates.

2. Literal Date Ranges

Look at exact dates:

clicks(2024-01-01..2024-01-31)    // All of January 2024

This is an inclusive time period, including both the start and end dates.

Make sure to use the format: YYYY-MM-DD

3. Relative Offset Time Periods

Look at earlier time periods to compare performance:

clicks(30d..60d) // from 30 days ago to 60 days ago

Think of `30d..60d` as "from 30 days ago to 60 days ago" - it's great for comparing current performance against previous periods.

Pro Tip: Use these time periods to spot trends in your data. For example, you can see if performance is improving or declining over time.

Either the leading or the trailing time period can be omitted.

- `clicks(..60d)` is "the lifetime, except the last 59 days".

- `clicks(30d..)` is equivalent to `clicks(30d)`.

Arithmetic operations

You can now perform arithmetic operations on metrics and numeric

properties (like budgets or bids).

If you wanted to find items where the bid is less

than the average CPC over the past 30 days plus

$0.05, then you can do that with the following:

bid < cpc(30d) + $0.05

Addition, subtraction, multiplication, and division are supported.

Multiple arithmetic operators are evaluated via order of operations. Multiplication and division are evaluated first, then addition and subtraction.

bid * 2 + $0.05 < 10

is equivalent to

(bid * 2) + $0.05 < 10

but _not_ equivalent to

bid * (2 + $0.05) < 10

Comments

Comments are supported by starting the line with `//`.

// This is a comment

bid < cpc(30d) + $0.05

Or multiline comments.

/*

This is a multiline comment

*/

bid < cpc(30d) + $0.05

Grouping

Parentheses are used to group expressions together.

(sales(30d) = 0 and clicks(30d) > 10)

or (acos(90d) > 40% and sales(90d) < $50)

Operator Precedence

You should be aware of operator precedence. V1 syntax

did not allow you to mix AND and OR in the same expressions.

You could _not_ do something like

over the last 30 days

  clicks > 10 and impressions > 100 or sales = 0

It would error. You had to be explicit about where the parentheses

were placed. So either

over the last 30 days

  (clicks > 10 and impressions > 100) or sales = 0

or

over the last 30 days

  clicks > 10 and (impressions > 100 or sales = 0)

The v2 syntax does not have this restriction. You can mix AND and OR freely. It relies on something call operator precedence, which

is basically just a fancy way of saying that the "AND" items are evaluated first.

`AND` has a higher precedence than `OR`.

So this:

clicks(30d) > 10 and impressions(30d) > 100 or sales(30d) = 0

is equivalent to this:

(clicks(30d) > 10 and impressions(30d) > 100) or sales(30d) = 0

but this would give different results:

clicks(30d) > 10 and (impressions(30d) > 100 or sales(30d) = 0)

String Operations

Properties that contain text (like the campaign name or ad group name) can be compared using several operators:

- `=` exact match

- `!=` not equal

- `contains` substring match

- `does not contain` substring non-match

- `starts with` prefix match

- `ends with` suffix match

campaign name contains "lottery"

campaign name does starts with "B00KSB00KS"

Reference

A full list of all currently supported metrics and properties is below.

Metrics

- clicks

- impressions

- sales

- acos

- cost

- spend

- orders

- cpc

- ctr

- cvr

- roas

- rpc

- cac

- aov

KDP only Metrics

- pages read

- estimated royalties

- adjusted sales

- adjusted orders

- adjusted pages read

- adjusted estimated royalties

- blended profit

- blended rpc

- blended acos

- blended roas

- blended cvr

- blended cac

- blended aov

Properties

- state

- bid

- campaign name

- ad group name

- budget

- daily budget

- default bid

- campaign start date

- campaign end date

Need more help?