To continue receiving payouts, you need to secure your account by turning on two-step authentication. If two-step authentication is not turned on your payouts will be paused. Learn more

Include JavaScript ScriptTag in Shopify themes Node.js React - Embedded App

Shopify Partner
7 0 3

Hello Everybody, 

I just started developing apps on Shopify. I am a fresh developer with less than 1 year of programming experience. I am giving this info out because I would like to ask for a detailed and more beginner-friendly answer. 


I have created an embedded App using Polaris, Node.js, React. 

What I would like to accomplish is that my App will add a JavaScript script tag to the product.template.liquid right under the "Add To Cart" button. Also, it will remove the script tag from the product.template.liquid page when a toggle button in one of my React stateful components is clicked. 

I have the following Toggle handler: 

  state = {
        minValue: '',
        maxValue: '',
        enabled: false,

                        content: contentStatus,
                        onAction: this.handleToggle,
                    BusyStore App is{' '}
                    <TextStyle variation="strong">{textStatus}</TextStyle>.

handleToggle = () => { 
        this.setState(({enabled}) => { 
            return {enabled: !enabled};


When this.state == enabled POST: 

                function foo() {
document.getElementById('txt').innerHTML =
            		"&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<strong>" + Math.round(count) + "</strong> ogląda teraz ten produkt";
   		         var t = setTimeout(startTime, 2000);
		function checkTime(i) {
   			 if (i < 10) {i = i};
   		 return i;


when this.state == disabled then DELETE 


<body onload="startTime()">
                   			<img src=""
                        		     style="height: 32px; margin-bottom: -34px;">
					<div id="txt"></div>


I am using on load property to call the function. 


How do I go about adding such a snippet: 

Is this the right approach? 

Replies 0 (0)