Installing UTM Tracking Code

UTM (Urchin Traffic Monitor) code is necessary for getting the most traffic data from your site’s visitors. The following five simple steps will guide you through installing the UTM JavaScript code on your website:

  1. Copy UTM files into the website document root
  2. Enable Cookies in Logging
  3. Implement UTM tracking code into your HTML
  4. Set Urchin 6 Profile to use UTM
  5. Check for correct implementation
  1. Copy UTM files into the website document root
    The files, urchin.js and __utm.gif are located in the path/to/urchin6/util/utm directory in the Urchin distribution. Copy these two files to the root directory of your website content. IMPORTANT: the GIF filename begins with two underscores.
  2. Enable Cookies in Logging
    • IIS
      Open the IIS Manager and bring up the Properties window for your website. Make sure the logging is enabled and set to the W3C Extended format. Click the Properties button next to the format and under the Extended Properties Tab, check the box next to Cookie.
    • Apache
      If not already enabled, you can use the following log format in your httpd.conf file to enable cookie logging:LogFormat "%h %v %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{Cookie}i\"" special
  3. Implement UTM tracking code into your HTML
    • Urchin 6 by itself
      Enter the following lines in all of your HTML pages. While it can go anywhere in the pages, we recommend putting it right before the </body> tag. If you use a common include or template, you can enter it there.<script src="/urchin.js" type="text/javascript"></script>
      <script type="text/javascript">
      urchinTracker();
      </script>

      If you are using a package like “HTML Tidy”, you may want to include the Javascript line in the HEAD area of your page, for instance:

      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; ">
      <script src="/urchin.js" type="text/javascript"></script>
      <script type="text/javascript">
      urchinTracker();
      </script>
      ...
      </head>
      ...

    • Urchin 6 and Google Analytics Side-by-Side
      NOTE: Be sure to change “UA-1234567-8” to the appropriate Google Analytics Account number.

      • Old Code (urchin.js)<script src="http://www.google-analytics.com/urchin.js"
        type="text/javascript"></script>
        <script type="text/javascript">
        _uacct = "UA-1234567-8";
        _userv = 2;
        urchinTracker();
        </script>

        Specifically, _userv = 2; must be declared before urchinTracker() to tell the UTM
        code to make a GIF request to both Google Analytics and Urchin.

      • New Code (ga.js)

        <script type="text/javascript">
        var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
        document.write(unescape("%3Cscript src='" + gaJsHost + "googleanalytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
        </script>
        <script type="text/javascript">
        var pageTracker = _gat._getTracker("UA-1234567-8");
        pageTracker._setLocalRemoteServerMode();
        pageTracker._trackPageview();
        </script>

        Specifically, pageTracker._setLocalRemoteServerMode(); must be declared before
        _trackPageView() to tell the UTM code to make a GIF request to both Google Analytics
        and Urchin.
  4. Set Urchin 6 Profile to use UTM
    In the Urchin Administration interface, edit the profile in question and click on the Reporting tab. Set the Visitor Tracking Method to UTM. Set the UTM Domain to the address of your website without the www. When done click the Update button. Then click on the Profile Settings tab and choose UTM-Enable All for the Default Report Set, then click Update again. That’s it! Your website will now begin logging UTM data into your normal log file which will be identified the next time you run Urchin.
  5. Check for correct implementation
    To see if the UTM is successfully making entries to your log file, check the log after you have installed the UTM and clicked on a few pages of the site. You should see an entry similar to the following in the log file:

    ... "GET /__utm.gif?..." 200 ..."__utma=..."

    If you don’t see the __utma entries, be sure to check that cookies was enabled in the logging properly. If the status code is not 200 then check to make sure the files were properly copied to your document root.