Up your e mail coding abilities with this phase-by-action AMP for Electronic mail tutorial. Produce your personal e mail that allows audience adjust the shades of a item picture.

In this this tutorial you will master how to build an interactive e-commerce email message. We’ll screen a merchandise with several color choices. The reader will be in a position to press every colour and dynamically update the merchandise impression. Here’s what it seems like (see the whole code illustration):

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

Even though it is a rather simple instance, you will develop into acquainted with a several vital AMP for E-mail factors these types of as:

  • amp-img an AMP replacement for the html5 img tag.
  • amp-selector a command for choosing 1 or a lot more selections
  • amp-bind responds to person steps such as hovers, clicks, type submissions, and many others.

To give you an strategy of what else can be with these components, here’s a much more advanced illustration from Google. This provides the additional complexity of demonstrating unique products and solutions (the 1-pack, 2-pack, and 3-pack) and allows people today see those people merchandise in unique colours, but the theory of what you’ll study under is the exact same.

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

Move 1 – Swift Begin with the AMP Playground

We will use the formal AMP Playground for this tutorial. I have absent forward and incorporated some simple CSS for laying out our solution image and the colour selectors so you can emphasis on finding out how the AMP parts do the job.

Go to this customized AMP Playground for a brief way to get begun.

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

Step 2 – Add The Product Particulars

Code at close of Action 2

Let’s get started laying out the information. We’ll start off with the product or service tile, description (just colour in this case), and the solution photos. Incorporate the following inside the .

45 Qt Tough Cooler

Coloration Amber

Observe, we’re working with [text]=colorChoice. This is a hook that we can use afterwards on in the tutorial to update the merchandise description with the picked out color. For case in point, when the consumer chooses “Blue”, the textual content will dynamically update from “COLOR Amber” to “COLOR Blue”.

Following let us insert our initially product or service picture. Let’s begin with our default shade, Amber.

The is contained in just a div with a little little bit of logic, [hidden]="!(colorChoice == 'Amber') which means that the Amber solution picture will only be found when the consumer selects the Amber shade.

Up coming, increase the remaining products illustrations or photos, 1 for just about every shade. Just about every of these will originally be hidden, as the Amber shade will be the default products variation.


An example of the AMP email code and the image is generates.
Location the preliminary products layout. See code in AMP Playground

Move 3 – Introducing the Shade Decisions

It’s lastly time to incorporate a selector for each of the shade solutions. We’ll use with the default, single-option environment so that they function substantially like a radio button. And upon picking out a colour option, the amp-condition will be updated to replicate that colour selection. The improve to amp-point out allows the relaxation of our document know to alter the item image and the colour description. Incorporate the next below the merchandise details.

The has an occasion trigger. When it is chosen, it updates the colorChoice variable. This variable is made use of to display the suitable product image and to update the shade description textual content in the product specifics.

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

At this place, go ahead and attempt choosing every single color option. You should really see your product or service facts update appropriately.

What the code for the AMP email looks like later on in development
Adding the solution color selectors. Perspective code in AMP Playground

Knowledge How it Functions

In this article is a summary of the essential principles employed in this example.

Shade Selectors: The shade selector, , has a “select” event. When the action takes place, it updates the colorChoice variable through the doc. ( is what associates an action with 1 or much more updates to the doc.)

on="find: AMP.setState(colorChoice: occasion.targetOption)"

Merchandise Images: The products photos have standard logic to disguise or show each and every image based on the value of the colorChoice variable. Example: concealed = Real when colorChoice is not equal to ‘Amber’.

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

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


Clearly show us what you produced!

Future, I recommend sending yourself a duplicate of the information you designed from this tutorial. Use an e-mail service supplier that supports AMP for Email these kinds of as AWeber or use the Gmail AMP Playground.

If you were being influenced by this write-up, I’d really like to see what you created! Share in the reviews under or deliver me an e-mail and check with me to take a look.

Leave a Reply