One of the exciting features we’ve introduced alongside the release of these templates is the Variant Selector. What this new feature does is actually pretty simple: it lets you switch between any number of different content structures (blocks of HTML) within your email. So, the explanation is straightforward, but if you’re a designer the practical implications of this feature are actually pretty huge.
First, let’s take a look at the new Basic Variable template:

The layout is deceptively simple, with a big upper content area and a lower area with a left-side image and right-side text. Hover over that lower area, however, and you’ll see that it’s repeatable and has a new control attached to it – that’s the Variant Selector.

This template has a left-image module and a right-image module that can be selected via the drop-down menu, then repeated and selected again. In this particular template, this allows you to create a “ping-pong” layout, where each image-and-text module mirrors the previous.

This is a neat use, and ultimately a pretty simple one, but like a lot of our features there’s quite a bit of power in that simplicity. An interesting use case for this? Maybe you’re an agency, or a freelance web designer building templates for others, and you find that your client wants to switch between two different templates each month, alternating the layout of the email they use to send your campaign content. By using the Variant Selector code, you can combine the two template layouts into one, then your client just selects which layout they’d like to send out. After that, they can continue on as if it’s a normal template. Easy for them, which is great, and a little less work for you to achieve your client’s goal.
So that’s the basic stuff covered. Let’s get our hands dirty with the code that lets this feature work. Those uncomfortable with HTML should look away… now.
First, here’s the unadulterated code for each of the modules in the Basic Variable template:
<!-- // Begin Module: Left Image with Content \\ -->
<table border="0" cellpadding="20" cellspacing="0" width="100%"
mc:repeatable="siwc_600" mc:variant="content with left image">
<tr>
<td align="center" valign="top">
<img src="http://gallery.mailchimp.com/
653153ae841fd11de66ad181a/images/placeholder_260.gif"
style="max-width:250px;" mc:label="image"
mc:edit="liwc600_image00" />
</td>
<td valign="top">
<div mc:edit="liwc600_content00">
<h4>Heading 4</h4>
<strong>Variable content blocks:</strong>
<a href="http://blog.mailchimp.com/kb/article/how-
do-i-work-with-repeatable-content-blocks" target="_blank">
Variable content sections</a> are noted with plus and
minus signs so that you can add and subtract content blocks
and also a drop-down selector that allows you to choose which
type of content block to display.
</div>
</td>
</tr>
</table>
<!-- // End Module: Left Image with Content \\ -->
<!-- // Begin Module: Right Image with Content \\ -->
<table border="0" cellpadding="20" cellspacing="0" width="100%"
mc:repeatable="siwc_600" mc:variant="content with right image">
<tr>
<td valign="top">
<div mc:edit="riwc600_content00">
<h4>Heading 4</h4>
<strong>Variable content blocks:</strong>
<a href="http://blog.mailchimp.com/kb/article/how-
do-i-work-with-repeatable-content-blocks" target="_blank">
Variable content sections</a> are noted with plus and
minus signs so that you can add and subtract content blocks
and also a drop-down selector that allows you to choose which
type of content block to display.
</div>
</td>
<td align="center" valign="top">
<img src="http://gallery.mailchimp.com/
653153ae841fd11de66ad181a/images/placeholder_260.gif"
style="max-width:250px;" mc:label="image"
mc:edit="riwc600_image00" />
</td>
</tr>
</table>
<!-- // End Module: Right Image with Content \\ -->
Each module is coded as its own HTML table, and they’re identical save for the order of the table cells that hold the image and text. In the first table’s opening HTML tag, you’ll see two attributes from our template language: mc:repeatable and mc:variant:
mc:repeatable="siwc_600" mc:variant="content with left image"
The mc:repeatable tag is familiar, save for one detail: it’s taking a name (in this case, siwc_600). That’s an important difference between a normal mc:repeatable tag, where no name is required. The app uses this name to track the repeated variant, so it’s very important that the name be included and that it be identical on the two items you want to alternate between.
The next tag is mc:variant, which is brand-new. You’ll see that it’s also taking a name; “content with left image” in the top module, “content with right image” on the bottom one. This tag sets the text that shows on the Variant Selector drop-down menu:

That’s all you need to get the Variant Selector working – the use of those two tags. There’s one more important detail: the tagged objects you wish to toggle between must be adjacent to each other in the template’s HTML. Here’s a simplified example:
<table> <tr> <td> <div mc:repeatable="catsdogsbirdsfish" mc:variant="meow meow meow!"> <h1>Meow!</h1> Cats are the best! </div> <div mc:repeatable="catsdogsbirdsfish" mc:variant="woof woof woof!"> <h1>Woof!</h1> Dogs are the best! </div> <div mc:repeatable="catsdogsbirdsfish" mc:variant="tweet tweet tweet!"> <h1>Tweet!</h1> Birds are the best! </div> <div mc:repeatable="catsdogsbirdsfish" mc:variant="glub glub glub!"> <h1>Glub?</h1> I don't know what sounds fish make, but they are the best! </div> </td> </tr> </table>
Since the four divs are adjacent to each other and are correctly tagged up, they’ll be pulled as selectable variants within the app. Just keep in mind that the Variant Selectors you set up in “My Templates” will only be applicable within a campaign, since variants are content-specific tools.You can use the Variant Selectors on pretty much any number of chunks of code: we haven’t placed any limits on the number of variants you can set so, theoretically, you can do this to infinity+1*. That’s a pretty powerful proposition (alliteration bonus!).
*We’d rather you didn’t.
[...] a “variant selector” to the template language, which allows you to swap between different types of content blocks as you [...]
Just a friendly reminder (don’t you hate that saying?)…don’t forget to update your “Handy Email Template Resources—HTML Editor Plugins”
http://blog.mailchimp.com/resources/email-template-language/
I can’t really get it to work, even using the code supplied (and the template).
What doesn’t seem to work is both hiding the main field of a variant and changing variants, as the change selection box doesn’t even appear.
Hi Jesper. When using Variant Selectors, you can set the code up in ‘My Templates’ as you generally would when creating custom templates, but the full functionality is available only when you’re creating a campaign. It sounds to me like you’re trying to set the variants outside of a campaign?
That was a judgment call on our part, thinking that there would be no need to have variants fully selectable outside of campaign creation, since templates themselves should not be content-dependent as opposed to campaigns, which are not only content-dependent but also where on-the-fly layout decisions (as allowed by the Variant Selector) should be made.
I could be misinterpreting your issue. If that’s the case, feel free to drop another comment here or email me at templates [at] mailchimp.com.
Is anyone else having issues with the variant selector? It does not appear in any of the templates I try. I am working in the forever free plan…is it possible the variant selector only appears in paid plans?
No, it’s not limited to paid. Contact support to see if there’s a problem with the code anywhere. One of the most common issues is when people copy-paste content from Microsoft Word, or from a web page, then “stray code” gets imported behind the scene. Some stray code can interfere with our templates. We’d need to look into the template you’re having issues with.
Hi, I too am having trouble with the variant selector. It doesn’t even appear as a drop down when editing templates. Would be a very useful tool if it worked…
For me, it actually worked when I got into the campaign editor. When I was testing in the My Templates area, in the Design section, it only worked a little bit, but when setting up a Campaign, it works like a charm…
Hi team,
I got a bit cheeky and tried to take the image out of the table, making it a right or left aligned image that would be nested within the written content. I moved the image, gave it the requisite ‘align=”left/right” ‘ attribute and deleted the table cell around it. However, it didn’t work properly. Example below.
Heading 4
Variable content blocks: Variable content sections are noted with plus and minus signs so that you can add and subtract content blocks and also a drop-down selector that allows you to choose which type of content block to display.
Don’t know if this is possible to make work.
Oops pasting that code didn’t really work…
Hi Robert. What exactly are you trying to achieve? Just the removal of the image itself? If so, you don’t even really have to mess with the code – you can do that within the campaign by just clicking “remove image”. At that point, you can then place your image in the content area.
If I’m misinterpreting, shoot me an email: templates [at] mailchimp.com.
Hi Fabio.
I have question for you regarding variant.
I would like to have a variant section for social.
I have defined different divs, one for each social (facebook, twitter, etc.), and I would like to have a template that give me the option to add the social I want (i.e. only facebook or facebook plus twitter, or facebook like plus twitter).
It works fine with the table example above, but I would like to have the optional sections added on the same row (the example above adds section in column, one down the previous, I would like to add on the right of the previous): any suggestions?
BR
Roberto
Hey Roberto,
An easy way to do what you’re looking for is to set the <td> elements of your table to be the variants. You’ll want to use a nested table so that the different numbers of <td> elements won’t interfere with your email’s main content sections.
You could do something like this, for example:
<table> <tr> <td> This is my email's content. </td> </tr> <tr> <td> <table> <tr> <td mc:repeatable="socialblock" mc:variant="twitter layout"> This is my twitter link. </td> <td mc:repeatable="socialblock" mc:variant="facebook layout"> This is my facebook link. </td> <td mc:repeatable="socialblock" mc:variant="combo layout"> This is my twitter link and this is my facebook link. </td> </tr> </table> </td> </tr> </table>By setting the <td> elements as the variants, you satisfy the variant selector requirement of using adjacent elements in your code and they’ll also show up in the same row.
I hope this helps. Drop me a line at templates [at] mailchimp.com if you need any more help.
hi i want to use repeatable tag with in repeatable block like mc:repeatable one block and inner have html with in mc:repeatable
is it possible …or any example ??
I am new to the Variant and struggled to get it to work until I viewed it in the campaign view. It didn’t work in the template view but worked in the campaign view. I hope this is a feature that will be added.
Thanks for the blog Fabio the variant tag has opened up so many more options for me.
When I save my “basic (variable)” email campaign as a template half the content is lost – all the blocks that had the image on the right or no image at all.
I wanted to save it as a template not just for future use but also so I could get in to the code and insert some graphic lines between the blocks.
So, how do I take an email campaign and get it into code view so i can tweak it manually?
I guess I really want to edit the way a block shows so it can have a horizontal rule between each one.
It would also be really really handy to be able to re-order the blocks.
Any help appreciated thanks.
Hi Lauren,
A nice, quick way to grab Start-From-Scratch template code is to visit our Email Blueprint repository on Github. Specifically, the variant template code is located here.
I’m building a mailer from scratch using the 1:2 columns:3 columns template. I’ve created another row of the “:3 columns” beneath the original.
How do I lock in a fixed horizontal alignment for my columns? I’d like the template to treat the my various content blocks as fixed rows — that way, when the leftmost block has more content than the block to its right, it doesn’t effect the horizontal alignment of the row beneath it.
Is it possible to create repatable table rows with variant tr contents?
I have a news letter style which is
And the client keeps changing their mind regarding which order they would like the tr’s in,
ie, tr with 3td, top then change mind next month to tr with 2td top etc . . .
Since i can’t seem to find reference to “moveable” sections (ie drag and drop re-ordering) i thought i might be able to create variant tr types but this does not seem to work or i have coded it wrong.
I have noticed all examples of variant that i have seen have been on td’s rather than tr’s so was more wondering if and how it was achievable on tr’s.
Kenn
the above post ripped out my structure, will attempt a different approach to listing the structure:
table
tr mc:repeatable=”Section” mc:variant=”one”
td
/ td
/ tr
tr mc:repeatable=”Section” mc:variant=”two”
td
/ td
td
/ td
/ tr
tr mc:repeatable=”Section” mc:variant=”three”
td
/ td
td
/ td
td
/ td
/ tr
tr mc:repeatable=”Section” mc:variant=”four”
td
/ td
td
/ td
td
/ td
td
/ td
/ tr
tr mc:repeatable=”Section” mc:variant=”five”
td
div
/ div
/ td
/ tr
/ table
Kenn
We haven’t tried to put variants into TR but suspect it would be very hard to maintain the integrity of the TD’s. We have only used it to repeat/variant of entire tables. All of this is nested in a second table. The tables act as a tr and can be styled according to your needs.
I know there is a lot of nesting but in my experience the best way to handle complex email designs is to nest tables. We presently have a three option variant working on a couple of our templates in this manner, but am sure you could push it to five.
Table
TR
TD
Table variant one
TR
TD /TD
/TR
/table
Table variant two
TR
TD /TD
/TR
/table
/TD
/TR
/table
Hello Chris,
Thank you for your reply, i have defaulted back to the div’s and table variant for the email template. I managed to get it working the normal way that you recommend.
It was difficult to get my head around the fact that i had to do each variant as a table and it was a bit stressful when i had made the template and began using it in a test campaign, because of the div’s in design and build mode it creates massive gaps between each repeated section, but when sending and in the pop-up view it closes the gaps so its absolutly fine now and works amazingly well.
Mailchimp is impressive software its just a case of sitting down and getting your head around a few things, and sometimes having to think about the new stuff in a new way rather than the methods i was stuck in from other email clients and applying that thought to your new functionality.
Anyway congratualtions on a very good product.
Kenn
In our weekly newsletter we have blocks of code for each new product, there are several different variations of these code blocks. I am trying to set up a template which has all the code blocks, so we can simply select one and it will be inserted into the newsletter, however many times we need that block of code. The problem(s) I am running into is figuring out how to have the area where the blocks of code will be inserted into remain blank, until we insert one of the code blocks? Is this possible?
A nice feature, but really I miss the option to move elements e.g. via drag & drop.
I agree. Is there a way to do a drag-n-drop with variant selectors?
I tried to use this to give my template a choice of three different call to action buttons at the bottom of the email. I had one tag and in it I stuck three tags. Each div contained a button variation and an mc:edit. Everything worked until you used the template and repeated two buttons of the same type. You would edit the first button as you wanted but when you went to edit the second, the editor would be filled with the content from the first button. The content of the two were linked – not good. :-(
The solution (if you’re having the same issue) was not to put the repeatable sections as divs in the same . I went back up the structure to the tag. I needed to create three separate table rows, instead of three separate divs in one cell.
In the tag, I put my mc:repeatable and mc:variant. Then I made sure that the only contained ONE of the button variants. Then I created another after the first. Put the repeatable part in there and created a to hold the SECOND button variant. And so on…
Hope that’s useful.
Drag & Drop for moving elements would be very great!
I had spent some time with the selectors to notice, that it won’t work with but only with .
Redesigned my table layout and now everything is fine!
Hi, thank you for this feature. But when I put a mc:repeatable mc:variant element inside a mc:repeatable element, I get empty Elements if a repeat a Element from the outer loop.
What could i do?
Exmalpe Code:
table mc:repeatable
tr
td
table mc:repeatable=”contentElement” mc:variant=”Bild links Text rechts”
…
table mc:repeatable=”contentElement” mc:variant=”Bild rechts Text links”
…
/td
/tr
/table
In the “Edit Template” Mode I can repeat only the outer elements.
If I in the campaign mode I can only repeat the inner elements.
If I repeat the outer elements in the campaign mode I get empty elements!
Hey Benedikt – is there a reason you’re nesting repeatable elements within a repeatable element? That’s something I’d recommend you avoid, if possible. You should simply repeat the variant tables themselves instead of repeating the table that contains those tables.
Yes, I have repeatable boxes (tables) with shadow around it and a title.
Inside these boxes I want to place 6 types of content elements (variants). Text left, img right, only text and so on…
I don’t know how many content elements have to be inside a box with shadow.
So, what should I do?
I’ve been working on a template were I use mc:repeatable, but when I try to drag and drop the repeatable blocks over or under each other, nothing happens. I don’t see a yellow indicator as suggested in the documentation. I put the template on gist: https://gist.github.com/3760320 . If anyone can please help, I’d really appreciate it.
Hi Fabio
I am trying to centralised my two column one left & other one on right. They both appear at present on leftside.i am using template basic1:2 columns which has images & description.Please guide me how to do this.
I’m not completely sure where you’re having a problem. Could you possibly provide some more details or explanation for me? Also, our support chimps at http://mailchimp.com/support would be able to chat through any issues you might be having.