How to Add Rule-Based Images to SendGrid

Let one image slot in your SendGrid email show different creative per contact or per time of day, chosen by Sendtric when the email is opened.

One image slot in your SendGrid email, different creative for each audience.

Rule-based images let you upload several versions of an image and set rules for when each one shows. Sendtric checks the rules every time the email is opened and serves the first image that matches, so a SendGrid Single Send can show members a different banner from everyone else, or switch from a breakfast offer to a dinner offer during the day.

Sendtric's Rule-based Images editor with two images, their display conditions and a fallback image

In SendGrid you can already branch content with Handlebars, for example {{#if}} blocks in a template. Those choices are made when the email is sent. Rule-based images are decided when it is opened, which is what makes time and day rules possible, and they keep the logic out of your template code.

What you can do with rule-based images in SendGrid

  • Membership tiers: show a gold, silver or standard banner based on a tier custom field.
  • Regional creative: pick a store or destination photo from the contact's country or state_province_region field.
  • Opening-time offers: swap the hero image depending on the day of the week or the time someone opens the email (Standard plan and above).
  • Order status in transactional email: in a Dynamic Template, pass the status and show a matching "packed", "shipped" or "delivered" graphic.
Rule typeSendtric plan
Text matches on a SendGrid field, email client, operating systemAll plans
Fallback image when nothing matchesMicro and above
Date, day of week and time of dayStandard and above
Number comparisons and device typePower and above

Free accounts can use two images per widget, Micro four, Standard ten and Power unlimited. See pricing for the rest.

How to add rule-based images to SendGrid

Step 1: Upload your images in priority order

In Sendtric, open Rule-based Images, click Create New and use Add Image for each version. Sendtric checks images from top to bottom and stops at the first match, so add the most specific one first.

Step 2: Set the conditions

Click Update Conditions on each image card. For a field-based rule choose Merge Tag: Text, give the merge tag a name such as tier, and pick a match like equals "gold". Combine several conditions with AND or OR, then click Save. An image with no conditions is never shown.

The Show This Image window in Sendtric with the AND/OR choice and two conditions

Step 3: Copy the code and put in the SendGrid tag

Add a Fallback Image, click Save, then copy the code. Each merge tag rule appears in the URL as tier={{TIER}}. Replace the placeholder with your SendGrid tag, for example tier={{tier}} for a custom field, or the key you pass in dynamic_template_data.

The embed code for a Sendtric rule-based image with a merge tag parameter in the URL

Step 4: Add it to a Code module

In SendGrid's Design Editor, drag a Code module from the Build tab into place, paste the code into Edit Module HTML and click Update.

SendGrid's Design Editor with the Code module in the Build tab's Add Modules grid, next to an email preview showing a Sendtric rule-based image

Step 5: Simulate, then test

Use Sendtric's Preview to simulate a field value, a date or an email client and see which image wins. Then send a SendGrid test to contacts that should get different images.

Text rules ignore capitals

Merge Tag: Text conditions aren't case sensitive, so "Gold" and "gold" in your SendGrid field both match. Spelling still has to be exact, so check the values stored in the field before you write the rules.

Pass a time zone for time rules

Time and day rules use the time zone you pick. If your contacts are spread out, store a time zone such as America/New_York in a custom field and choose Dynamic Timezone so each contact's local time is used.

SendGrid Rule-Based Images FAQ

What happens when no rule matches?

Sendtric shows your Fallback Image. Without one, it shows an invisible 1 by 1 pixel image, so nothing appears in that spot.

Can I use Handlebars conditions instead?

You can, but they are evaluated at send time and need the logic in each template. Rule-based images decide on open and are managed in one place in Sendtric, which also allows time-of-day rules.

Can a countdown timer be one of the images?

Yes. When you add an image, the library also lists your timers, personalized images and weather widgets, so one rule can show a timer and another a static banner.

Do the rules work in SendGrid Automations?

Yes. The code is an ordinary image, so it works in Automations, Single Sends and Dynamic Templates.

Where can I read more about conditions?

Our help article on display conditions for rule-based images goes through each type.

This guide covers one piece of Sendtric's email personalization platform. For every rule-based images option and example, see the main page.

More SendGrid guides

Using a different platform? See all Sendtric integrations.

Martin Tenev

Martin is a Growth Manager who is enthusiastic about all things growth and AI including how to create email campaigns that convert.

Connect on LinkedIn

Ready to boost your email conversions?

Join thousands of marketers using Sendtric's Email Personalization Platform to drive conversions.