Let’s talk about one of Marketo’s best-kept secrets—custom variables! 🎉 If you’ve ever dreamed of making your email templates more dynamic and giving your team full control over elements like colors, fonts, or even specific sections of content, custom variables are here to save the day. 🦸♀️ But hold up! Before you dive into variable creation, it’s important to think strategically. What do you want the end user (aka your fellow marketers) to be able to edit in their email campaigns? Should a variable control a specific section (like a local module) or apply globally across the entire template? Answering these questions first will set you up for success and make your templates not just functional but super flexible.
Let’s dig into all the variable types, break down their use cases, and show you how they can level up your email game.
Approaching Custom Variables: Think Before You Code
Before you start creating custom variables, pause and consider how you want users to interact with your email template. Here are two key things to keep in mind:
Scope of the Variable
The scope of your variables is denoted by using the mktoModuleScope attribute which is a boolean value. Set to “true” if you want to limit a variable’s scope to the module level only and “false” if you want the variable to affect all modules in your template. If you don’t incorporate this attribute into your variable meta tag at all it defaults to “false”.
Local Variables: These are specific to a single module of your email template. They give the user control over one particular area without affecting the rest of the template. For example, you might want them to control the background color of a single content block.
<meta class="mktoColor" id="bg_color_black" mktoName="Background Color" default="#000000" mktoModuleScope="true" />
Global Variables: These are applied across the entire template and control elements like brand colors or fonts. They’re great for ensuring consistency, so if your company changes its branding, you can make one update and voilà—your whole template is updated! One example below is button radius - oftentimes you want to make sure all buttons in your email match and so this would be a great one to use as a global variable.
<meta class="mktoNumber" id="btn_radius" mktoName="Button Radius" default="50" min="0" max="50" units="px" step="1" />
What the End User Should Control:
Design Elements: Think about colors, fonts, and spacing. These are elements you might want the user to tweak to match specific campaigns.
Content Elements: Variables can control things like headings, buttons, or product images. Define what content blocks your team will need to edit frequently, and set up variables that make it a breeze to customize.
Types of Custom Variables in Marketo
Now that you’ve thought through the scope and purpose, let’s break down the different types of variables you can use in Marketo email templates. Each type has its own special use case, and combining them will give your templates that extra boost of flexibility.
Color Variables | class="mktoColor"
What They Are: Color variables are custom variables that allow users to easily adjust colors across a template. Instead of hardcoding a color value, you define a variable to let the user select the color they need.
Example:<meta class="mktoColor" id="body_text_color_black" mktoName="Text Color" default="#000000" mktoModuleScope="true" />
In this example, body_text_color_black is a variable that controls the text color of text elements within the email. Users can update this without touching the code.
How to Use:
Color variables are great for letting your marketing team change things like button colors, headers, and background sections based on campaign themes or brand guidelines.<p class="mktoText" mktoName="Text" id="footerTxt1" style="color: ${body_text_color_black};”>Body Text</p>
Pro Tip: Define a color palette for your team to ensure brand consistency and make their choices easier.String Variables | class="mktoString"
What They Are: Text variables allow you to create editable content that your team can change without needing to touch the code. This could be anything from token values to button labels.
Example:<meta class="mktoString" id="btn_url" mktoName="Button Url" default="#" mktoModuleScope="true" />
In this case, button_url is a variable that controls the link for a button. Users can easily update it in the editor.
How to Use:
Use string variables for things like calls to action (CTA), tokens, or text. They’re a great way to empower users to tweak text or links without messing with the template’s structure.
Pro Tip: Always provide default values that make sense in your template, so even if the user forgets to edit them, the email still works.Image Variables | class=”mktoImg”
What They Are: Image variables let your users swap out images easily, such as product photos, logos, or banners, without having to go into the code. This makes it simple to adapt the template for different campaigns.
Example:<meta class="mktoImg" id="header_logo_light" mktoname="Header Logo - Light Mode" default="https://firebasestorage.googleapis.com/v0/b/marketo-template-customizer.appspot.com/o/EmailVariant-color-logo.png?alt=media&token=8174fcbf-fc21-4a92-9ec0-9c92043d5af3" />
The header_logo_light variable holds the URL for the image. If the user wants to change the image, they can select from the image picker in Marketo.
How to Use:
Perfect for logos, product images, and other visuals that change from campaign to campaign. Your team can easily update the image by simply pasting a new URL, no HTML knowledge required.<img class="mktoImg light-img" mktoName="Logo" id="logo" src="${header_logo_light}" alt="Logo" width="${header_logo_width}" style="border: 0; height: auto; width: ${header_logo_width}px; line-height: 100%; outline: none; text-decoration: none; display: inline-block;" border="0">
Pro Tip: Make sure the images are responsive and optimized for both desktop and mobile to avoid any formatting issues.Boolean (True/False) Variables | class=”mktoBoolean”
What They Are: Boolean variables let you toggle sections of content on or off. They’re ideal for situations where you might want to show or hide certain content blocks depending on the campaign or audience.
Example:<meta class="mktoBoolean" id="link_text_decoration" mktoName="Underline Link Text?" default="false" false_value="none" true_value="underline" false_value_name="No" true_value_name="Yes" />
In this case, link_text_decoration controls whether a text links throughout the email should be underlined or not. If set to false, text links will not be underlined and the default is set to "false".
How to Use:
Great for use in global variables where you want to turn styles on or off across an email. The user can decide whether to show or hide these elements with a simple true/false option.
Pro Tip: Keep things simple for your users by adding clear labels and instructions in your documentation or template editor, so they know what each toggle does.List Variables | class=”mktoList”
What They Are: List variables allow users to choose from a predefined set of options, making them perfect for controlling repeated patterns, like alignment choices or pre-set color schemes.
Example:<meta class="mktoList" id="horizontal_align" mktoName="Horizontal Align" values="center,left,right" mktoModuleScope="true" />
In this example, horizontal_align, offers three predefined horizontal alignment choices. The user can select the desired option from the list, ensuring consistency and easy customization.
How to Use:
Use list variables for things like alignment, font-weights, or font-families. This lets users select from predefined lists that are inline with company brand guidelines.
Pro Tip: Define clear options within the list and label them in a way that is easy for users to understand.Number Variables | class=”mktoNumber)”
What They Are: Number variables allow you to define numerical values that can be used for things like spacing, font sizes, or even percentages for layouts. They are incredibly helpful for fine-tuning the design elements of your email.
Example:<meta class="mktoNumber" id="body_font_size" mktoName="Paragraph Font Size" default="14" min="1" max="50" units="px" step="1" mktoModuleScope="true" />
In this case, body_font_size sets the font size of paragraph text within the template, giving the user flexibility in adjusting font sizing without touching the code.
How to Use:
Number variables work well for controlling spacing, line heights, or even percentage-based widths for responsive design. Your team can tweak these values to ensure the layout looks perfect without diving into the code.
Pro Tip: Combine number variables with other types like color or text to create a robust design control system in your email template.HTML Block Variables | class= “mktoHTML”
What They Are: HTML block variables allow you to insert editable HTML code snippets into your template. This is perfect for cases where you want to give users advanced control over specific sections without exposing the entire template structure.
Example:<meta class="mktoHTML" id="trackingPixel" mktoName="Add Tracking Pixel">
This allows users to input custom HTML content into a designated area of the email, making it flexible for more advanced content needs.
How to Use:
Letting end users insert html blocks into the email can be a risky move if the end user isn’t familiar with the email template html itself but it can be helpful in inserting tracking pixels or other data from third party tools into your email.
Pro Tip: While HTML block variables offer flexibility, ensure your users know basic HTML before allowing them to use this variable type to avoid broken layouts.
Best Practices for Custom Variables
Now that you’ve got a handle on the types of custom variables, here are a few tips to make the most of them:
Naming Conventions: Always use clear and descriptive names for your variables. For example, buttonColor is much better than something vague like color1. This makes it easier for your team to understand what each variable controls.
Use Defaults: Always set default values for your variables. This ensures that even if someone forgets to customize a variable, the email will still render properly with a fallback value.
Test Your Templates: Before rolling out templates to the broader team, test them thoroughly! Check how your variables behave in different scenarios, and make sure they render correctly across email clients.
Document Your Variables: Provide your users with a guide to the variables you’ve created. This will help them understand what each variable controls and how to use them effectively.
Ideas for Using Custom Variables
Need some inspiration on how to use custom variables? Here are a few creative ways to incorporate them into your templates:
Theme Your Emails: Use global color and text variables to easily switch between campaign themes (like seasonal promotions or product launches) without having to rebuild the entire template.
Personalized CTAs: Use text variables to let your team personalize CTAs for different audience segments. For example, "Sign Up" for one group, and "Get Your Free Trial" for another.
Dynamic Sections: Use boolean variables to toggle special content blocks on or off depending on the campaign. Maybe it’s a limited-time offer or a special holiday greeting!
Wrapping Up
Custom variables in Marketo email templates give you the power to create highly dynamic, flexible, and user-friendly templates. Whether you’re tweaking a color, swapping out images, or controlling entire sections of content, variables make it easy to hand the keys over to your marketing team without losing control of the design. So, go ahead and play around with them—you’ll be amazed at how much more powerful your email templates can be! ✨
Happy templating! 🎨📧