Hi ,
Welcome to the Support Portal. How can we help?
Follow

Insert scripts on instance level

Table of Contents

 

Introduction

For hosting partners, we have replaced the ability to add a Google Analytics code with the ability to inject a custom piece of HTML into every page (e.g. Google Tag Manager). 

 

Configuration

Custom info can be changed via the config settings which can be found in: 

\inetpub\wwwroot\{tenant name}\{workspace folder}\Configs\NDAW.Html.Front.config

The setting is called "ExtraHtmlToInjectOnEveryPage". Because the config file is in XML format, adding control characters ('<', '>', ''', '"', '&') into the parameter value can cause the parser to miss understand the resulting data. The solution is to escape the control characters so that the parser can interpret them correctly as data, and not confuse them for markup.

The following is a list of all the necessary replacements:

Char Escape String
< &lt;
> &gt;
" &quot;
' &apos;
& &amp;

For example, if you want to include the text “Hello world!” in H1 tags, the HTML code would be:

<h1>Hello world!</h1>

With XML escaping, this would become:

&lt;h1&gt;Hello world!&lt;/h1&gt; 

And the resulting "ExtraHtmlToInjectOnEveryPage" setting would become:

<setting name="ExtraHtmlToInjectOnEveryPage" serializeAs="String">
<value>&lt;h1&gt;Hello world!&lt;/h1&gt;</value>
</setting>
Tip: To prevent typing errors, you can use an online XML Escape site like https://jsonformatter.org/xml-escape

If you want to inject a piece of javascript it needs to include the <script> tags. Here’s an example of calling an external javascript file located in the root of your Workspace 365 site:

<setting name="ExtraHtmlToInjectOnEveryPage" serializeAs="String">
<value>&lt;script type=&quot;application/javascript&quot; src=&quot;/include.js&quot;&gt;&lt;/script&gt;</value>
</setting>

The relative URL provided here can be replaced by an absolute URL. This allows you to call a script from a separate location, such as your own website.

Back to top