Script tags in checkout

tomw
New Member
3 0 0

Hi all,

I'm looking at developing an app for Shopify which will add functionality to a store's checkout page. It would be ideal if the user didn't have to copy and paste code into files themselves hence I was looking at using the ScriptTag API (http://api.shopify.com/scripttag.html) to include a custom javascript file.

I've worked through some of the examples on the aforementioned API page and can get a custom script included on every page on my test store except for the checkout page. I've changed the src to start with 'https://' as suggested by the tutorial but my script still doesn't run or even appear in the page source for the checkout.

Does anybody have any ideas how I can get this working for the checkout? Is what I'm trying to do even possible?

Cheers in advance,
Tom

Replies 8 (8)
Jamie
Shopify Staff (Retired)
Shopify Staff (Retired)
5841 0 162

Hi Tom, you cannot add scripts to the checkout process for security reasons associated with PCI compliance.

Jamie | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

HunkyBill
Shopify Expert
4738 54 544

According to the API Docs... you can. Perhaps this needs a little clarification.

Note that a ScriptTag will only appear in checkout if the src starts with 'https://' in order not to break the SSL lock.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
tomw
New Member
3 0 0

Yep, that's what I read in the API docs which is why I thought I should be able to do it. Could someone please clarify if a ScriptTag can or cannot appear 'in' the checkout?

Cheers

HunkyBill
Shopify Expert
4738 54 544

This was previously beaten to death in the now defunct Google Groups... you can drop JS into the final page of checkout, known as the Thank You page. At that point, your script can do whatever you need to do. The completed order is present via Liquid there. You cannot drop script into the first two pages of checkout where other data is collected, as that would introduce serious security issues as you can imagine.

Arguably the docs are correct. The Thank You page is part of checkout. 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
tomw
New Member
3 0 0

Ok, thank you very much for the clarification

Scott__Bates
Shopify Partner
5 0 0

@HunkyBill  can you share more details on being able to put javascript on the Thank You page?   you even mention that the completed order is available in liquid which would imply that there is a liquid template for the thank you page but I have seen nothing on that anywhere else.  

I am trying to add the e-commerce specific google analytics tags to my store but it's javascript  that requires being on that final thank you page with knowledge of the order, I'd need to render some additional details in the liquid.  

See: https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingEcommerce

HunkyBill
Shopify Expert
4738 54 544

http://api.shopify.com/scripttag.html

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
Scott__Bates
Shopify Partner
5 0 0

@HunkyBill - Thanks...  helpful and that could potentially solve half the problem.  But you clued me into the correct google search that led me to : http://support.shopify.com/customer/portal/articles/527942-how-do-i-customize-my-thank-you-page-  and I think that link will allow me to get both the liquid and javascript to do the additional analytics.

thanks