Available Twig Tokens
Reference guide for tokens available within the Twig Templates plugin for Mautic.
The Twig Templates plugin provides several objects and tokens you can use to access Mautic data and perform actions within your templates.
Contact Object (contact
)
The contact
object provides access to the fields of the contact viewing the email or landing page.
- Standard Fields: Access any standard Mautic contact field using its alias (e.g.,
contact.firstname
,contact.email
,contact.city
). - Custom Fields: Access custom contact fields using their alias (e.g.,
contact.custom_field_alias
). - Tags: Access the contact’s tags as an array.
- Segments: Access the segments (lists) the contact belongs to as an array of objects. Each object has properties like
id
andname
. - Companies (
contact.companies
): Access all companies associated with the contact as an array of company objects. Each object contains the company’s fields. - Primary Company Shortcut (
contact.primaryCompany
): Returns the primary company object if one is set. If no company is explicitly marked as primary, it returns the first company associated with the contact. Returnsnull
if the contact has no associated companies.
Form Result Tokens
These tokens are available only when an email is triggered by a form submission action (either directly or via a campaign). See Forms Support for details.
formresult
: An object containing the data from the most recent form submission by the contact. Field names correspond to form field aliases.formresults
: An array containing all form submission data associated with the contact. Each element is an object likeformresult
.
Email Tokens (tokens
)
When sending emails via the API, you can pass custom tokens in the payload. These are accessible via the tokens
object. See the API Documentation for usage.
This list covers tokens specifically added or enhanced by the Twig Templates plugin. Standard Twig variables and functions (like now
for the current time) are also available. Refer to the official Twig Documentation for more on standard Twig capabilities. For accessing Custom Objects data, see the Custom Objects Support page.