Adding additional scripts and running scripts only on first visit
You can customize your order status page by adding additional scripts. You can also set up your scripts to run only on a first visit.
Add additional scripts
The Additional scripts box is used to insert code into the template for your order status page. You can add any of the following:
HTML - You can use any valid HTML5 code, for example script, style, iframe, and object elements.
Liquid code - You have access to the
checkout
andshop
Liquid objects. To learn more about their attributes, refer to The checkout object and The shop object. Note that thecheckout.order
,checkout.order_name
, andcheckout.order_number
values may not be present if the order creation is not yet complete. Use `checkout.order_id if you need a unique tracking id for the order that is available at all times.
Example customizations using additional scripts
Here are some example customizations that use the Additional scripts field:
- Show content when a particular shipping method is used
- Show content when a particular product is in the order
- Show content based on customers' locations
- Add a message to your order status page using a JavaScript object
Access the additional scripts
Desktop
To access additional scripts, start from your Shopify admin, and go to Settings > Checkout. Under Order status page you find the Additional scripts section.
Mobile
To access additional scripts, start from your Shopify app and go to Store > Checkout. Under Store settings, tap Checkout. Under Order status page, you find the Additional scripts section.
Set up scripts to run only on a first visit
It's common to include scripts that track sales conversions on the order status page because it's the final page of checkout. However, customers who return to check their order status might count as a second sale in your analytics.
To prevent your analytics from counting customers more than once, you can add the first_time_accessed
property around some or all of your additional scripts. To do this, use a Liquid if statement, and place any scripts that you only want to run once between {% if first_time_accessed %}
and {% endif %}
tags.
Steps:
Desktop
- From your Shopify admin, go to Settings > Checkout.
- In the Order status page section, go to the Additional scripts text box.
- Paste the following code into the Additional scripts box:
- If you want a script to run the first time that the order status page is accessed, then paste it between the
{% if first_time_accessed %}
and{% endif %}
tags. If you want a script to run every time the order status page is accessed, then paste it below the{% endif %}
tag. - Click Save.
iPhone
- From the Shopify app, tap the … button, and then tap Settings.
- In the Store settings section, tap Checkout.
- In the Order status page section, go to the Additional scripts text box.
- Paste the following code into the Additional scripts box:
- If you want a script to run the first time that the order status page is accessed, then paste it between the
{% if first_time_accessed %}
and{% endif %}
tags. If you want a script to run every time the order status page is accessed, then paste it below the{% endif %}
tag. - Click Save.
Android
- From the Shopify app, tap the … button, and then tap Settings.
- In the Store settings section, tap Checkout.
- In the Order status page section, go to the Additional scripts text box.
- Paste the following code into the Additional scripts box:
- If you want a script to run the first time that the order status page is accessed, then paste it between the
{% if first_time_accessed %}
and{% endif %}
tags. If you want a script to run every time the order status page is accessed, then paste it below the{% endif %}
tag. - Click Save.