# Variables & Data Fields

Variables and data fields let you capture, store, and reuse information throughout your video flow. Track user responses, personalize content, and create dynamic experiences that adapt to each viewer.

## What Are Variables?

Variables are containers that store data during a viewer's journey through your video. They can hold:

* User responses to questions
* Data from your CRM or database
* Calculated values (scores, totals, etc.)
* System information (time, date, etc.)

## Types of Variables

### User Input Variables

Capture responses from interactive elements:

**Examples:**

* `user_name` — "John Smith"
* `company_size` — "Enterprise"
* `budget_range` — "$10,000-$50,000"
* `preferred_features` — \["Analytics", "Automation"]

### Calculated Variables

Derived from user interactions or data processing:

**Examples:**

* `quiz_score` — 85 (calculated from answers)
* `total_points` — 150 (sum of all interactions)
* `time_spent` — 245 (seconds in video)
* `completion_percentage` — 75%

### System Variables

Automatically provided by the platform:

**Examples:**

* `current_time` — "2024-01-15 14:30:00"
* `viewer_id` — "user\_12345"
* `session_start` — "2024-01-15 14:25:00"
* `device_type` — "mobile"

## Using Variables in Your Flow

### Displaying Variables

Show variable values in your content:

**Examples:**

* "Hello, {{user\_name}}!"
* "Your score: {{quiz\_score}}/100"
* "Based on your {{company\_size}} needs..."
* "You've earned {{total\_points}} points"

### Conditional Logic

Use variables to control branching:

**Examples:**

```
IF quiz_score >= 80 THEN show "Advanced" content
IF company_size = "Enterprise" THEN show enterprise features
IF total_points > 100 THEN show bonus offer
```

### Dynamic Content

Personalize based on stored data:

**Examples:**

* Show different product recommendations based on `preferred_features`
* Display custom pricing based on `budget_range`
* Adjust content length based on `time_spent`

## Real-World Examples

### Customer Onboarding Flow

```
Variables captured:
- user_name: "Sarah Johnson"
- company_size: "Mid-market"
- primary_goal: "Increase efficiency"
- team_size: 25

Used for:
- Personalized greeting: "Hi Sarah!"
- Relevant features: Show mid-market solutions
- Custom messaging: Focus on efficiency benefits
- Team recommendations: Suggest 25-user package
```

### Product Recommendation Quiz

```
Variables captured:
- budget: "$5,000-$10,000"
- use_case: "Marketing automation"
- experience_level: "Intermediate"
- timeline: "3 months"

Calculated:
- recommendation_score: 85
- best_product: "Pro Plan"
- estimated_roi: "$15,000"

Used for:
- Product recommendation: "Based on your needs, we recommend Pro Plan"
- ROI projection: "Expected ROI: $15,000"
- Next steps: "Schedule a demo for Pro Plan"
```

## Advanced Variable Features

### Variable Arrays

Store multiple values in a single variable:

**Examples:**

* `selected_features` — \["Analytics", "Automation", "Reporting"]
* `quiz_answers` — \["A", "B", "C", "A", "B"]
* `interaction_history` — \["clicked\_demo", "viewed\_pricing", "downloaded\_guide"]

### Variable Calculations

Perform math operations on variables:

**Examples:**

* `total_cost = base_price + add_ons`
* `discount_amount = original_price * 0.15`
* `final_score = (correct_answers / total_questions) * 100`

### Variable Persistence

Store variables across sessions:

**Examples:**

* Remember user preferences for future visits
* Track cumulative engagement across multiple videos
* Build user profiles over time

## Best Practices

### Variable Naming

* **Use descriptive names** — `user_company_size` instead of `var1`
* **Follow consistent conventions** — Use underscores for multi-word variables
* **Avoid reserved words** — Don't use system keywords
* **Document your variables** — Keep a list of what each variable stores

### Data Management

* **Validate input** — Ensure data is in expected format
* **Handle missing data** — Provide fallbacks for empty variables
* **Clean data** — Remove unnecessary spaces, format consistently
* **Secure sensitive data** — Don't store passwords or personal info in variables

### Performance

* **Limit variable count** — Too many variables can slow performance
* **Use appropriate data types** — Text, numbers, dates, etc.
* **Clean up unused variables** — Remove variables you no longer need
* **Optimize calculations** — Keep complex calculations simple

## Common Use Cases

* **Personalized greetings and messaging**
* **Dynamic product recommendations**
* **Quiz scoring and results**
* **Progress tracking and gamification**
* **A/B testing and optimization**
* **Lead qualification and scoring**
* **Customer journey mapping**

***

**Ready to personalize your content?** Learn about [dynamic data fields](/personalization-data-management/dynamic-data-fields.md) for advanced personalization.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.blings.io/workflows-branching-logic/variables-data-fields.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
