Email Booleans - How do you implement them?

Geoff_Krajeski1
Level 10 - Champion Alumni

Email Booleans - How do you implement them?

Anyone know how a boolean in email works or have an example, as in to toggle images/areas on & off?

Can you help with how they work? 

If I'm toggling an element in page shouldn't there be some correlating name/id?

The documentation is not 100% there on how you would actually do this.

http://docs.marketo.com/display/public/DOCS/Email+Template+Syntax

Tags (3)
12 REPLIES 12
Grégoire_Miche2
Level 10

Re: Email Booleans - How do you implement them?

Hi Geoffrey,

No much time to paste some code not, but usually, the boolean variable will in fact get the values "none" or "block" or whatever CSS value that makes sense.

Then in your code, you will have something in your code under the form of

<img style="display:${myBooleanVariable}">

BtW, hiding elements using booleans is acceptable in landing pages but not really recommended in emails. Because 1/ some email clients will not correctly interpret the CSS above and 2/ the image has to load even if it does not display, which is not good for deliverability or performance. It's much better to use modules instead, because these really add or remove the code for the email.

-Greg

Geoff_Krajeski1
Level 10 - Champion Alumni

Re: Email Booleans - How do you implement them?

What would be a better method to allow someone to turn a block "on" or "off" in a kind of master template in your opinion?

Is there another way to do this?

Grégoire_Miche2
Level 10

Re: Email Booleans - How do you implement them?

Hi Geoffrey,

The method proposed by Marketo is the module one (mktoModule). And it is pretty efficient. It enables to really add / remove / clone and move email blocks. If you need to remove a small sub-item, as you want the email code to remain as clean as possible, the best method is to create 2 modules in the email template: one with the email, another without. and the user chooses which one he prefers.

-Greg

Paul_Hughes
Level 2

Re: Email Booleans - How do you implement them?

I haven't seen this solution on the community page, but I use HTML comment tags to toggle large sections of code on / off with Email 2.0's boolean functionality:

At the top, I declare:

<meta class="mktoBoolean" id="showSection" mktoName="Show Section?" default="true" true_value="-->" false_value="" true_value_name="YES" false_value_name="NO" mktoModuleScope="true">

Then, I place comments around the section I want to toggle on/off:

<!-- Section Conditional Trigger ${showSection}

     [As much code as you want]

<!-- End Conditional -->

When the "Show Section" boolean is set to "true", the top conditional is closed, and the code is shown as normal. When the boolean is false, the top comment is left open. This causes the client to comment everything in the code out until the bottom comment, whose closing bracket prevents the entire rest of the document from being commented out. Comments are universally supported, so this doesn't run into any client issues (unlike trying to use display). And, since hidden images are commented out, the user's email client won't try to load it.

I have found this to work reasonably well, and other variables can be placed within the commented section.

Grégoire_Miche2
Level 10

Re: Email Booleans - How do you implement them?

Smart one. I like it!

-Greg

Anonymous
Not applicable

Re: Email Booleans - How do you implement them?

Hey! I really like this HTML comment idea.

It works great at hiding/showing but the only issue is that content wrapped in mktEditable are no longer editable.

Does anyone have an idea why this might be?

Paul_Hughes
Level 2

Re: Email Booleans - How do you implement them?

I ran into this myself. As far as I can tell, mktEditable divs cannot be shown / hidden with this method. I've worked around this by adding / removing modules (each with only one mktEditable div), rather than trying to use booleans within a module.

When trying to hide one, I have sometimes simply left a mktEditable blank by deleting all of the content within it. The Litmus tests I ran indicated that this didn't cause weird spacing problems. I definitely recommend testing this if you try it though. When it comes to email, you can never be too sure.

Grace_Brebner3
Level 10

Re: Email Booleans - How do you implement them?

This is a clever idea...

Remy_Frank1
Level 1

Re: Email Booleans - How do you implement them?

We really liked this idea, but some email clients/servers break (or don't honor) this boolean logic. We used boolean to toggle a CTA button on/off - but if someone forwarded that email, the CTA button randomly appeared on the forwarded email... 😕

We've experimented with adding a Marketo tag to alleviate the issue, but ultimately may go back to the idea of creating two hero modules - 1 with a CTA button, and 1 without a CTA button.