How to create interactive product images with AMP for Email

Up your e mail coding abilities with this action-by-step AMP for Email tutorial. Develop your own e mail that lets visitors improve the shades of a item impression.

In this this tutorial you will find out how to make an interactive e-commerce electronic mail concept. We’ll show a item with a number of colour possibilities. The reader will be able to push each and every colour and dynamically update the products image. Here’s what it looks like (see the whole code example):

An example of an interactive ecommerce AMP element in an email.
As found in Yahoo Mail inbox

Although it’s a somewhat simple instance, you will grow to be familiar with a handful of significant AMP for E mail elements these types of as:

  • amp-img an AMP alternative for the html5 img tag.
  • amp-selector a command for deciding upon 1 or much more solutions
  • amp-bind responds to person steps this sort of as hovers, clicks, sort submissions, etcetera.

To give you an concept of what else can be with these factors, here’s a extra refined example from Google. This provides the additional complexity of demonstrating different merchandise (the 1-pack, 2-pack, and 3-pack) and allows folks see people goods in diverse shades, but the theory of what you are going to find out underneath is the exact.

An example of AMP for Email that uses interactive images for different product packs.

Step 1 – Quick Commence with the AMP Playground

We will use the official AMP Playground for this tutorial. I’ve absent in advance and included some primary CSS for laying out our product or service picture and the shade selectors so you can target on mastering how the AMP parts operate.

Stop by this customized AMP Playground for a fast way to get began.

An example of the code that generates the AMP ecommerce email element
The AMP Playground, established up just for this tutorial. See code in AMP Playground

Action 2 – Include The Products Details

Code at stop of Step 2

Let’s start out laying out the message. We’ll start with the products tile, description (just colour in this situation), and the solution illustrations or photos. Include the adhering to within the .

45 Qt Hard Cooler

Colour Amber

Note, we’re using [text]=colorChoice. This is a hook that we can use afterwards on in the tutorial to update the solution description with the decided on shade. For illustration, when the consumer chooses “Blue”, the text will dynamically update from “COLOR Amber” to “COLOR Blue”.

Next let’s increase our initial products picture. Let us start out with our default shade, Amber.

The is contained inside a div with a very little little bit of logic, [hidden]="!(colorChoice == 'Amber') which implies that the Amber product or service image will only be found when the consumer selects the Amber shade.

Future, incorporate the remaining solution images, 1 for every shade. Every single of these will to begin with be hidden, as the Amber colour will be the default item variation.


An example of the AMP email code and the image is generates.
Setting the initial merchandise format. Look at code in AMP Playground

Stage 3 – Introducing the Shade Alternatives

It is ultimately time to increase a selector for just about every of the shade alternatives. We’ll use with the default, one-selection location so that they operate much like a radio button. And upon picking out a shade alternative, the amp-state will be up to date to reflect that color option. The adjust to amp-point out allows the rest of our document know to improve the product or service graphic and the coloration description. Include the next below the product particulars.

The has an celebration set off. When it is chosen, it updates the colorChoice variable. This variable is used to exhibit the proper merchandise picture and to update the shade description textual content in the solution facts.

on="pick: AMP.setState(colorChoice: event.targetOption)"

At this level, go ahead and check out deciding on each and every colour preference. You should really see your item details update accordingly.

What the code for the AMP email looks like later on in development
Introducing the products color selectors. View code in AMP Playground

Knowing How it Performs

Below is a summary of the primary ideas made use of in this case in point.

Shade Selectors: The shade selector, , has a “select” celebration. When the motion takes place, it updates the colorChoice variable in the course of the doc. ( is what associates an motion with 1 or a lot more updates to the document.)

on="select: AMP.setState(colorChoice: celebration.targetOption)"

Product Pictures: The products images have fundamental logic to disguise or demonstrate just about every graphic based on the worth of the colorChoice variable. Instance: concealed = Genuine when colorChoice is not equal to ‘Amber’.

[hidden]="!(colorChoice == 'Amber')"

Merchandise Description: The products description textual content also updates to the benefit of the colorChoice variable.


Clearly show us what you designed!

Next, I advocate sending by yourself a duplicate of the message you designed from this tutorial. Use an electronic mail assistance service provider that supports AMP for Electronic mail this sort of as AWeber or use the Gmail AMP Playground.

If you were being influenced by this write-up, I’d love to see what you created! Share in the reviews underneath or ship me an e-mail and question me to choose a appear.

Leave a Reply