Embed custom script in to your SharePoint pages

You can embed custom script into your SharePoint pages to enable analytics and tracking. You can also integrate 3rd party apps which require you to add their script to the page

Here is how to add a custom script to be executed on every page:

  1. Navigate to the main page of your intranet - aka the Hub Site
  2. Click the [*] → Site contents
  3. Open the [Site Assets] library and upload your custom script as a file, for example: [myscript.js]
    You can add any JavaScript compatible content to this file.
  4. Copy the URL of this file; we’ll be using it in the next step.

Now, let’s reference this script to be loaded on every page:

  1. Navigate back to the site contents by clicking the [*] → Site contents
  2. Find the [Config] list and open it
  3. Add the following new item in the list:

Title: TrackingCode
Value: [URL of the file you copied in step 4 above]

  1. Save the new item and refresh the Hub Site page. Your script will now be inserted into the [head] of each page and load on each page.

You can also insert a script into the Body of your page.
To do that, create an additional script file and a secondary [TrackingCode] element in the [Config] list. You will now have two [TrackingCode] elements. The first one will automatically go into the [Head] of the document and the second one into the [Body].

Anything unclear or doesn’t work?
Post your question or comment here