Twig Templates Snippets Library
A collection of ready-to-use Twig snippets for Mautic personalization.
Here are useful Twig snippets for personalizing Mautic emails, landing pages, and text messages.
Access Primary Company Details
Use the contact.primaryCompany
shortcut to easily access the primary company associated with the contact. If no company is explicitly marked as primary, this will return the first company associated. It returns null
if no companies are linked.
List All Associated Companies
Iterate through all companies linked to the contact using contact.companies
. This is useful if a contact might be associated with multiple companies or if you need to display a complete list.
Comma-Separated List of Company Names
Display a simple comma-separated list of the names of all companies associated with the contact.
Contact’s Tags
Iterate through and display a contact’s tags.
Contact’s Segments
Iterate through and display the names of segments a contact belongs to.
Get Content from External URL
Fetch content from a URL, decode JSON, and process it as an array. Useful for dynamic content like abandoned cart details.
Content Segmentation based on Contact Affinity
Display different content based on a contact field value (e.g., affinity
).
Always Capitalize
Ensure text, like a contact’s first name, is capitalized.
Fetch RSS Data
Retrieve and display content from an RSS feed.
Expiry Date Calculation
Calculate the difference between a date field (e.g., date_last_order
) and the current date.
Time-Based Greetings
Display greetings based on the current time of day (server time).
Fallback Value
Provide a default value if a contact field is empty.
Magic with Dates
Manipulate and format dates.
Random Selection
Choose a random item from a list. Useful for varying greetings or calls to action.
Gender-Based Proper Greeting (German Example)
Customize greetings based on gender using a contact’s title field.
Personalize Content with JSON Decode
Process JSON stored in a contact field (e.g., cart_data
) to display personalized content like cart items or order details.
Support for Email Tokens in API
Use email tokens when sending emails via the API by passing them in the tokens
key of the payload. See the API Documentation for more details.