Magento 2 Email Template Variables [Complete List]

Variable is a data item that can be applied multiple times and for different purposes. In Magento, variables are used to customize email templates. There are two types of variables: predefined and custom. Magento 2 gives you a great load of predefined (default) email template variables that will help you to adjust your email templates for personal usage.

Obviously, it is impossible to keep all of them in mind. So here you can find a complete list of Magento 2 email templates variables. 

Additionally, you'll learn how to add your custom variable to email templates and use it in your emails.

Default Email Template Variables in Magento 2

Default Variable Description  Magento 2 Default Variable Used in Email Templates
Base URL {|{config path="web/unsecure/base_url"}}
Secure Base URL {|{config path="web/secure/base_url"}}
General Sender Name  {|{config path="trans_email/ident_general/name"}}
General Sender Email  {|{config path="trans_email/ident_general/email"}}
Sales Representative Sender Name {|{config path="trans_email/ident_sales/name"}}
Sales Representative Sender Email {|{config path="trans_email/ident_sales/email"}}
Customer Support Sender Name {|{config path="trans_email/ident_support/name"}}
Customer Support Sender Email {|{config path="trans_email/ident_support/email"}}
Custom Email 1 Sender Name {|{config path="trans_email/ident_custom1/name"}}
Custom Email 1 Sender Email {|{config path="trans_email/ident_custom1/email"}}
Custom Email 2 Sender Name {|{config path="trans_email/ident_custom2/name"}}
Custom Email 2 Sender Email {|{config path="trans_email/ident_custom2/email"}}
Store Name {|{config path="general/store_information/name"}}
Store Phone Number {|{config path="general/store_information/phone"}}
Store Hours of Operation {|{config path="general/store_information/hours"}}
Country {|{config path="general/store_information/country_id"}}
Region/State {|{config path="general/store_information/region_id"}}
ZIP/Postal Code {|{config path="general/store_information/postcode"}}
City {|{config path="general/store_information/city"}}
Street Address {|{config path="general/store_information/street_line1"}}
Street Address Line 2 {|{config path="general/store_information/street_line2"}}
VAT Number {|{config path="general/store_information/merchant_vat_number"}}
Store Name {|{var store.frontend_name}}
Customer Account URL {|{var this.getUrl($store,'customer/account/',[_nosid:1])}}
Password Reset URL {|{var this.getUrl($store,'customer/account/createPassword/',[_query:[id:$,token:$customer.rp_token],_nosid:1])}}
Customer Email {|{var}}
Customer Name {|{var}}

Except for all these default variables, Magento 2 gives you the possibility to add your custom variables. And that's what we'll learn to do next.

Add Custom Variable to Email Template in Magento 2

Although there are many default email template variables in Magento 2, the list is still rather limited if you have some specific goals. But, actually, it isn't a problem, since Magento allows you to add custom variables to meet the needs of your store.

Just follow the steps written below to add custom variables for email templates in Magento.

1. Create Custom Variable

1. Go to System > Other Settings > Custom Variables and press the Add New Variable button. 

2. Complete the required information:

  • Add the Variable Code, written in lowercase without spaces. However, underscores and hyphens are acceptable.
  • Complete the Variable Name which is used for the inner reference.
  • In the Variable HTML Value field, add the formatted version of the variable value, with the help of the HTML tags.
  • Fill in the Variable Plain Value field, using plain unformatted text. 

Create Custom Variable in Magento 2

Don't forget to Save the new custom variable and proceed with adding it to your email template. 

2. Add Custom Variable to the Email Template 

1. Go to Marketing > Communications > Email Templates and choose the template you want to add the custom variable to or create a new template in the Template field.

2. Press the Insert Variable button, where you will find the full list of default and custom variables. Choose the custom variable you would like to add. It will be automatically added to the Template Content field. 

How to Add Custom Variable in Magento 2?

Save Template after you finish all the changes. 

These are all the steps you have to take to add custom variables to the email templates. 

Using both default and custom email template variables you create better store-customer communication and make your emails even more personalized. We're talking not only about order confirmation and shipment comments templates. 

If you want to configure new review notifications and customer registration email notification, you can use variables to tweak the information sent to your email box.