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:
Variable | Description | Example Value |
---|---|---|
{{ .Subscriber.Email }} | Subscriber email address | [email protected] |
Built-in Task Variables
Task variables access current email task information:
Variable | Description | Example Value |
---|---|---|
{{ .Task.Addresser }} | Sender email | [email protected] |
{{ .Task.Subject }} | Email subject | Anniversary Event Notification |
{{ .Task.FullName }} | Sender display name | Customer Service Department |
Custom Variables
Custom variables are extra fields associated with subscribers, flexibly definable for business needs.
Examples of Common Custom Variables
{
"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
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.
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" }
Using Custom Variables in Templates
- Basic usage:Example:
{{ .Subscriber.VariableName }}
htmlAge: {{ .Subscriber.age }} Planet: {{ .Subscriber.planet }}
- Display:
Age: 42
Planet: Mars
- Display:
Recommendations for Custom Variables
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"}
Data format standards:
- Values should be plain strings.
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
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
<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:
Variable | Description | Effect |
---|---|---|
{{ .Subscriber.name }} | Custom: name | John Smith |
{{ .Subscriber.city }} | Custom: city | New York |
{{ .Subscriber.job }} | Custom: job | Engineer |
{{ .Task.FullName }} | Built-in | Sender name |
{{ .Task.Addresser }} | Built-in | Sender email |
2. Configure custom variables
- Import subscribers:
Contacts --> Subscribers --> Import
[email protected],"{""name"":""John Smith"",""city"":""New York"",""job"":""Engineer""}"
- Edit subscribers:
Contacts --> Subscribers --> Edit
{
"name": "John Smith",
"city": "New York",
"job": "Engineer"
}
3. Test templates
Email Marketing --> Task --> Add Task
4. Test results
Best Practices
Naming conventions:
Avoid special characters.
Use meaningful names.
Template testing:
Send test emails.
Verify all variables display correctly.
Common uses:
Personalized greetings
Regionalized content
Dynamic offers
Custom recommendations
Notes:
Limit variables in subjects.
Ensure all subscribers have necessary variable values.
Clean up unused custom variables regularly.