Standard Method for Instrumenting Webtrends JavaScript for SharePoint 2010

The standard method adds the Webtrends JavaScript to SharePoint 2010 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 2010.
    1. On the Site Actions page, click Settings.
    2. On the Site Settings page, under the Look and Feel category, click Master Page.

      Locating the Site and System master pages in SharePoint

      Note:

      If Master Page does not appear in Look and Feel:

      • You may be running SharePoint 2010 Foundation. In this case, the default master page is v4.master. If it has been changed, please contact your SharePoint administrator to determine which one to use.
      • If you are running SharePoint 2010 Server (Standard or Enterprise), you need to activate the SharePoint Server Publishing Infrastructure Feature at both the Site Collection and the Site levels. In 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 Featuress.

  2. Use the SharePoint Designer or a text editor to modify your master page(s) to include the Webtrends JavaScript call between the head tags:

    Editing the master page in the site collection

  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:
    • YOUR_WEBTRENDS_DCSID_HERE
    • YOUR_TIMEZONE_HERE
    • PATH_TO_WEBTRENDS.SP.JS
    • PATH_TO_WEBTRENDS.JS
              var dcs = new Webtrends.dcs().init({
              dcsid: "YOUR_WEBTRENDS_DCSID_HERE",
              timezone: "YOUR_TIMEZONE_HERE",
                            …
    window.wt_sp_globals.dcs = new Webtrends.dcs().init({
            dcsid: "YOUR_WEBTRENDS_DCSID_HERE",
            timezone: "YOUR_TIMEZONE_HERE",
            plugins: {
                sp: { src: "PATH_TO_WEBTRENDS.SP.JS" },
                hm: { src: "//s.webtrends.com/js/webtrends.hm.js" }
            }
        });
    
    …
    
    (function() {
        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);
    })();
    
    Note that these customizations remove the reference to window.wt_sp_globals.url. This is defined by the Webtrends Feature, so it will not be present if you are performing a standard install.
    1. Add the following line to the top of webtrends.load.js. This is automatically inserted elsewhere by the Webtrends Feature, but must be inserted manually if you are not using it.
      window.wt_sp_globals = {};
    2. Replace the following with the proper values:
  5. Add the following to the end of the HEAD section of every page you want to track, making sure to replace PATH_TO_WEBTRENDS.LOAD.JS with your specific values:
    <script type="text/javascript" src="PATH_TO_WEBTRENDS.LOAD.JS"></script>