Skip to content

Latest commit

 

History

History
153 lines (147 loc) · 5.37 KB

template-variables.mdx

File metadata and controls

153 lines (147 loc) · 5.37 KB
title description
Template Variables
How to use template variables to customize and supercharge your emails

import Layout from "../../components/Layout"; import { Code } from "../../components/Markdown"; import Table from "../../components/Table";

export const meta = { title: "Template Variables", description: "How to use template variables to customize and supercharge your emails", }; export default ({ children }) => {children};

Template Variables

Template variables are a concept that have multiple names: "mail merges" might be one you're more familiar with if you have a marketing and email background. The concept is to add snippets in your email that are programmatically replaced when Buttondown sends out an email; this allows you to customize your content per-subscriber or to repeat certain key concepts in your email without having to change them over and over again.

Template variable library

{p.variable}, }, { title: "Description", key: "description", }, { title: "Example", key: "example", component: (p) => {p.example}, }, ]} content={[ { variable: "subscriber.id", description: "The unique ID for a given subscriber", example: `Your subscriber ID is {{ subscriber.id }}.`, }, { variable: "subscriber.can_view_premium_content", description: "Whether or not a subscriber is able to view premium content", example: `{% if subscriber.can_view_premium_content %}Click here to check out the full version of the podcast!{% endif %}.`, }, { variable: "subscriber.metadata", description: "Access to the metadata for a given subscriber", example: `Hi there, {{ subscriber.metadata.first_name }}! You're looking dapper today.`, }, { variable: "subscriber.email", description: "Access to the email address for a given subscriber", example: "You signed up for this email via {{ subscriber.email }}.", }, { variable: "subscriber.can_be_upsold", description: "Whether or not a subscriber is able to be upsold to a paid subscription", example: `{% if subscriber.can_be_upsold %} Want to get even more content? Click [here]({{ subscriber.get_upgrade_url }})! {% endif %} `, }, { variable: "subscriber.subscriber_type", description: "Access to the subscriber type (premium, regular, etc) for a given subscriber", example: `{% if subscriber.subscriber_type == "premium" %} Thanks for your patronage! {% endif %} `, }, { variable: "subscriber.tags", description: "Access to the tag names of a given subscriber", example: `{% if "python" in subscriber.tags %} You know, I bet you're interested in Python! {% elif "html" in subscriber.tags %} You know, you strike me as a web developer. {% else %} I don't know what you're interested in! {% endif %}`, }, { variable: "email.subject", description: "The subject of the email you're sending out", example: `Today, we'll be discussing {{ email.subject }}.`, }, { variable: "unsubscribe_url", description: "A personalized URL for the given subscriber to unsubscribe with", example: `Not interested in this email? No worries — [unsubscribe here]({{ unsubscribe_url }}).`, }, { variable: "subscribe_url", description: "A generic URL for your subscription page", example: `Did someone forward you this email? If so, you can [subscribe here]({{ subscribe_url }}).`, }, { variable: "email_url", description: "The permalink of the email being sent out", example: "You can also view this email [online]({{ email_url }}).", }, { variable: "upgrade_url", description: "A link to prompt existing free subscribers to upgrade. (Only relevant for paid newsletters.)", example: "You can upgrade to a premium subscription [here]({{ upgrade_url }}).", }, { variable: "premium_subscribe_url", description: "A link to prompt existing free subscribers to upgrade. (Only relevant for paid newsletters.) This is the exact same thing as upgrade_url.", example: "You can upgrade to a premium subscription [here]({{ premium_subscribe_url }}).", }, { variable: "email.secondary_id", description: "The issue number of the email being sent out", example: "This is issue #{{ email.secondary_id }} of my newsletter!", }, { variable: "email.publish_date", description: "The raw date time of the email being sent out", example: "Sent on {{ email.publish_date }}.", }, { variable: "subscribe_form", description: "An embedded subscribe form for your newsletter, just like the one that appears at the bottom of your archives. Note that this only appears on the web/archive version of your email; it will not appear in the actual emails sent to subscribers.", example: "Want more sweet insights like these?\n\n{{ subscribe_form }}", }, { variable: "medium", description: "Either 'email' (for emails) or 'web' (for web views)", example: "You're reading this via {{ medium }}.", }, ]} />