You can use conjunction (&&) and disjunction (||) in rules.
Negation is done using the keyword not
Expressions can parenthesized for grouping.
The following are examples of valid predicates:
city("Orem") || city("Provo")
not(city("Orem") || city("Provo"))
state("UT") && not city("Provo")
Testing for Equality
You can build predicate expressions that test for equality and inequality.
For numbers you can use <, >, <=, >=, ==, and !=
For strings you can use eq, neq, and like. like takes a regular expression as its second argument and returns true if it matches the string given as it's first argument.
Arguments can be any valid expression including arithmetic expressions, datasources (see Declarations), constants, page variables (see Page Variables), URL variables, or variables declared in the pre block (see Declarations).
The following predicates are available for use in rules. If you think of others we ought to have, just ask.
The predicates are grouped by data source.
Location Predicates
city(<arg>)
returns true when <arg> matches the customer city.
outside_city(<arg>)
returns true when <arg> does not match the customer city.
state(<arg>)
returns true when <arg> matches the customer state.
outside_state(<arg>)
returns true when <arg> does not match the customer state.
country(<arg>)
returns true when <arg> matches the customer county. <arg> must be a valid two-digit country code. Use GB for United Kingdom.
outside_country(<arg>)
returns true when <arg> does not match the customer country. <arg> must be a valid two-digit country code. Use GB for United Kingdom.
international()
returns true when the customer country is not 'US'.
Media Market Predicates
media_market_rank_grater_than(<arg>)
returns true when media market rank is greater then <arg>.
media_market_rank_less_than(<arg>)
returns true when media market rank is less then <arg>.
dma_is(<arg>)
returns true when <arg> is your DMA Media Market Code.
Demographic Predicates
The data used by this data source is from the 2000 US Census. Demographic data is only available for US households at present. For median income, it is useful to keep this table of median income distributions by zipcode in mind:
Income Range
Number of Zips
Percent
$0 - $10000
127
0.40%
$10000 - $20000
1256
3.91%
$20000 - $30000
6916
21.55%
$30000 - $40000
11564
36.03%
$40000 - $50000
6247
19.46%
$50000 - $60000
2933
9.14%
$60000 - $70000
1484
4.62%
$70000 - $80000
711
2.22%
$80000 - $90000
385
1.20%
$90000 - $100000
186
0.58%
$100000 - $110000
132
0.41%
$110000 - $120000
61
0.19%
$120000 - $130000
35
0.11%
$130000 - $140000
14
0.04%
$140000 - $150000
15
0.05%
$150000 - $160000
13
0.04%
$160000 - $170000
2
0.01%
$170000 - $180000
3
0.01%
$180000 - $190000
2
0.01%
$190000 - $200000
1
0.00%
Above $200000
11
0.03%
Note that less than 20% of US zip codes have a median income above $50000. Also note that the median income of many work locations is lower than you might think, so you might want to combine the median income predicates with the at_home predicate (to be implemented).
A zip code is classified as "urban" if more than 70% of total population lives in an urban setting and "rural" if more than 70% of total population lives in an rural setting. Note that with this definition, "not urban" isn't the same as "rural". The classification "mixed" applied to zip codes that are neither urban nor rural. The following table shows the overall number of zip codes and percentages classified as rural, urban, or mixed:
Type
Number of Zips
Percent
Urban
10131
30.53%
Rural
18496
55.74%
Mixed
4553
13.72%
Note that even though the majority of zip codes are rural, according to the classification given above, 75% of the population lives in an urban setting as shown in the following table:
Type
Population
Percent
Urban
214461186
75.19%
Rural
33122004
11.61%
Mixed
37647326
13.20%
median_income_above(<arg>)
returns true when the median income of the zip code the customer is in is greater than the number given in <arg>
median_income_below(<arg>)
returns true when the median income of the zip code the custom is in is less than the number given in <arg>
median_income_between(<low>,<high>)
returns true when the median income of the zip code the custom is in is between <low> and <high> </dd>
urban()
returns true when the customer is in an urban location.
rural()
returns true when the customer is in an rural location.
Weather Predicates
All predicates are relative to local weather. That is weather where the customer is.
warmer_than(<arg>)
Is the current temperature warmer than <arg>
colder_than(<arg>)
Is the current temperature colder than <arg>
tomorrow_cond(<arg>)
Is <arg> the condition code for tomorrow's weather?
today_showers()
Is rain forecast today?
tomorrow_showers()
Is rain forecast tomorrow?
today_cloudy()
Is cloudy weather forecast for today?
tomorrow_cloudy()
Is cloudy weather forecast for tomorrow?
today_snow()
Is snow forecast for today/
tomorrow_snow()
Is snow forecast for tomorrow?
today_windy()
Is wind forecast for today/
tomorrow_windy()
Is wind forecast for tomorrow?
today_sunny()
Is sunny weather forecast for today/
tomorrow_sunny()
Is sunny weather forecast for tomorrow?
Time Predicates
All of the following predicates are referenced to the users local time. All times are 24-hour clock.
timezone(<arg>) </dt>
<arg> is the name of a timezone in a timezone code like "America/Denver"
Predicates
Predicate Expressions
The following are examples of valid predicates:
city("Orem") || city("Provo") not(city("Orem") || city("Provo")) state("UT") && not city("Provo")Testing for Equality
You can build predicate expressions that test for equality and inequality.
For numbers you can use <, >, <=, >=, ==, and !=
For strings you can use eq, neq, and like. like takes a regular expression as its second argument and returns true if it matches the string given as it's first argument.
Arguments can be any valid expression including arithmetic expressions, datasources (see Declarations), constants, page variables (see Page Variables), URL variables, or variables declared in the pre block (see Declarations).
The following are all valid tests for equality:
c == 5 page:var("city") eq "Blackfoot" "Orem" neq location:city() weather:curr_temp() < 90 location:city() + ", WA" eq city 5 * (weather:curr_temp() - 32) / 9 < 0Predicates
The following predicates are available for use in rules. If you think of others we ought to have, just ask.
The predicates are grouped by data source.
Location Predicates
city(<arg>)outside_city(<arg>)state(<arg>)outside_state(<arg>)country(<arg>)outside_country(<arg>)international()Media Market Predicates
media_market_rank_grater_than(<arg>)media_market_rank_less_than(<arg>)dma_is(<arg>)Demographic Predicates
The data used by this data source is from the 2000 US Census. Demographic data is only available for US households at present. For median income, it is useful to keep this table of median income distributions by zipcode in mind:
Note that less than 20% of US zip codes have a median income above $50000. Also note that the median income of many work locations is lower than you might think, so you might want to combine the median income predicates with the
at_homepredicate (to be implemented).A zip code is classified as "urban" if more than 70% of total population lives in an urban setting and "rural" if more than 70% of total population lives in an rural setting. Note that with this definition, "not urban" isn't the same as "rural". The classification "mixed" applied to zip codes that are neither urban nor rural. The following table shows the overall number of zip codes and percentages classified as rural, urban, or mixed:
Note that even though the majority of zip codes are rural, according to the classification given above, 75% of the population lives in an urban setting as shown in the following table:
median_income_above(<arg>)median_income_below(<arg>)median_income_between(<low>,<high>)urban()rural()Weather Predicates
All predicates are relative to local weather. That is weather where the customer is.
warmer_than(<arg>)colder_than(<arg>)tomorrow_cond(<arg>)today_showers()tomorrow_showers()today_cloudy()tomorrow_cloudy()today_snow()tomorrow_snow()today_windy()tomorrow_windy()today_sunny()tomorrow_sunny()Time Predicates
All of the following predicates are referenced to the users local time. All times are 24-hour clock.
timezone(<arg>)</dt>daytime()nighttime()morning()afternoon()evening()night()lunch_time()late_morning()early_afternoon()late_afternoon()time_between(<start_hour>, <start_minute>, <end_hour>, <end_minute>)date_between(<start_month>, <start_day>, <start_year>, <end_month>, <end_day>, <end_year>)date_start(<start_month>, <start_day>, <start_year>)day_of_week(<day name>)today_is(<sun>, <mon>, <tue>, <wed>, <thur>, <fri>, <sat>)weekday()weekend()Economic Indicator Predicates
djia_up_more_than(<arg>)djia_down_more_than(<arg>)Referer Predicates
search_engine_referer()referer_domain(<arg>)remote_referer()local_referer()Browser Predicates
using_ie()using_firefox()Misc Predicates
truth()