• FirefoxUpgrade to the new Firefox »
  • Quick Install Guide

    Last Updated: March 19, 2012
    Text Size: A A A

    Save to My Help

    Save this article to My Help for easy reference. You can visit the article at any time from any computer.

    Replace an article

    You have reached the maximum number of saved articles. Your oldest saved article will be replaced with the new one.

    This document is a quick start guide which explains how to install basic Yahoo Web Analytics tracking.

    The guide will illustrate the simple pixel-only installation through to a standard installation including JavaScript and non-java script modes.

    Where do I actually get my tracking code?

    The tracking code is available from the Yahoo Web Analytics user interface.

    1. Click the Control Center tab.
    2. Click on the Installation button to open the Installation overlay, which shows the tracking code.
    3. Copy the displayed text to your clipboard.

    Where do I put the Tracking Code?

    1. Paste the copied text into your web site’s HTML pages, just before the closing <body> tag:

      After paste or insertion into a content management system and saving the web page, your html should look like this:

      NOTE. You will need to place tracking code on any page you want to track; the code you insert on pages may differ as described in the Yahoo Web Analytics Installation Guide. The example in this guide shows only how to verify basic installation for a single sample page.

    2. Save the page (if needed) to your web server.

      At this stage YWA will not have collected any data yet. If you select the project in Yahoo Web Analytics, it should look something like this:

    About the Tracking Code

    There are multiple versions of the tracking code available.

    Pixel Tracking Version

    The simplest non-JavaScript version of the tracking code is a simple pixel-tracking, no JavaScript version.

    A sample of this type of tracking code might look like this:

    <div><img src="http://a.analytics.yahoo.com/p.pl?a=1234567890123&js=no" width="1" height="1" alt="" /></div>

    This code makes a single pixel request along with a query string parameter (query string parameters are the values after the question mark symbol such as a=1234567890123 (which is the project ID) in the above example).

    JavaScript Version

    A better version of the tracking code uses an included java script called ywa.js file that is sent by Yahoo servers.

    This code tracks more user activity (such as exit links and downloads), and so provides fuller analytics data.

    To use this code:

    1. The JavaScript ywa.js file is included, then a JavaScript object is created using the relevant project id:

      <script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>

    2. Next, the submit() function is run, which sends the following:

      var YWATracker = YWA.getTracker("1234567890123");

    3. Finally a submit function is called which sends the analytics tracking information for a page view to Yahoo’s web analytics servers:

      YWATracker.submit();

      Here is the full code for this minimal JavaScript version:

      <script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
      <script type="text/javascript">
      var YWATracker = YWA.getTracker("1234567890123");
      YWATracker.submit();
      </script>

    Note: The JavaScript file location can vary depending on your location.

    Hybrid Version

    Not all browsers support JavaScript. In order to track web sites on both browsers that support JavaScript and browsers that do not, you can use a combined version of the code outlined in the previous two sections. The JavaScript-enabled browser can use the section of code denoted by the JavaScript sections, while the non-JavaScript-enabled browsers run the code in the noscript section.

    <script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
    <script type="text/javascript">
    var YWATracker = YWA.getTracker("1234567890123");
    YWATracker.submit();
    </script>
    <noscript>
    <div><img src="http://s.analytics.yahoo.com/p.pl?a=1234567890123&js=no" width="1" height="1" alt="" /></div>
    </noscript>

    Setting Document Name and Document Group Values

    By default, the tracking code uses the web page title (in our example <TITLE>Your sample web page</TITLE>) as the document name (see http://help.yahoo.com/l/us/yahoo/ywa/faqs/tracking/customcode/v4/customcode-05.html). However, you can override this assignment by setting a document name using the setDocumentName(…) function. The page will then be tracked under the name set in the parentheses after the function rather than the page title defined in the HTML.

    Similarly, you can set an optional document group value (see http://help.yahoo.com/l/us/yahoo/ywa/faqs/tracking/customcode/v4/customcode-10.html). This document grouping can be set using the setDocumentGroup(…) function.

    The code to implement these two functions might look something like this:

    <script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
    <script type="text/javascript">
    var YWATracker = YWA.getTracker("1234567890123");
    YWATracker.setDocumentName("my web site page name");
    YWATracker.setDocumentGroup ("my web site group of pages name");
    YWATracker.submit();
    </script>
    <noscript>
    <div><img src="http://s.analytics.yahoo.com/p.pl?a=1234567890123&js=no" width="1" height="1" alt="" /></div>
    </noscript>

    Tracking Sale Completions

    If you want to track a sale completion, you could implement specific tracking code that signified a sale completion. On that page, you would use a special variable called an action in conjunction with a sale amount. This can be coded using the functions setAction("01"); and setAmount("GBP59.95"); where the amount has both the currency and actual value of the sale coded into it. (See Available Currencies for a list of valid currencies.)

    The value (GBP59.95 in the example above) should be dynamically populated by the content management system or through JavaScript that your development staff would have to implement on your web site.

    <script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
    <script type="text/javascript">
    var YWATracker = YWA.getTracker("1234567890123");
    YWATracker.setDocumentName("my web site sale confirmation page name");
    YWATracker.setAction("01"); // a sale has occured indicated by action set to 1
    YWATracker.setAmount("GBP59.95"); // a sale of 59 UK pounds and ninety five pence
    YWATracker.submit();
    </script>
    <noscript>
    <div><img src="http://s.analytics.yahoo.com/p.pl?a=1234567890123&js=no" width="1" height="1" alt="" /></div> </noscript>

    How do I Check the Tracking Code?

    Once the code has been added to your web page, you are ready to check that your site is running the tracking code correctly.

    There are several steps involved in checking your site. This section is optional; if you simply want to check your site using Yahoo Web Analytics reports, skip ahead to Check the “Last Visitor Details” Report on page 9.

    Using a Browser Utility to Trace Your Code (optional)

    In this example, we’ll show how to check the site using a utility available with the Firefox browser.

    1. Choose Tools > Add-ons and download and install the free add-on called HttpFox.

    2. From the Tools menu in FireFox, activate the HttpFox add-on.

    3. Load the web page that you added the tracking code to earlier into a browser. This should generate a page view event that will send data to Yahoo Web Analytics for collection.
    4. Using HttpFox, check the message trace as shown below. You are looking for a request to analytics.yahoo.com in the first pane. If you see that entry, select it.

    5. Select the Query String tab.
    6. Check that the ‘a’ parameter displays the same value that was originally defined in the tracking code. (Every project has a unique project ID, which Yahoo Web Analytics uses in tracking your site.)

    Using a Browser Utility to Check for JavaScript Errors (optional)

    It is also important that your page contain no JavaScript errors, as this can prevent the web page from being tracked by YWA. There are any number of utilities for validating your web pages. In this example, we’ll show how to check the site using a utility available with the Firefox browser:

    1. Download and install the free add-on called Firebug.

    2. Activate Firebug and verify that there are no JavaScript errors on the web page. If you see the “bug” icon at the bottom of the page with the Firebug add-on active, it means that there are no JavaScript errors on your page.

    Check the “Last Visitor Details” Report

    After loading the page into your browser, you can verify that the page was viewed from the Yahoo Web Analytics interface:

    1. Go to Reports > Last Visitor Details.

    This should reflect the page view that you just executed:

    That’s it!

    If you can see the tracked data in your Last Visitor Details report, then your web site is being tracked.

    Was this information helpful?      

    My Help

    Forgot your ID or password?

    Sign In

    Sign in to see your account information saved articles and more.
    1. Recent Searches (0)

    2. Saved Articles