Skip to content

Template Variables

Overview of Template Variables

BillionMail's template variable system allows dynamic data insertion into email templates. These variables can be used in:

  • Email template content

  • Marketing task subject lines

  • Sender names

  • Anywhere requiring dynamic content

Variables use double-brace syntax:

{{ .Subscriber.VariableName }}
{{ .Task.VariableName }}

Built-in Subscriber Variables

Subscriber variables access recipient basic information:

VariableDescriptionExample Value
{{ .Subscriber.Email }}Subscriber email address[email protected]

Built-in Task Variables

Task variables access current email task information:

VariableDescriptionExample Value
{{ .Task.Addresser }}Sender email[email protected]
{{ .Task.Subject }}Email subjectAnniversary Event Notification
{{ .Task.FullName }}Sender display nameCustomer Service Department

Custom Variables

Custom variables are extra fields associated with subscribers, flexibly definable for business needs.

Examples of Common Custom Variables

json
{
    "name": "John Smith",              // Name
    "nickname": "John",          // Nickname
    "gender": "Male",                 // Gender
    "age": "28",                      // Age
    "birthday": "1996-03-21",         // Birthday
    "phone": "+1-555-0123",          // Mobile number
    "company": "Technology Co., Ltd.", // Company name
    "position": "Product Manager",     // Job title
    "industry": "Internet",           // Industry
    "city": "New York",               // City
    "interests": "Technology, Travel", // Hobbies
    "vip_level": "Gold",              // Membership level
    "register_source": "Website", // Registration source
    "last_purchase": "2024-03-01"     // Last purchase date
}

Ways to Add Custom Variables

  1. Batch import via CSV:
    Format: email,attributes

    csv
    [email protected],"{""age"":""42"",""planet"":""Mars""}"
    [email protected],"{""age"":""42"",""planet"":""Mars""}"
    [email protected],"{""name"":""John Smith"",""city"":""New York"",""job"":""Engineer""}"

    Notes:

    • attributes must be valid JSON strings.

    • All values should be in string format.

    • Multiple attributes are allowed.
      alt text

  2. Single editing:

    • Go to the subscriber details page.

    • Click "Edit".

    • Add key-value pairs in the custom variables section.

    • Save changes.

    json
    {
       "name": "John Smith",
       "city": "New York",
       "job": "Engineer"
    }

    alt text

Using Custom Variables in Templates

  1. Basic usage:
    {{ .Subscriber.VariableName }}
    Example:
    html
    Age: {{ .Subscriber.age }}  
    Planet: {{ .Subscriber.planet }}
    • Display:
      Age: 42
      Planet: Mars

Recommendations for Custom Variables

  1. Naming conventions:

    • Use lowercase letters.

    • Avoid special characters.

    • Make names self-explanatory.

    Recommended:

    json
    {"age": "25", "city": "New York"}

    Not recommended:

    json
    {"Age": "25", "City": "New York"}
  2. Data format standards:

    • Values should be plain strings.
  3. Common scenarios:

    • Personal info: name, gender, birthday, contacts

    • Membership: level, points, registration time

    • Consumption: purchase times, amount, last purchase

    • Preferences: hobbies, devices, language

    • Channels: registration source, referrer, marketing channels

  4. Data maintenance:

    • Update regularly for timeliness.

    • Clean up unused variables.

    • Maintain consistent value formats.

How to Use Variables

1. Email content template example:

Email Marketing --> Template --> Add Template

html
<div>
    <h1>Dear {{ .Subscriber.name }} </h1>
    
    <p>Hello! We see you are from {{ .Subscriber.city }},</p>
    
    <p>As a {{ .Subscriber.job }}, we've prepared special career advice for you.</p>
    
    <p>Contact us anytime with questions.</p>
    
    <footer>
        {{ .Task.FullName }}
        <br>
        {{ .Task.Addresser }}
    </footer>
</div>
  • Variable explanation:
VariableDescriptionEffect
{{ .Subscriber.name }}Custom: nameJohn Smith
{{ .Subscriber.city }}Custom: cityNew York
{{ .Subscriber.job }}Custom: jobEngineer
{{ .Task.FullName }}Built-inSender name
{{ .Task.Addresser }}Built-inSender email

alt text

2. Configure custom variables

  • Import subscribers:

Contacts --> Subscribers --> Import

[email protected],"{""name"":""John Smith"",""city"":""New York"",""job"":""Engineer""}"

alt text

  • Edit subscribers:

Contacts --> Subscribers --> Edit

json
{
    "name": "John Smith",
    "city": "New York",
    "job": "Engineer"
}

alt text

3. Test templates

Email Marketing --> Task --> Add Task
alt text

4. Test results

alt text

Best Practices

  1. Naming conventions:

    • Avoid special characters.

    • Use meaningful names.

  2. Template testing:

    • Send test emails.

    • Verify all variables display correctly.

  3. Common uses:

    • Personalized greetings

    • Regionalized content

    • Dynamic offers

    • Custom recommendations

  4. Notes:

    • Limit variables in subjects.

    • Ensure all subscribers have necessary variable values.

    • Clean up unused custom variables regularly.

Released under the AGPLv3 License