Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

Customize Tracking Code

Last Updated: March 28, 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.

The tracking code includes functions that you can activate in order to collect deeper information about your visitors or to track specific actions and data such as a document name, a sale action and/or the corresponding revenue data.

Available tracking setter functions

These are all the available setter functions:

Function Name Description
setDocumentName Assign specific titles to your web pages (only for reporting purposes).

Usage:

YWATracker.setDocumentName("xxx");

setDocumentGroup Group your web pages into meaningful groups (only for reporting purposes).

Usage:

YWATracker.setDocumentGroup("xxx");

setMemberId Assign member IDs to your visitors.

Usage:

YWATracker.setMemberId("xxx");

setAction Create custom actions. A total of 50 actions are available, with #2 through #50 available to the user. (Action #1 is reserved for the SALE action.)

Usage:

YWATracker.setAction("xxx");

setAmount If you have a shopping web site, this function enables you to enter the total sum of a visitor's purchases.

Usage:

YWATracker.setAmount("xxx");

setOrderId If you have a shopping web site, this function enables you to enter the order ID of a visitor's purchases. Tracking the setOrderId for a shopping site is mandatory, as this greatly improves the accuracy of monitoring your online sales.

Usage:

Usage: YWATracker.setOrderId("xxx");

setTax If you have a shopping web site, this function enables you to enter the tax on a visitor's purchases. It is an optional function.

Usage:

YWATracker.setTax("xxx");

setShipping If you have a shopping web site, this function enables you to enter the shipping charges on a visitor's purchases. It is an optional function.

Usage:

YWATracker.setShipping("xxx");

setDiscount If you have a shopping web site, this function enables you to enter the discount on a visitor's purchases. It is an optional function.

Usage:

YWATracker.setDiscount("xxx");

setSKU If you have a shopping web site, this function enables you to track the SKU (Stock Keeping Unit) information of your products.

Usage:

YWATracker.setSKU("xxx");

setUnits If you have a shopping web site, this function enables you to track how many products your visitors bought.

Usage:

YWATracker.setUnits("xxx");

setAmounts If you have a shopping web site, this function enables you to enter the price of your products. This function expresses the individual price of an item multiplied by the total number of units of the respective item. E.g., if a customer buys 3 units of Product A, and the individual price of Product A is $100, the value of the setAmounts function will be $300.

Usage:

YWATracker.setAmounts("xxx");

setCF Use Custom Fields and to add your specific tracking functions to the standard functions already available in the system.

Usage:

YWATracker.setCF(7, "xxx");
YWATracker.setCF(8, "xxx");

setCmpQuery Track the URL of a referring campaign even though the web site is set to remove the tracking string.

Usage:

YWATracker.setCmpQuery("xxx");

setDomains Track web sites that have different sub-domains and third-level domains by preventing exit links being tracked when a visitor moves between domains. If you set the setDomains function to equal wild card (*) + the main domain name, all the sub-domains will not be counted as exit links, but as part of the main domain. This function needs to be implemented on every page of your main web site containing links to the second domain.

Usage:

YWATracker.setDomains("xxx");

You can use the setDomains function only with selected web sites, which you can list as different values:

YWATracker.setDomains("www.domain.com,cart.domain.com, domain.com");

or,

YWATracker.setDomains("*.domain.com,*.domain.net");

Please note that you can use regular expressions with the DOMAINS function:

YWATracker.setDomains("REGEXP:writeregularexpressionhere");

Note: The sub-domain(s) must also have tracking code installed.

setCookieDomain Prevent visit sessions from being broken when a visitor moves between different domains in a single project that share a common domain denominator (e.g., browse.example.com and shop.example.com). The same value (example.com) should be specified for the variable in the tracking code placed on pages on each subdomain.

Usage:

YWATracker.setCookieDomain("example.com");

In this case, the Yahoo! Web Analytics cookie will be stored for example.com and will therefore not be specific to either subdomain. setCookieDomain should not be used when there is no common domain denominator.

setFlashUrl Record the location of the Flash object. This function should be used when the location of the Flash object cannot be determined by the URL.

Usage:

YWATracker.setFlashUrl("xxx");

setISK Track internal search phrases and has to be inflated on the internal search results page.

Usage:

YWATracker.setISK("xxx");

setISR Track the number of internal search results. This function must be included on the internal search results page. See Tracking internal search functionality..

Usage:

YWATracker.setISR("xxx");

The functions listed above have to be used as part of a tracking object. All function names are case sensitive. Your functions cannot accept parameters longer than 75 characters. You must not use non-ASCII characters in function names. Do not use any of the following characters in the name:

'<>#&;:?-*~`´)(=%!".

These and other non-ASCII characters may interfere with the operation of the tracking code. (The leading slashes (//) must be removed to activate the function.)

Tracking by document name

Yahoo! Web Analytics enables you to assign each web page a unique name for the purposes of reporting. If you do not define a page name, Yahoo! Web Analytics will use that page's HTML title tag in reports.

The setDocumentName function is used primarily to identify a specific product or page you wish to track. This feature is also useful for naming pages that are generated dynamically.

You can also use the setDocumentName function for assigning pages with different titles to one setDocumentName in order to see these pages in a single report.

Example

<!-- Yahoo! Web Analytics - All rights reserved -->
<script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
<script type="text/javascript">
  var YWATracker = YWA.getTracker("1000123xxxx");
  YWATracker.setDocumentName("About us");
  YWATracker.submit();
</script>
<noscript>
 <div><img src="http://a.analytics.yahoo.com/p.pl?a=1000123xxxx&amp;js=no" width="1" height="1" alt="" /></div>
</noscript>
<!-- End of Yahoo! Web Analytics Code -->

Tracking by document group

With document groups, you can group similar pages (e.g., products, services, etc.) and compare the popularity of these sections in your reports. Use the setDocumentGroup function in your tracking code to identify each page that you wish to be part of a document group. For example, all your pages that provide product information could be identified by the document group name 'Products'. This function allows you to create one level of categorization, but if multiple levels are needed, then custom fields must be used.

Example

<!-- Yahoo! Web Analytics - All rights reserved -->
<script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
<script type="text/javascript">
  var YWATracker = YWA.getTracker("1000123xxxx");
  YWATracker.setDocumentName("About us");
  YWATracker.setDocumentGroup("Company Information");
  YWATracker.submit();
</script>
<noscript>
<div><img src="http://a.analytics.yahoo.com/p.pl?a=1000123xxxx&amp;js=no" width="1" height="1" alt="" /></div>
</noscript>
<!-- End of Yahoo! Web Analytics Code -->

Tracking registered visitors

If you install Yahoo! Web Analytics on a corporate extranet or on a web site with a members' area, you may want to identify registered visitors in your reports.

To track registered members, you need to customize the setMemberId function in your tracking code. To identify the appropriate function to include in your Yahoo! Web Analytics tracking code, you need to be familiar with the custom scripting (e.g., PHP, JSP, ASP) employed in your content management system.

Note: Your MEMBERID function cannot accept parameters longer than 75 characters. You must not use non-ASCII characters in the function name. Do not use any of the following characters in the name:

'<>#&;:?-*~`´)(=%!".

These and other non-ASCII characters may interfere with the operation of the tracking code. (The leading slashes (//) must be removed to activate the function.)

Example

<!-- Yahoo! Web Analytics - All rights reserved -->
<script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
<script type="text/javascript">
  var YWATracker = YWA.getTracker("1000123xxxx");
  YWATracker.setDocumentName("Welcome page");
  YWATracker.setDocumentGroup("Members Area");
  YWATracker.setMemberId("John");
  YWATracker.submit();
</script>
<noscript>
<div><img src="http://a.analytics.yahoo.com/p.pl?a=1000123xxxx&amp;js=no" width="1" height="1" alt="" /></div>
</noscript>
<!-- End of Yahoo! Web Analytics Code -->

Tracking actions (conversion analysis)

Yahoo! Web Analytics enables you to define and track up to 50 actions that have value to your business. Actions 1-5 are reserved, while actions 6 through 50 can be defined by the user. Typical actions you might want to track include an online sale, a registration form, a newsletter subscription, or following specific links, etc.

Once you define an action, you can check your conversion reports in order to analyze your web users' behavior in the context of that action. A conversion is defined as a visitor completing an action you configured. With conversion analysis, you can determine the effectiveness of an online marketing campaign, and troubleshoot critical actions such as site registrations, newsletter signups, file downloads, etc.

Yahoo! Web Analytics offers you the following pre-defined actions:

  1. Sale (end of a completed sales process) - Action 01. This action cannot be changed and is the only action that can be associated with the setAmount function.
  2. Signup (successful signup or subscription to a service) - Action 02.
  3. Newsletter (subscription to a newsletter) - Action 03.
  4. Contact (contact form submission) - Action 04. Actions 02, 03, and 04 are suggested and can be changed by simply entering a different action name.

You can also define your own custom actions for Actions 05 through 50.

Note: An action does not need to be a purchase of goods or a signup to an online service. You can define actions on product information pages. If a visitor looks at your products (not just your home page) it indicates that this visitor shows interest in your offering.

Setting up action tracking

  • Go to Settings > Action tracking > Track sales, revenue, form submissions, downloads and custom actions. This displays the Custom Actions window (see Custom Actions Window.).
  • Enter your own custom actions in the fields for Actions 05 through 10.
  • Decide whether an action is unique or not.
  • Click on the Update button.

Custom Actions Window

You should configure an action as unique if the visitor performs that action more than once but the action is recorded just once (e.g., tracking how many visitors downloaded a document from your web site). To configure an action as unique, check off the Unique check box.

You should configure an action as non-unique if every time the visitor performs that action, it is recorded as such (e.g., tracking how many times visitors bought something from your web site). To configure an action as non-unique, leave blank the Unique check box.

Note: Keep in mind that every time the page on which you configured an action is viewed, an action is recorded, so make sure the page is unique to that action. Generally, this means the ‘Thank you' or ‘Confirmation' page that is displayed at the end of a purchase or a form submission.

To finish implementing actions, you also need to customize the tracking code on the targeted pages. You can define actions on your web site by using the setAction function in the tracking code. Set this function with one of the available action IDs for each page that you wish to be considered an ‘action'.

When using the Sale Action (01), you may also include the setAmount function, which associates the monetary value of a purchase with the Sale Action.

Example

<!-- Yahoo! Web Analytics - All rights reserved -->
<script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
<script type="text/javascript">
  var YWATracker = YWA.getTracker("1000123xxxx");
  YWATracker.setDocumentName("Payment Confirmation");
  YWATracker.setDocumentGroup("Shopping Cart");
  YWATracker.setAction("01");
  YWATracker.submit();
</script>
<noscript>
<div><img src="http://a.analytics.yahoo.com/p.pl?a=1000123xxxx&amp;js=no" width="1" height="1" alt="" /></div>
</noscript>
<!-- End of Yahoo! Web Analytics Code -->

In some cases, you may need to employ order ID tracking to avoid duplicate tracking of sales. The setOrderId function operates in a manner similar to the setAmount function and inflates a function defined by your shopping cart software.

Tracking multiple sales during the same visit

If you need to track multiple sales on the same page during the same visit, you must do the following:

  1. If your setOrderId function is dynamic, make sure each sale has a different OrderId.
  2. OR

  3. If your setOrderId function is fixed, you should change or remove the setOrderId function from the code for this page. Otherwise, the Sale action (01) will only be recorded one time - the first time it is completed.

When configuring sale actions, you also need to decide whether a sale action is unique. You can set the Sale Action (01) to Unique/Non-Unique from the Custom Actions Window (see Custom Actions Window.).

Configuring an action as Unique/Non-Unique affects only the reporting interface and not how data is collected.

  • If you configure a sale action as unique, then your reports will display a maximum of one sale action per visit.
  • If you configure a sale action as non-unique, then your reports may include more than one sale action per visit.

Example

  1. The first visit included 2 sale actions.
  2. The second visit included 1 sale action.
  3. The third visit included no sale actions.

The number of unique actions is 2 (an action for the first visit and an action for the second visit).

The total number of actions is 3.

If you configure the sale actions on the page with multiple sale actions as unique, then the reporting interface will display the number of unique sale actions in all the conversion reports. The only exception is the Conversion Summary report which displays the total number of actions and the number of unique actions.

If you configure the sale actions on the page with multiple sale actions as non-unique, then the reporting interface will display the total number of sale actions in all the conversion reports. This will artificially increase your conversion rate. Therefore, in order to avoid this, you should always configure the Sale actions on the page with multiple sale actions as unique.

Tracking multiple occurrences of the same action on a web page

If you need to track multiple occurrences of the same action on a web page, you must use a wrapper function. With this method, you can capture multiple orders/order IDs and their respective SKUs, amounts and any other information via custom fields.

Example: Multiple function calls

<!-- Yahoo! Web Analytics - All rights reserved -->
<script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
<script type="text/javascript">
 function captureSale(orderid, SKU, SKU Units, SKU Amounts) {
   var YWATracker = YWA.getTracker("1000123xxxx");
   YWATracker.setAction("01");
   YWATracker.setOrderId(orderid);
   YWATracker.setSKU(SKU);
   YWATracker.setUnits(SKU Units);
   YWATracker.setAmounts(SKU Amounts);
   YWATracker.setAmount(amount);
   YWATracker.submit_action();
 }

 //the relevant functions can be called as below

 captureSale('orderid 1', 'SKU 1', '1', 'USD10');
 captureSale('orderid 2', 'SKU 2', '2', 'USD30');
 captureSale('orderid 3', 'SKU 3', '3', 'USD25'); </script>

Tracking multiple actions/custom fields on the same web page

If you need to track multiple actions on the same web page, you can do so by passing on multiple actions and custom fields in one request.

Example

<!-- Yahoo! Web Analytics - All rights reserved -->
<script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
<script type="text/javascript">
 var YWATracker = YWA.getTracker("1000123xxxx");
 YWATracker.setAction("01;02;03;PENDING_SALE");
 YWATracker.setAmount("EUR99.95;;;USD10.90");
 YWATracker.setCF(17,"test1;test2");
 YWATracker.setCF(18,"cf2test1;cf2test2;cf2test3;cf2test4");
 YWATracker.submit();
</script>
<noscript>
<div><img src="http://a.analytics.yahoo.com/p.pl?a=1000123xxxx&amp;js=no" width="1" height="1" alt="" /></div>
</noscript>
<!-- End of Yahoo! Web Analytics Code -->

This request will result in the following output:

Record Action Amount cf01(Custom field 01) cf02(Custom field 02)
Record 1 01 EUR99.95 test1 cf2test1
Record 2 02 0 test2 cf2test2
Record 3 03 0 N/A cf2test3
Record 4 PENDING_SALE USD10.90 N/A cf2test4

You can use the following functions multiple times in one request:

  • Action
  • Amount
  • OrderId
  • Tax
  • Shipping
  • Discount
  • Action-based Custom Fields

Merchandising functions (e.g., Units) refer only to the very first action in the list. You can also track multiple actions on the same page using On Click actions. See Example 5 in Tracking "On Click" actions..

Tracking downloads and exit links

Downloads and exit links are automatically tracked. You can check reports on these metrics from Reports > Content > Downloads and Reports > Navigation > Exits.

However, if you want to track downloads and exit links as actions, you should change the tracking code as follows:

First, create a wrapper function:

<script language="Javascript">
function captureOnclick(actionnumber) {
var YWATracker = YWA.getTracker("1000123xxxx");
YWATracker.setAction(actionnumber);
YWATracker.submit_action();
}
</script>

Then connect an onclick event to the wrapper function and provide values, like this:

  • To track downloads as actions:

    <a href="http://same.domain/download.pdf"
    onclick="captureOnclick('06')";>

  • To track exit links as actions:

    <a href="http://points.to.somewhere.else/"
    onclick="captureOnclick('07')";>

Using the exitlink function

You can use the exitlink function to manually code exit links in a website that would not be captured by the normal running of the YWA JavaScript include code. Normally, the included file scans the browsers Document Object Model 'DOM', for URL references to other web sites outside of the current domain, (or domains if multiple domains are used and setup). However, this scan cannot check for custom setups (such as JavaScript being run from a button that will cause a 'goto new url' on another domain).

An example of a JavaScript wrapper function to use this function might look like this:

captureExitLink(exitlink) {
   var YWATracker = YWA.getTracker(123456789);
   YWATracker.exitlink(exitlink);
}

This wrapper function can be called by JavaScript, or with geturl(...) from Flash ActionScript.

If, for example, you want to track a custom coded JavaScript link to an external web site, you can add the 'exitlink' function to this custom YWA code. For example, you could declare a wrapper function in the header section of a file, like this:

<head>
function captureExitLink(exitlink) {
   var YWATracker = YWA.getTracker(123456789);
   YWATracker.exitlink(exitlink);
}
</head>

Then, within the relevant piece of custom JavaScript code, add a call to the custom JavaScript function such as in this example, where a function will cause a redirect to:

http://www.example_domain.com/example.page.html

function example_custom_js_goto_example()
{
// an example function that causes a jump to a new website
   ...custom js goto example code line...
   ...custom js goto example code line...
//
// ywa exit link tracking code using call to wrapper
   captureExitLink("http://www.example_domain.com/example.page.html");
//
   ...custom js goto example code line...
   ...custom js goto example code line...
// got new url js code
   window.location = "http://www.example_domain.com/example.page.html";
}

Tracking "On Click" actions

To track "on click" actions (including download and exitlinks), follow these steps:

  1. Create a wrapper function:

    <script language="Javascript">
     function captureOnclick(actionnumber) {
      var YWATracker = YWA.getTracker("1000123xxxx");
      YWATracker.setAction(actionnumber);
      YWATracker.submit_action();
     }
    </script>

  2. Connect an onclick event to the wrapper function and provide values:

    <a href="ref.htm" onclick="captureOnclick('01')";><img src="IMG_abc.jpg">

  3. The standard tracking code should be referred from any page containing the onclick action. This should be placed just before the closing BODY tag, as is standard practice.

    <!-- Yahoo! Web Analytics - All rights reserved -->
    <script type="text/javascript"
     src="http://d.yimg.com/mi/ywa.js"></script>
    <script type="text/javascript">
      var YWATracker = YWA.getTracker("1000123xxxx");
      YWATracker.setDocumentName("About us");
      YWATracker.submit();
    </script>
    <noscript>
    <div><img
    src="http://a.analytics.yahoo.com/p.pl?a=1000123xxxx&amp;js=no"
    width="1" height="1" alt="" /></div>
    </noscript>
    <!-- End of Yahoo! Web Analytics Code -->

  4. If you need to track additional information about the onClick action (i.e., the revenue provided by exit links, the SKU, SKU Units, SKU Cost, or other details about your custom functions: partner ID, retailer ID, etc. using additional custom fields), you can do so using a wrapper function. For example:

    <script language="Javascript">
     function captureSale( orderid, SKU, SKU_Units, SKU_Amounts, amount) {
      var YWATracker = YWA.getTracker("1000123xxxx");
      YWATracker.setAction("01");
      YWATracker.setOrderId(orderid);
      YWATracker.setSKU(SKU);
      YWATracker.setUnits(SKU_Units);
      YWATracker.setAmounts(SKU_Amounts);
      YWATracker.setAmount(amount);
      YWATracker.submit_action();
     }
    </script>

  5. Next, you need to call the onClick, which attaches the onClick to the wrapper function and provides values:

    <a href="ref.htm" onClick="captureSale('orderid 1', 'SKU 1', '1', 'USD10', 'USD10')";><img src="IMG_1964_1.jpg">

  6. The standard tracking code should be referred from any page containing the onclick action. This should be placed just before the closing BODY tag, as is standard practice.

    <!-- Yahoo! Web Analytics - All rights reserved -->
    <script type="text/javascript"
     src="http://d.yimg.com/mi/ywa.js"></script>
    <script type="text/javascript">
      var YWATracker = YWA.getTracker("1000123xxxx");
      YWATracker.setDocumentName("About us");
      YWATracker.submit();
    </script>
    <noscript>
    <div><img src="http://a.analytics.yahoo.com/p.pl?a=1000123xxxx&amp;js=no" width="1" height="1" alt="" /></div>
    </noscript>
    <!-- End of Yahoo! Web Analytics Code -->

Tracking revenue/multiple currency support

In order to capture the value of your purchases you need to set up the setAmount function in your Yahoo! Web Analytics tracking code, in combination with the Sale action (01) function.

The setAmount function can only be used in case of sale actions (see Tracking actions (conversion analysis).. The amount can either be entered as a constant figure (e.g., if you sell just one product) or as a function from your shopping cart.

You can only track the revenue of your online purchases in the currency in which they were made, which becomes your tracking currency. To set the tracking currency, you must place the appropriate three-letter currency abbreviation directly in front of the revenue amount, if constant, or, directly in front of your shopping cart revenue function.

See Available Currencies for a list of valid currencies.

When using a shopping cart, the value may be inflated into the tracking code dynamically. This means you need to be familiar with the custom scripting (e.g., PHP, JSP, ASP) employed by your shopping cart, to identify the correct function to insert in the Yahoo! Web Analytics tracking code.

The following example shows a sample script set up for a setAmount function, which is tracked in Danish Kroner (DKK). The actual name of your function will depend on your shopping cart. In the following example, both the setAction and the setAmount functions are activated.

Your setAmount function cannot accept parameters longer than 75 characters. You must not use non-ASCII characters in the function name. Do not use any of the following characters in the name:

'<>#&;:?-*~`´)(=%!".

These and other non-ASCII characters may interfere with the operation of the tracking code. (The leading slashes (//) must be removed to activate the function.) For example:

<script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
<script type="text/javascript">
 var YWATracker = YWA.getTracker("1000123xxxx");
  YWATracker.setAction("01");
  YWATracker.setAmount("<%currencysign%><%value%>");
  YWATracker.setDocumentGroup("Shopping Cart");
  YWATracker.setDocumentName("Payment Confirmation");
  YWATracker.submit();
</script>
<noscript>
 <div><img src="http://a.analytics.yahoo.com/p.pl?a=1000123xxxx&amp;js=no" width="1" height="1" alt= "" /></div>
</noscript>
<!-- End of Yahoo! Web Analytics Code -->

Even though your online purchases are registered in the tracking currency, your project (web site) default currency may be set to a different one (this is the currency that you set up when you set up the project, i.e., the project default reporting currency). Once you set up the project default reporting currency, all your campaign costs and sales figures except the ones in the Sales Details report are converted to this currency.

Yahoo! Web Analytics uses monthly average exchange rates to convert the campaign costs and sales figures into the project default reporting currency (e.g., your annual revenue displayed in your project default reporting currency is calculated by multiplying the monthly figures obtained in the tracking currency with the monthly average exchange rates).

Users with Administrator rights can override the project default reporting currency and select user defined reporting currencies for themselves and for other account users:

  1. To select a user defined reporting currency for your own account, click on Settings > Personal setup > Edit your user profile and select the currency of your choice.
  2. To select a user defined reporting currency for other account users, click on Settings Users & roles > Create and modify users and set their access rights, choose a user and select the preferred currency for this user.

Once you select a user defined reporting currency, all your reports except the Sales Details report will be displayed in your chosen currency. The figures displayed in the user defined reporting currency are calculated in the same way as the figures in the project default reporting currency, i.e., by multiplying the figures obtained in the tracking currency with the monthly average exchange rates.

The Sales Details report will always display the currency in which the purchases were originally made, i.e., the tracking currency.

Encrypted Revenue Collection

The Yahoo! Web Analytics revenue encryption feature is designed for clients who prefer not to pass the revenue figures in plain text through the Yahoo! Web Analytics tracking code. This technique will prevent robots, spiders and proxies from gathering competitive intelligence on your web site's revenue, margins, agreements with affiliates.

For more information, see the article on revenue encryption.

Tracking the order ID

To track the order ID of your online sales, you need to activate the setOrderId function. To identify the correct function to insert in the Yahoo! Web Analytics tracking code, you need to be familiar with the custom scripting (e.g., PHP, JSP, ASP) employed by your shopping cart. The setOrderId function only functions when used in conjunction with the setAmount function.

Tracking the order ID for a shopping site is mandatory, as this greatly improves the accuracy of monitoring your online sales, by ensuring there are no duplicate orders captured during a visit. The order ID appears in the Sales Details report.

If you want to use the Yahoo! Web Analytics API, the order ID is used as a reference.

The setOrderId is also used for troubleshooting the tracking of your online sales. The setOrderId is used as a reference point for our technical support team.

Your setOrderId function cannot accept parameters longer than 75 characters. You must not use non-ASCII characters in the function name. Do not use any of the following characters in the name:

'<>#&;:?-*~`´)(=%!".

These and other non-ASCII characters may interfere with the operation of the tracking code. (The leading slashes (//) must be removed to activate the function.) For example:

<!-- Yahoo! Web Analytics - All rights reserved -->
<script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
<script type="text/javascript">
 var YWATracker = YWA.getTracker("1000123xxxx");
  YWATracker.setAction("01");
  YWATracker.setAmount("USD99.95");
  YWATracker.setOrderId("1001");
  YWATracker.setDocumentGroup("Shopping Cart");
  YWATracker.setDocumentName("Payment Confirmation");
  YWATracker.submit();
</script>
<noscript>
 <div><img src="http://a.analytics.yahoo.com/p.pl?a=1000123xxxx&amp;js=no" width="1" height="1" alt="" /></div>
</noscript>
<!-- End of Yahoo! Web Analytics Code -->

Tracking internal search functionality

You can track the internal search functionality on your web site by using the functions setISK and setISR, which have to be inflated on the internal search results page. In order to track the number of internal search actions performed on your web site, you need to use the INTERNAL_SEARCH standard action. For example:

<!-- Yahoo! Web Analytics - All rights reserved -->
<script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
<script type="text/javascript">
 var YWATracker = YWA.getTracker("1000123xxxx");
  YWATracker.setAction("INTERNAL_SEARCH");
  YWATracker.setISK("office supplies");
  YWATracker.setISR("3");
  YWATracker.setDocumentGroup("Search");
  YWATracker.setDocumentName("Search Results");
  YWATracker.submit();
</script>
<noscript>
 <div><img src="http://a.analytics.yahoo.com/p.pl?a=1000123xxxx&amp;js=no" width="1" height="1" alt="" /></div>
</noscript>
<!-- End of Yahoo! Web Analytics Code -->

Once the new functions are configured, traffic data about internal search will be available in the standard Internal Search reports, available under Marketing > Internal Search.

Tracking custom fields

Custom fields enable you to add your specific reporting categories to the pre-defined reporting structures already available in the system and to obtain reports broken down by these categories. Using custom fields allows you to capture and report information that is not contained in standard reports but important and unique to your business.

While custom fields can be used in a variety of ways according to your business needs, these are some of the most common uses:

Enhancing E-commerce Analytics - mirror your online catalogue structure in your analytics reporting and record different price ranges and brands for your shopping site.

Increased Granularity to your Analytics - record additional information specific to your business' booking engine, e.g., travel destination, length of stay, day of the week, membership type, ticket type (economy or business class), payment by check and credit card payment, etc. for a travel site.

Capturing Customer Profile Information - track customer specific information, such as gender, position, relationship to your business, preferences, etc.

Yahoo! Web Analytics provides a set of out-of-the-box custom fields per project, which you can use to track information relevant to your business. Please note that no additional custom fields can be created, and you have complete control on how you manage these custom fields.

The out-of-the-box custom fields are divided by scope and data type. When deciding to use custom fields, you have to ensure you match the correct scope and data type to the information you would like to collect.

The table below lists the scope and data type of the custom fields provided.

Scope and data type for Custom Fields

Scope Data Type Maximum Number
Session String 4
Number/Date 0-2M (long) 2
Page View String 8
Number/Date 0-2M (long) 2
Action String 12
Number/Date 0-2M (long) 4
Campaign String 4
Number/Date 0-2M (long) 2
TOTAL Custom Fields 38

Custom Fields Scope

  1. Session - collect only one value per visit session. If multiple values are passed during one visit, only the last one will be tracked.
  2. Page View - collect multiple values per visit session, one per each page view.
  3. Action - collect data pertaining to the actions tracked on your website. Such Custom Fields must always be used in association with an action, which is tracked either on a specific page or on an onclick event.
  4. Campaign - collect data pertaining to the campaigns tracked on your website.

Data Types

  1. Number 0-2M (long) - 0 to 2 million
  2. Date ( mandatory format) - year-month-day, e.g., 2008-05-10. Please note that no other date formats are allowed.
  3. String - 250 characters limit

Below is an example of using custom fields for a hospitality site where you can track detailed booking information by capturing the package and room type booked, which is not possible via standard fields.

<!-- Yahoo! Web Analytics - All rights reserved -->
<script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
<script type="text/javascript">
 var YWATracker = YWA.getTracker("1000123xxxx");
  YWATracker.setAction("01");
  YWATracker.setAmount("CAD600.00");
  YWATracker.setOrderId("123xxx");
  YWATracker.setMemberId("test_user");
  YWATracker.setCF(7, "Bed and breakfast "); //(denotes Package Type)
  YWATracker.setCF(8, "Resorts"); //(denotes Property Type)
  YWATracker.setCF(9, "2006-12-10"); //(denotes Arrival Date)
  YWATracker.setCF(10, "10"); //(denotes Length of Stay)
  YWATracker.setCF(11, "Gold member"); //(denotes Membership Type)
  YWATracker.setDocumentGroup("Rates and Reservations");
  YWATracker.setDocumentName("Reservation confirmed");
  YWATracker.submit();
</script>
<!-- End of Yahoo! Web Analytics Code -->

The custom fields included in the example above have the following scope and data type:

Custom Field Scope Data Type
CF 1: Package Type Action String
CF 2: Property Type Page View String
CF 3: Arrival Date Action Date
CF 4: Length of Stay Action Number
CF 5: Membership Type Session String

Please note that the scope affects the way custom fields interact with other reporting dimensions, and that, depending on the custom fields scope, certain restrictions might be in place, e.g., campaign data can only be cross-referenced with page view data if a session dimension is also included.

Using custom fields

To use custom fields:

  1. See Settings > Custom Fields > Manage Custom Fields. The entire list of thirty-eight custom fields appears.
  2. Standard Custom Fields 2Select the custom field with the correct scope and data type by ticking the check-box next to a standard custom field, enter your chosen name, and click on the Update names button.
  3. Rename Custom Fields: Next, you need to implement the tagging for the custom field you have just created. To do so, you need to use the following page tags as methods of the YWATracker object:

YWATracker.setCF(11, "Gold Member"); //(denotes membership type for My Custom Field)
YWATracker.setCF(12, "Spring Sales"); //(denotes package type)

Once the data starts flowing in for the newly-created custom fields, you can use them as groups in the Custom Report Wizard to create customized reports.

Assigning custom fields to content groups

The custom fields settings page, available under Settings > Custom Fields > Manage Custom Fields, also allows you to assign custom fields to specific content groups, based on your chosen organization criteria.

To assign custom fields to content groups:

  • Click on the Assign Custom Fields to Specific Groups link at the bottom of the page.
  • This will display the Custom Fields Groups page, where you can create your own groups of custom fields, by entering the group label and a description. We provide you with four sample groups, as these are some of the most common functional areas for which custom fields are used to enhance tracking.

Create Custom Fields Group

You can also move custom fields from one group to the other by ticking the check boxes next to each custom field, selecting the destination group from the drop-down available and clicking on the Move button.

Move Custom Fields

When a custom field is no longer needed, then you can simply remove the custom field tags from your website and stop tracking the data. If you need to reuse custom fields, all you need to do is rename them and use the page tags to capture the information you need.

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