How to set up back in stock notifications for Shopify
Overview
Set up back in stock notifications for your Shopify store to send Contacts email when your products are back in stock! Read on to learn how to install the back in stock button and set up related automations.
In this guide
- Create a subscribed to back in stock automation
- Create a product back in stock automation
- Install the back in stock script
- Turn on back in stock automations
- Troubleshooting
🚦 Before Getting Started
- Set up your Shopify integration
- Install Beacon general tracking
- 1
-
This Automation will send an email to Contacts confirming their subscription to back in stock notifications. Create an Automation using the Subscribed to Back in Stock trigger. Add an email node with a message that confirms Contacts' subscription to notifications.
Create a subscribed to back in stock automation
- 2
-
This Automation will send an email to Contacts when the product they are interested in is back in stock!
Create an Automation and select the Product Back in Stock trigger from the Shopify tab. In the Units field, enter the number of units that should be in stock before the Automation sends out back in stock notifications.
Add an email node with a message that informs Contacts that the product they want is back in stock! Use the In Stock block to display the product's photo, price, reviews (if Sendlane Reviews is installed), and a link to purchase:
Add a Goal node that checks for purchases, and your finished Automation should look something like this:
Create a product back in stock automation
- 3
-
The script below will attempt to automatically pull your Shopify store’s styling if you are using a standard Shopify theme. If your button doesn't look like the rest of your store after installation, check out the Style Options section below for a script that provides more granular control of your button's design, and review the Troubleshooting section to see specific suggestions for known design fixes.
<script src="https://sendlane.com/scripts/sendlane-backinstock-widget.lib.js"></script> <script> SendlaneBackInStock.configure({ account: { token: "PUBLIC_TOKEN", platform: "shopify", }, settings: { cta_button: { text: "Notify me when available", product_page_form_element_selector: ".product-form", }, modal: { headline: "Get notified when this product is back in stock.", email_field_label: "Email", button_label: "Notify me when available", success_message: "We will notify you when it becomes available", disable_phone_field: true, } } }) </script>
Before logging into Shopify, add your Shopify integration token to the script so it's ready to paste in your store. Copy the script to a text editor, then replace the
PUBLIC_TOKEN
with the token in your Shopify integration's settingsTo install the script:
- Log in to your Shopify account
- Click Online Store
- Click Themes
- Click the Three dot menu
- Click Edit code
- Search for the theme.liquid file
- Click into the theme.liquid file
- Press
CMD
+F
to open the search function - Type
</body>
in the search field - Paste the snippet just before the
</body>
tag
Install the back in stock script
- 4
-
Now that your script is successfully installed, it's time to activate your automations!
Turn on back in stock automations
Style Options
The following script provides more granular control over the appearance and settings for the back in stock notification form and button appearing on product pages when a product is out of stock. This script can be used in place of the simplified script in step 3.
Replace PUBLIC_TOKEN
in the script below with the token in your Shopify integration's settings
<script src="https://sendlane.com/scripts/sendlane-backinstock-widget.lib.js"></script> <script> SendlaneBackInStock.configure({ account: { token: "PUBLIC_TOKEN", platform: "shopify", }, settings: { cta_button: { text: "Notify me when available", background_color: "black", text_color: "white", margin: "0.5rem 0", padding: "10px", width: "100%", product_page_button_class: "btn", product_page_form_element_selector: ".product-form", font_family: "Arial" }, modal: { headline: "Get notified when this product is back in stock.", email_field_label: "Email", button_label: "Notify me when available", success_message: "We will notify you when it becomes available", drop_background_color: "rgba(0,0,0,0.4)", background_color: "#fff", text_color: "#222", font_family: "Arial", disable_phone_field: true, button_text_color: "#ffffff", button_background_color: "#006fbb", close_button_color: "#ccc", error_background_color: "#fcd6d7", error_text_color: "#c72e2f", success_background_color: "#d3efcd", success_text_color: "#1B9500" } } }) </script>
Button Settings
settings.trigger.text
- Text displayed on button when an item goes out of stock.settings.trigger.background_color
- Button background colorsettings.trigger.text_color
- The text color of the buttonsettings.trigger.margin
- Margin around the button (defaults to '0.5rem 0' or 8px)settings.trigger.padding
- Padding around the buttonsettings.trigger.width
- Override of the button width (defaults to 100%)settings.trigger.product_page_use_button_classes
- Enabling this feature will attempt to use existing buttons' width in the product form element on the product page. While enabled,settings.trigger.product_page_button_class
will be ignored.settings.trigger.product_page_form_element_selector
- Enabling this feature overrides the widget's location for the back in stock notification button on the page (defaults to .product-form)
Subscription Form Settings
settings.modal.headline
- Headline that appears at the top of the form; (defaults to product name)settings.modal.email_field_label
- Email field label (defaults to 'Email')settings.modal.button_label
- Text within the submit button (defaults to 'Notify Me')settings.modal.success_message
- Message that appears when form is submitted (defaults to '"You're in! We'll let you know when it's back"')settings.modal.drop_background_color
- Drop background color that appears when the form is open (defaults to 'rgba(0,0,0,0.4)')settings.modal.background_color
- Background color of the form (defaults to white)settings.modal.text_color
- Text color of the popup form (defaults to black)settings.modal.button_text_color
- Text color of the button on the popup form (defaults to white)settings.modal.button_background_color
- Background color of the button on the popup form (defaults to black)settings.modal.close_button_color
- Color of the "X" button that closes the form (defaults to #ccc)settings.modal.error_background_color
- Background color of the form's error notification (defaults to pale red)settings.modal.error_text_color
- Text color of the form's error notification (defaults to red)settings.modal.success_background_color
- Background color of the form's success notification (defaults to pale green)settings.modal.success_text_color
- Text color of the form's error notification (defaults to green)
Troubleshooting
- The notify me button doesn't appear on my site!
- The notify me button doesn't match my theme!
- The notify me button is showing up in an odd place!
The notify me button doesn't appear on my site!
Because of the variability in Shopify themes, there are several potential solutions when your back in stock notification button is not appearing on your site:
You may have multiple classes in your product_page_button_class
value due to conflicting scripts, apps, or themes. Check for anything in your store that may be modifying the btn class, such as:
- Theme CSS rules or JavaScript code targeting buttons with the class btn
- Apps that modify product pages or buttons
If your product_page_button_class
value isn't using multiple classes, your Shopify theme might not access required product IDs when product pages are rendered. Before continuing, ensure the back in stock script is installed:
- Right click anywhere on your store
- Click Inspect
- Press CTRL + F
- Paste sendlane-backinstock-cta-button
If you find a button with an ID that equals sendlane-backinstock-cta-button, the back in stock script has been successfully installed.
Now you can check for undefined product IDs in your product pages. Open your browser's console (we highly recommend Chrome) and type the following into the console (copy and paste is not available in the console): document.querySelector('.product-variant-id')?.value
. If you get a result of undefined, you need to paste the following snippet just after the closing </script> tag of your back in stock script. This snippet provides the necessary product ID.
<input type="hidden" name="id" value="{{ product.selected_or_first_available_variant.id }}" disabled class="product-variant-id" >
The notify me button doesn't match my theme!
If the standard back in stock script cannot automatically apply your store's theme to the notify me button, you can add the product_page_button_class: "btn",
setting to the script with your theme's specific button class. The adjusted standard script will look something like this (note the addition of product_page_button_class: "btn",
in settings):
<script src="https://sendlane.com/scripts/sendlane-backinstock-widget.lib.js"></script> <script> SendlaneBackInStock.configure({ account: { token: "PUBLIC_TOKEN", platform: "shopify", }, settings: { cta_button: { text: "Notify me when available", product_page_form_element_selector: ".product-form", product_page_button_class: "btn", }, modal: { headline: "Get notified when this product is back in stock.", email_field_label: "Email", button_label: "Notify me when available", success_message: "We will notify you when it becomes available", disable_phone_field: true, } } }) </script>
btn
and button
are common generic button classes. If using the script above with the class set to btn
doesn't work, try changing btn
to button
.
If neither btn
or button
work, you'll need to use Chrome's inspect tool to find the button class your theme is using. If you haven't used the Chrome inspect tool before, check out this video on using the inspect tool to find the correct place to install the star rating widget for Sendlane Reviews. Use the technique shown in the video to highlight and identify the class associated with buttons in your store.
You should see <div>
tags related to buttons with a button class specified, like this:
In this specific instance, you'd replace the btn
in the modified script above with shopify-payment-button
. The class in your theme may be something else.
Replace the button classes in the script with those in your theme until the back in stock notification button matches your theme.
The notify me button is showing up in an odd place!
The basic back in stock script uses the product_page_form_element_selector: ".product-form",
setting to determine where the back in stock button appears. Most Shopify themes use the class .product-form
for the area of the product page where the variant and add to cart buttons are.
If your back in stock button appears somewhere odd on your product page, your theme either uses a class other than .product-form
for its product page selection buttons or does not have a class. You can fix this by changing the product_page_form_element_selector: ".product-form",
setting from .product-form
to your theme's class. Some common alternate classes are .product-single__form
and js-product-form
.
The adjusted standard script will look something like this (note the change of .product-form
to .product-single__form
in the product_page_form_element_selector
line):
<script src="https://sendlane.com/scripts/sendlane-backinstock-widget.lib.js"></script> <script> SendlaneBackInStock.configure({ account: { token: "PUBLIC_TOKEN", platform: "shopify", }, settings: { cta_button: { text: "Notify me when available", product_page_form_element_selector: ".product-single__form", product_page_button_class: "btn", }, modal: { headline: "Get notified when this product is back in stock.", email_field_label: "Email", button_label: "Notify me when available", success_message: "We will notify you when it becomes available", disable_phone_field: true, } } }) </script>
If neither .product-single__form
or js-product-form
work to place your button beneath the add to cart button, you'll need to use Chrome's inspect tool to determine the correct class for your theme. Note that the correct class will be unique, appearing only once in your product page's theme file.
You should see <div>
tags related to product information with a class specified, like this:
In this specific instance, you'd replace the btn
in the modified script above with shopify-payment-button
.
Replace the button class in the script with button classes found in your theme until the back in stock notification button matches your theme. The class in your theme may be something else.
Additional Resources
- Introducing Sendlane’s Back-in-Stock Notifications
- Learn the ins and outs of marketing automation from experts at eCommerce Academy
- 6 Ways to Improve Your eCommerce Emails