Standard Method for Instrumenting Webtrends JavaScript for SharePoint 2013 and Office365

The standard JavaScript method adds the Webtrends JavaScript to SharePoint 2013 and Office365 website pages. This method works with the Webtrends SharePoint Analytics feature; the User Info Collector functionality will not be available.

The following three JavaScript files used in this task are in the root of the install file:

  • webtrends.load.js is inserted into every page and is responsible for initiating collection. All customization should be done in this file.
  • webtrends.js is the base Webtrends JavaScript tag.
  • webtrends.sp.js is the base SharePoint plugin for the Webtrends JavaScript tag.

To add the Webtrends JavaScript tag with this method, you need to insert a small snippet of JavaScript in the <head> section of all pages you want to track. You can use any technique you prefer to insert this JavaScript. The procedure below adds the JavaScript to the master page, resulting in all pages inheriting the snippet from the master page.

  1. Determine the master page(s) to edit in SharePoint 2013.
    1. On the Site Contents page, click Settings.
    2. On the Site Settings page, under the Web Designer Galleries category, click Master Page.

      If Master Page does not appear under Look and Feel:

      • You may be running SharePoint 2013 Foundation. In this case, the default master page will be seattle. If it has been changed, contact your SharePoint administrator to determine which one to use.
      • If you are running SharePoint 2013 Server, you need to activate the SharePoint Server Publishing Infrastructure feature at the Site Collection level and the SharePoint Server Publishing feature at the Site level. On the Site Settings page:
        Under Site Collection Administration, click Site collection features.
        Under Site Actions, click Manage site features.

      Contact your SharePoint administrator to determine the master page in use if you do not want to or are unable to activate these features.

  2. Edit the master page using SharePoint Designer 2013
  3. Create a custom List named WebtrendsAssets and upload the three JavaScript files to it. Host the JavaScript files in ~sitecollection/Lists/WebtrendsAssets. Alternatively, you can host these files in any location you choose, such as a static content server.
    Important: Wherever you choose to host these files, note the location for use in the step below.
  4. Modify webtrends.load.js and replace the following with the proper values:
                     var dcs = new Webtrends.dcs().init({
            dcsid: "YOUR_WEBTRENDS_DCSID_HERE",
            timezone: "YOUR_TIMEZONE_HERE",
            plugins: {
                sp: { src: "PATH_TO_WEBTRENDS.SP.JS" },
                hm: { src: "//" }
            function loadScript() {
                    var s = document.createElement("script");
                    s.async = true;
                    s.src = "PATH_TO_WEBTRENDS.JS";
                    var s2 = document.getElementsByTagName("script")[0];
                    s2.parentNode.insertBefore(s, s2);
  5. Add the following to the bottom of the HEAD section of every page you want to track, making sure to replace TITLE_OF_SITE_COLLECTION and PATH_TO_WEBTRENDS.LOAD.JS with your specific values:
      <SharePoint:ScriptBlock runat="server">                
            window.wt_sp_globals = {
                            method: "manual"
                    (function () {
                    var s = document.createElement("script");
                    s.async = true;
                    s.src = "PATH_TO_WEBTRENDS.LOAD.JS";
                    var s2 = document.getElementsByTagName("script")[0];
                    s2.parentNode.insertBefore(s, s2);