Email template variables and filters

Template variables

The email template uses the Liquid templating language. 

The email template has the following Liquid objects available:

  • product  - the product for the customer notification
  • variant  - the specific product variant the customer requested the notification for
  • shop  - your shop, including useful attributes such as shop.name  and shop.email
  • customer  - the customer the notification is being delivered to

Most of the popular Shopify Liquid filters have been made available for you to use in the customer email template. If you find a filter is missing please   contact support to see if it can be added.

If you're unfamiliar with Liquid templates take a look at  Shopify's Liquid introduction to learn the basics.

Shop

name

The name of shop.

email

The account owner email address for the shop.

address

The first line of the shop address.

city

The city for the shop address.

zip

The zip or postal code for the shop address.

country

The country for the shop address.

phone

The telephone number for the shop.

province

The state or province for the shop address.

owner

The name of the shop account owner.

domain

The domain name for the shop.

Product

id

Returns the product id used in the store catalog.

title

Returns the product title.

handle

Returns the handle used in the product page URL.

content

Returns the HTML content for the product description. Identical to product.description.

description

Returns the HTML content for the product description.

vendor

Return the product vendor.

type

Returns the type of product.

variants

Returns a list of variants for the product. See variants below for more information.

images

Returns a list of images for the product.

featured_image

Returns the featured image, or first image for the product.

tags

Returns a list of product tags.

price

Returns the price for the product.

options

Returns a list of option names for the product.

Variant

id

Returns the variant's unique catalog id.           

option1             

Returns the variant's first option.

option2             

Returns the variant's second option.

option3             

Returns the variant's third option.

price               

Returns the variant's price.

compare_at_price    

Returns the variant's compare at price.

weight              

Returns the variant's weight.

image

Returns the variant image if one has been set. Use the url property to include the image URL in your template.

{{ variant.image.url }}

To ensure an image is shown you can default to a product image if the variant image is blank:

{% assign featured_image = product.featured_image %}
{% if variant.image %}
  {% assign featured_image = variant.image %}
{% endif %}

<img src="{{ featured_image.url }}">
inventory_quantity

Returns the current inventory quantity for a variant.

sku

Returns the SKU for the variant.

title

Returns the variant title.

title_unless_default

Returns the variant title if set to something other than 'Default Title'. Otherwise it returns nothing.

This is useful when including a product and variant title, but you want to avoid single variant products being displayed as 'Default Title'.

/* Multi variant product, and variant title is 'Red' */
{{ product.title }} {{ variant.title_unless_default }} # Output: Shoes Red

/* Single variant product, and variant title is 'Default Title' so will be omitted */
{{ product.title }} {{ variant.title_unless_default }} # Output: Handbag
url

Returns a full URL to the product page, with the variant parameter and UTM parameters embedded. This is the easiest way to link to a product in your email template.

{{ variant.url}}
# Output: https://www.myshop.com/products/shoes?utm_source=back-in-stock&utm_medium=email&utm_campaign=stock-notification&utm_content=ProductTitle&bis_id=*|BISID|*&variant=665433569

If you would like to override the default UTM parameters you can construct a URL and include the analytics filter. See analytics filter below.

add_to_cart_url

Returns a URL that will take the customer to the checkout page with the variant added to the cart. This reduces the steps required for the customer to select a variant and click 'add to cart'.

{{ variant.add_to_cart_url }}
# Output: 
https://www.myshop.com/cart/12345678:1?utm_source=back-in-stock&utm_medium=email&utm_campaign=*|UTMCAMPAIGN|*&utm_content=*|UTMCONTENT|*&bis_id=*|BISID|*

For a URL that links to the cart page instead of the checkout page, use the liquid expression below.

http://{{shop.domain}}/cart/add/{{ variant.id | analytics}}

Customer

email

The email address for the customer receiving the Back in Stock notification.

unsubscribe_url

Link to unsubscribe customers from the notification / any registered notifications.

<a href="{{ customer.unsubscribe_url }}">Manage your notifications</a>
unsubscribe_all_url

Link to unsubscribe from all notifications (one click unsubscribe). Some email clients, like Yahoo and Google, require this link to be present in the email.

<a href="{{ customer.unsubscribe_all_url }}">Unsubscribe from all notifications</a>

Template Filters

The standard Liquid filters are available for use. You can find a list of these in the Liquid  Standard Filters documentation. The following filters are available in addition to the standard filters.

asset_url

Returns a URL for an file stored in the store's assets folder.

{{ 'logo.png' | asset_url }}
product_img_url

Takes a product image and returns a URL to that image. Accepts a Shopify image size name as a parameter.

{{ product.featured_image | product_img_url: "medium" }}

Available sizes are master, 2048x2048, 1024x1024, grande, large, medium, compact, small, thumb, icon, and pico.

analytics

Appends UTM parameters to a URL. This is normally used to construct a product URL.

http://{{shop.domain}}/products/{{ product.handle | analytics }}
# Output:
# http://acmestore.com/products/red-shoes?utm_source=back-in-stock&utm_medium=email&utm_campaign=stock-notification&utm_content=ProductTitle&bis_id=ABC

UTM parameters are useful for tracking click throughs and conversions in tools such as Google Analytics.

You can specify custom UTM parameters and still use the analytics filter. It will not override any existing parameters as long as you include the analytics filter last. 

For instance, to set a custom utm_campaign parameter:

http://{{shop.domain}}/products/{{ product.handle | append: '?utm_campaign=feb17' | analytics }}
# Output:
# http://acmestore.com/products/red-shoes?utm_source=back-in-stock&utm_medium=email&utm_campaign=feb17&utm_content=ProductTitle&bis_id=ABC

To change the default utm parameters it is necessary to change them manually (instead of use the analytics filter). For example, to replace utm_source=back-in-stock with utm_source=online-channel:

http://{{shop.domain}}/products/{{ product.handle | append: '?utm_source=online-channel&utm_medium=email&utm_campaign=*|UTMCAMPAIGN|*&utm_content=*|UTMCONTENT|*&bis_id=*|BISID|*' }}&variant={{ variant.id }}

Examples

Link to a product page instead of a variant

The default email template links to the product page using {{ variant.url }} . This builds a url with the variant= parameter in the URL to specify the specific variant.

If you would like to use a URL that simply links to the product page you can build one using the shop domain and product handle.
Add the following code to the top of the email template:
	{% capture product_url %}
	https://{{shop.domain}}/products/{{product.handle | analytics }}
	{% endcapture %}

This creates a variable called product_url with the required URL. You can then replace variant.url in the template with product_url .

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.