Cannot access "shop", "order", or "OrderStatus" objects/assets in "Additional Scripts" box

Solved
Highlighted
Tourist
12 1 1

Hello!

I am trying to add custom tracking in my checkout flow. I have navigated to Settings --> Checkout --> Additional Scripts.

 

In this documentation - https://help.shopify.com/en/manual/orders/status-tracking/customize-order-status/add-conversion-trac... - it says that "In that text box, you are able to use the shop Liquid object, the order Liquid object, and the OrderStatus Javascript asset."

However, when I try to access the shop object by putting the following in the "Additional Scripts" box

console.log('shop', shop);

I get the error

Uncaught ReferenceError: shop is not defined

 

How do I access the shop object? Is it a syntax issue?

0 Likes
Highlighted

This is an accepted solution.

It looks like you are using a JS variable not a liquid variable.

 

Try:

console.log('shop', {{ shop }});
0 Likes
Highlighted
Tourist
12 1 1

Ahh I see, thank you very much!

 

Also, the above only works for strings. For arrays, I've found that {{ <your_object> | json }} works for many Liquid objects. For example,

 

const lineItems = {{ order.line_items | json }};

is valid in the "Additional Scripts" box.

0 Likes