Skip to main content

Context Variables

Context Variables

Overview

Derived Context Variables are computed server-side from the normalized context generated by the Cloudflare Worker. Unlike raw context variables, derived variables represent higher-level contextual insights that creatives can consume directly without implementing business logic in the client runtime.

Benefits

  • Zero client-side computation
  • Consistent evaluation across all creatives
  • Edge-cacheable responses
  • Smaller runtime bundle
  • Simple variable binding
  • Faster creative rendering

Processing Flow

Cloudflare Request
        │
        ▼
Geo + Network + Bot
        │
        ▼
Weather API
        │
        ▼
Normalize Context
        │
        ▼
Evaluate Derived Variables
        │
        ▼
Cache Final Response
        │
        ▼
Return Context

Variable Categories

Category

Description

Weather

Temperature, comfort, daylight and weather classifications

Time

Daypart, work hours and behavioural context

Network

Network capability and media suitability

Traffic

Traffic quality and trust signals

Audience

Behavioural context for personalization

Device

Device capability and rendering suitability

Media

Recommended media quality


Weather Variables

Variable

Type

Possible Values

Logic

weather.temperature_band

String

hot

,

warm

,

cold

temp >= 35 → hot

,

25 ≤ temp < 35 → warm

, otherwise

cold

weather.condition_type

String

sunny

,

cloudy

,

rainy

,

stormy

,

snowy

,

foggy

Maps weather condition text/code returned by the weather provider

weather.uv_level

String

low

,

moderate

,

high

,

extreme

UV < 3 → low

,

3–6 → moderate

,

6–9 → high

,

>=10 → extreme

weather.comfort_level

String

comfortable

,

humid

,

hot_humid

,

cold

Derived from temperature and humidity

weather.wind_level

String

calm

,

moderate

,

windy

,

stormy

<5

,

5–20

,

20–40

,

>40 km/h

weather.is_daylight

Boolean

true

,

false

weather.is_day == true

weather.precipitation_level

String

none

,

light

,

moderate

,

heavy

Derived from precipitation amount

weather.visibility_level

String

clear

,

moderate

,

poor

Derived from visibility distance

weather.activity_suitability

String

excellent

,

good

,

poor

Combination of temperature, precipitation, UV index and wind


Time Variables

Variable

Type

Possible Values

Logic

time.daypart

String

early_morning

,

morning

,

afternoon

,

evening

,

night

05:00–08:00

,

08:00–12:00

,

12:00–17:00

,

17:00–21:00

, otherwise

night

time.is_weekend

Boolean

true

,

false

Saturday or Sunday

time.is_work_hours

Boolean

true

,

false

09:00–18:00

on weekdays

time.meal_period

String

breakfast

,

lunch

,

snack

,

dinner

,

late_night

Determined from the current hour

time.productivity_state

String

productive

,

relaxed

,

sleeping

Derived from daypart and work hours


Network Variables

Variable

Type

Possible Values

Logic

network.speed_tier

String

fast

,

moderate

,

slow

Derived from RTT and HTTP protocol

network.connection_stability

String

stable

,

unstable

RTT heuristics

network.connection_type

String

broadband

,

mobile

,

enterprise

,

unknown

ASN and ISP lookup

network.is_broadband

Boolean

true

,

false

Derived from ASN/ISP mapping

network.supports_rich_media

Boolean

true

,

false

Fast connection and modern protocol (HTTP/3)

network.video_quality_tier

String

low

,

medium

,

high

Recommended video quality based on network capability


Traffic Variables

Variable

Type

Possible Values

Logic

traffic.quality_tier

String

high

,

medium

,

low

Derived from bot score, proxy detection and network quality

traffic.is_suspicious

Boolean

true

,

false

Bot or proxy detection

traffic.trust_score

Number

0–100

Weighted trust scoring algorithm


Audience Variables

Variable

Type

Possible Values

Logic

audience.outdoor_score

Number

0–100

Weighted weather and daylight score

audience.outdoor_likelihood

String

high

,

medium

,

low

Derived from outdoor score

audience.commerce_intent

String

high

,

medium

,

low

Based on time, weather and work state

audience.engagement_likelihood

String

high

,

medium

,

low

Derived from traffic quality, network capability and time

audience.mobility_state

String

commuting

,

working

,

stationary

,

leisure

,

sleeping

Time and daypart heuristics

audience.session_mood

String

productive

,

relaxed

,

entertainment

,

rushed

Behavioural context

audience.purchase_context

String

impulse

,

relaxed

,

functional

Combination of time, weather and mobility state


Device Variables

Variable

Type

Possible Values

Logic

device.rich_media_ready

Boolean

true

,

false

Fast network and trusted traffic

device.experience_tier

String

premium

,

standard

,

lite

Combined network and device capability


Media Variables

Variable

Type

Possible Values

Logic

media.video_quality

String

240p

,

480p

,

720p

,

1080p

Recommended maximum video quality based on network capability


Notes

  • All derived variables are evaluated server-side in the Cloudflare Worker.
  • Derived variables are returned alongside raw context variables in the API response.
  • Creatives consume derived variables exactly like normal context variables.
  • No client-side expression evaluation is required.
  • The final response, including derived variables, can be cached at the Cloudflare edge for optimal performance.