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!
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024