How to use Tokens

Tokens are representations of data. When a workflow runs, tokens are replaced with real data.

A simple example of this can be seen with a workflow that sends a text message to the customer when they place an order. In the image below, you can see that the phone number needs to be specified in the "To phone number" field.

In order to send the text message to the customer that placed the order, we need to use a token that represents the phone number for the order that triggered this workflow.

To insert a token, click on the  {+} button next to the field. This will open up the token selector sidebar. Here, you can view all of the tokens that are available from previous steps in your workflow.

If we search for "phone", quite a few results appear. This is due to how Shopify structures its data. Since we want to send a text message to the customer, we can select the first token.

After selecting the token, we can add a message and save the changes.

Now, when this workflow runs, the order that triggered it will determine the phone number to send the text to. For example, if we received an order from John Smith (123-456-7890), the workflow will send the text message to 123-456-7890.

Advanced usage

Using global store settings

Use the {{}} tokens to pull in settings from your Shopify store. Some common tokens:

  • {{}} Your store's "Store contact email", set in your Shopify Settings > General
  • {{}} Your store's url. Example: if you have a custom domain, if you have not configured a custom domain.
  • {{}} will always return your domain. Example:
  • {{}} Your store's name.  Example: My Store.

Formatting tags with Liquid

Tokens are parsed similarly to Shopify's Liquid syntax. This can be useful when you wish to manipulate data before it's processed.

In this example, we replace all tags that contain 'Spring Range' with 'Summer Range':

1. Select the token for the product tags

2. Double click on the token to edit it

3. Insert the replace filter to replace all tags that contain 'Spring Range' with 'Summer Range'

To learn more about Liquid syntax and its many functions, check out Shopify's Liquid documentation.

Dates and Times

You can get information about the current date and time by using the {{date:<format>}} token. For example, if the day of the week today is Tuesday, the token {{date:D}} will return "Tue". Full details and examples can be found in the Working with Dates doc.

Storage and Secrets

You can access storage items and secrets as tokens using the syntax {{storage:<key>}} or {{secret:<key>}} (note the colon here, instead of a dot). 

For example, if your workflow had a storage item called "domain", you can access it using the token {{storage:domain}}.