Personalized checkout and custom promotions with Shopify Scripts
I've been experiencing some issues with both the {{order.order_number}} and {{order_number}} liquid objects.
I have a script in the "Additional Scripts" section of the order status page. Note that this isn't placed by an app or part of the Shopify Plus scripts. It's a simple script that is manually added by going to Settings > Checkout > Additional Scripts.
The script logs a purchase event each time the status page is loaded and sends a few pieces of information out to a server. Included in the information is the Order Number. It looks something like this:
<script>
track('event', 'purchase', {
'value': {{checkout.total_price | money_without_currency}},
'order_number': {{order.order_number}}
});
</script>
This script has been inconsistent ever since I placed it. Sometimes it works, sometimes it doesn't. I discovered that the {{order.order_number}} value will not populate on occasions, resulting in a script error. I have also tried {{order_number}} with the same inconsistent result. Since this value doesn't seem to be accessible via Javascript through Shopify.checkout I'm at a bit of a loss.
Is there any reason why this value would be unstable? Is there another way I can consistently grab this information?
And just to clarify, I am looking to access the Order Number as it would appear in the orders dashboard in the admin. Not the order ID, order name, or the {{checkout.order_number}} value.
Thanks in advance for the help!
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025