Explode your opening rate on mobile thanks to the preheader

Ludovic

Member
Hey there ,

I received an email yesterday that caught my attention, I had never seen this trick and I find it really effective in making a campaign stand out.
But I'm not sure I understand how it's done and how to reproduce it with MailWizz.

I feel like it's a one-cell table in the preheader, is that plausible, is it possible?

Thank you for your attention
Ludovic

F392D0C1-887E-4FEB-9AE9-0C23F3AF7DBB.jpeg
 
MailWizz has a way to automatically insert a pre-header, which is a shortcut to add some html at the start of the email template, you can literally do the same on your own, by changing the html source of your email template.
 
Thanks for your reply, but i don't see right now how to achieve it, any documentation about this way to automatically insert a pre-header? Or maybe an snippet example?
 
There is a filter hook called 'console_command_send_campaigns_after_prepare_email' which can be used to hook in the campaign content right before sending.
So in apps/init-custom.php you could do:
PHP:
<?php

function customInjectPreheader(string $emailContent, string $preheader, Campaign $campaign): string {
    $hideCss      = 'display:none!important;mso-hide:all;';
    $style        = sprintf('<style type="text/css">span.preheader{%s}</style>', $hideCss);
    $emailContent = (string)str_ireplace('</head>', $style . '</head>', $emailContent);
    
    // this is your preheader template, only this should be modified
    // make sure you always have the two %s in the template.
    $preheader    = sprintf('
    <span class="preheader" style="%s">
        <table>
         <tr>
            <td>%s</td>
         </tr>
        </table>
    </span>
    ', $hideCss, $preheader);
    // end allowed modifications.
    
    $preheader    = (string)str_replace('$', '\$', $preheader);
    
    return (string)preg_replace('/<body([^>]+)?>/six', '$0' . $preheader, $emailContent);
}
    
    
hooks()->addFilter('console_command_send_campaigns_after_prepare_email', function(array $emailParams, Campaign $campaign, ListSubscriber $subscriber, DeliveryServer $server){
    $emailParams['body'] = customInjectPreheader($emailParams['body'], 'Your preheader here', $campaign);
    
    return $emailParams;
});
This is not tested, but hopefully you get the point.

Also, when using this, do not use the pre-header feature from the campaign.
 
Thanks for the code, and if I simply fill in the following HTML in the "Preheader" field would it work? Does the field accept HTML?
HTML:
<table style="width: 100%;"><tr><td style="height:10px; width:100%;background-color:#415A77;">&nbsp;</td></tr></table>
 
Well, it's a little dirty, but it does the job I think

Code:
◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️️️◼️️️ ♥︎‿♥︎ ◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️️◼️◼️◼️

( put directly in the preheader field)

IMG_9038.jpg
 
Back
Top