How to add javascript / embedd live chat on Mobile app

Hi, how do I embedd this snippet on one of my mobile pages to enable live chat? I tried to add a Javascipt element to a onready action but it does not seem to work? The intructions from freshchat are to:

Paste this code snippet before </BODY> 

  function initFreshChat() {

    window.fcWidget.init({

      token: "XXX",

      host: "https://wchat.freshchat.com"

    });

  }

  function initialize(i,t){var e;i.getElementById(t)?initFreshChat():((e=i.createElement("script")).id=t,e.async=!0,e.src="https://wchat.freshchat.com/js/widget.js",e.onload=initFreshChat,i.head.appendChild(e))}function initiateCall(){initialize(document,"Freshdesk Messaging-js-sdk")}window.addEventListener?window.addEventListener("load",initiateCall,!1):window.attachEvent("load",initiateCall,!1);

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.