Variables
Understand how data flows between steps and how to use variables in emails, invoices, and conditions.
What are Variables?
Variables are named placeholders that carry data from one step to the next. When a Pull Stats step fetches your affiliate stats, the results are stored as a dataset and exposed as variables — for example, {stats_1_affiliate_name} or {stats_1_revenue}. You then insert those variables into your email body, invoice template, or condition check, and AffZero replaces them with real values when the automation runs.
Variable Naming Convention
Variables follow a consistent pattern depending on which step produced them.
Pull Stats Variables (dataset mode)
This is the default for every new Pull Stats step — no manual cell selection required. Every column returned by the pull is automatically exposed as a variable:
| Pattern | Example | What it contains |
|---|---|---|
{stats_N_column} | {stats_1_revenue} | Value of column from the first row matching the step's filters (row order matches the step's default sort, e.g. revenue descending) |
{column} (no prefix) | {revenue} | Clean alias for the same first-row value from the most recently executed Pull Stats step in the workflow. Convenient with a single Pull Stats step; prefer the prefixed form once you have 2 or more |
{stats_N_total_column} | {stats_1_total_revenue} | Sum of column across all rows (only emitted for numeric, non-ID columns) |
{stats_N_avg_column} | {stats_1_avg_revenue} | Average of column across all rows |
{stats_N_rows_count} | {stats_1_rows_count} | Number of rows returned after filters |
{stats_N_data_table} | {stats_1_data_table} | The full result set rendered as an HTML table — drop straight into an email body. Add :col1,col2 to restrict columns, e.g. {stats_1_data_table:Revenue,Payout} |
{stats_N_data_json} | {stats_1_data_json} | The full result set as a JSON array — useful for webhook/API payloads |
Where N is the 1-based index of the Pull Stats step (first Pull Stats step = 1, second = 2, etc.) and column is the snake_case column name (e.g. affiliate_name, revenue, payout, clicks, conversions).
With a single Pull Stats step, {data_table} and {data_json} (no stats_N_ prefix) also work and refer to that step's dataset.
Legacy Cell-Selection Variables
Automations created before dataset mode existed (or steps still configured with manual cell selection) use row-indexed names instead:
{column_name_row_index_stats_N}
Where row_index is the 1-based row position (first row = 1, second row = 2, etc.) and N is the Pull Stats step index.
Examples:
| Variable | What it contains |
|---|---|
{affiliate_name_1_stats_1} | Name of the affiliate in row 1 from the first Pull Stats step |
{revenue_1_stats_1} | Revenue for row 1, first Pull Stats step |
{payout_2_stats_1} | Payout for row 2, first Pull Stats step |
New Pull Stats steps also emit these legacy names for the first ~20 rows automatically, so both naming styles work interchangeably. Prefer the dataset-mode names above for anything you write yourself — they're shown in the Variables Available panel and don't depend on row position.
AI Analyze Variables
The AI Analyze step produces custom named variables based on your instruction. For example, if you tell the AI to "find the top affiliate by revenue", it might produce:
{top_affiliate}— the name{top_affiliate_revenue}— the revenue value
These names are chosen by the AI, so you can copy them from the Variables Available panel after running the step.
Invoice Number Variables
AffZero has two independent invoice numbering systems, each producing its own variable:
Global sequence — configured at Invoices → Invoice Numbering, generated inside the Create Invoice step:
{invoice_number_global}
Available in any step that runs after a Create Invoice step. Shared across all automations.
Local sequence — from a Generate Invoice Number step added to this automation:
{invoice_number_local}
The name is user-defined when you configure the step (defaults to invoice_number_local). Scoped to this automation only, independent from the global sequence.
Both can be active in the same automation at the same time.
Tracker Action Get Variables
{field_path_action_N}
Where field_path is the API response field you selected, and N is the step index.
Date Variables
AffZero automatically injects a set of date variables into every automation run. These are available in email bodies, invoice templates, Google Sheets cells, and anywhere else variables are supported — no Pull Stats step required for the "today" and Net date variables.
Always-available date variables
These are computed fresh at the time the automation runs:
| Variable | Example value | Description |
|---|---|---|
{date_today} | March 31, 2026 | Today's date in long form |
{date_future_net15} | April 15, 2026 | 15 calendar days from today (Net 15) |
{date_future_net30} | April 30, 2026 | 30 calendar days from today (Net 30) |
Custom NET due dates
You can use any number — not just 15 or 30. Simply write the number directly into the placeholder:
| You type | What it resolves to |
|---|---|
{date_future_net7} | 7 days from today |
{date_future_net45} | 45 days from today |
{date_future_net60} | 60 days from today |
{date_future_net90} | 90 days from today |
NET terms are the standard payment convention in affiliate marketing: "Net 30" means the invoice is due 30 days after the invoice date. Use {date_future_net30} in your invoice template's due date field and it will always resolve to the correct date for that run.
Example invoice due date line:
Invoice Date: {date_today}
Payment Due: {date_future_net30}
Stats date range variables
These are set when your automation includes a Pull Stats step. They reflect the date range of the stats being pulled:
| Variable | Example value | Description |
|---|---|---|
{date_month_year} | March 2026 | Month and year of the stats period |
{date_long_format} | March 1, 2026 | Start date in long form |
{date_formatted} | 03/01/2026 | Start date in your preferred format (MM/DD or DD/MM) |
{date_month} | March | Month name |
{date_year} | 2026 | Year |
{date_start_day} | 01 | Day number of the range start |
{date_end_day} | 31 | Day number of the range end |
{date_preset} | Last Month | The date preset label used for the pull |
All date variables appear in the Date Variables section of the Variables Available panel (the blue collapsible block at the bottom of the list).
Where Pull Stats Variables Come From
In dataset mode (the default), every column of every row returned by the pull becomes available automatically — there's nothing to select. Run a test pull to see the real column names and sample values in the Variables Available panel before you build the rest of your workflow.
If a step still uses the legacy cell-selection mode, variables are only created for the cells you explicitly clicked during the test pull — data that wasn't clicked isn't available downstream even if it appears in the test pull table.
Entity Matching in Legacy Cell-Selection Mode
This section applies only to steps still using legacy cell-selection mode. Dataset-mode steps always reflect the live, current-run data and don't need entity matching.
When a legacy cell-selection automation runs for real (not a test pull), the stats data may come back in a different order depending on how the tracker API returns results on that day. AffZero handles this by tracking the entity ID (e.g. the affiliate's internal ID) instead of just the row position.
When AffZero fetches fresh data during a run:
- It looks up the entity ID you selected (e.g. Affiliate ID 123)
- Finds that entity in the fresh results — regardless of which row it's in
- Extracts the variable values from that matched row
This means {affiliate_name_1_stats_1} always refers to the same affiliate, not just whoever happens to be in row 1 on that particular day.
If an affiliate is not present in the fresh stats (e.g. they had no activity that week), AffZero falls back to the row position from your test pull, and ultimately to the test value you saw when you selected the cell. You'll see a warning in the run log if this happens.
How to Insert Variables
Variables can be used in:
- Email subject line — type
{to start or use the Variables panel to copy and paste - Email body — click the variable name in the Variables Available panel to insert it at the cursor position
- Invoice HTML template — type the variable name directly in the HTML
- Invoice filename — include variables like
{stats_1_affiliate_name}in the filename field - Condition Check — reference variables in condition rules (e.g.
{stats_1_total_revenue}is greater than5000) - Google Sheets — map variable values to specific columns
If a variable name is misspelled or doesn't exist, AffZero leaves the literal {variable_name} text in place rather than failing the step. Always copy variable names from the Variables Available panel to avoid typos, and check the run log for "unresolved placeholder" warnings after a test run.
Variables Available Panel
Every step that consumes variables (Send Email, Condition Check, Create Invoice, etc.) shows a Variables Available panel on the left side of the step editor. This panel lists every variable from all previous data-producing steps.
- Click a variable name to copy it
- Use the Insert button to place it at the current cursor position in the editor
- Variables from multiple Pull Stats steps are grouped by step for clarity
Multi-Step Variable Example
Step 1: Pull Stats (Affise, By Affiliate, Last 7 Days)
→ {stats_1_affiliate_name}, {stats_1_revenue}, {stats_1_payout}
→ {stats_1_total_revenue}, {stats_1_total_payout}, {stats_1_rows_count}
→ {stats_1_data_table} (full table, all affiliates)
Step 2: AI Analyze ("Identify top performer and flag any payout < $100")
→ {top_affiliate}, {low_payout_count}, {low_payout_affiliates}
Step 3: Send Email
→ Can use ANY variable from Step 1 and Step 2
→ Subject: "Weekly report — top performer: {top_affiliate}"
→ Body: "Revenue leader: {top_affiliate} | Total payout this week: {stats_1_total_payout}"