New Pages Aren't Displaying Custom Javascript?

I am trying to create an order tracking page which uses an Aftership tracking button that is coded in JavaScript. Although adding extra HTML onto the page works and is displayed, when I try to input some JS, nothing shows up.

Here is the snipped I am trying to add, for reference:




(function(e,t,n){var r,i=e.getElementsByTagName(t)[0];if(e.getElementById(n))return;r=e.createElement(t);r.id=n;r.src="//button.aftership.com/all.js";i.parentNode.insertBefore(r,i)})(document,"script","aftership-jssdk")

Has anyone experienced this sort of problem before?

Any help would be greatly appreciated!

You might want to use instead of tag.

How do you add this code? Do not forget to switch WYSIWYG editor to the source code mode also!

I inserted the code directly into the description field when editing the page, without clicking the < > button (which is what Aftership recommended). The front-end just displays the code itself, and not the tracking button itself.

I have tried inserting it into the HTML field instead (the < > part), but that doesn't display anything on the front-end either.

Again, suggest you use tags instead of tags if you want your javascript to execute. The tags are used to format code. I.e. like a

 tag where it recognizes whitespace and newlines.

Tony is right. For example, script tags are used here:

https://aftership.uservoice.com/knowledgebase/articles/258399-how-can-i-add-track-button-to-magento

Do not forget about source code mode.