Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

How do I implement pixel tracking?

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.

This article explains how to use pixel tracking with Yahoo! Web Analytics.

Why Use Pixel Tracking?

Within the standard implementation of Yahoo! Web Analytics JavaScript tracking code is added to each page. This tracking code must be placed at the bottom of each web page, outside of any tables, before the closing BODY tag. However, in certain circumstances (e.g., if the tracking code can only be placed at the top of a page, due to CMS restrictions, or for mobile tracking), the JavaScript tracking code can be replaced with pixel tracking.

This document illustrates how the pixel tracking mechanism can be used for tracking with Yahoo! Web Analytics.

Implementing Pixel Tracking

Pixel tracking is accomplished by constructing 1x1 pixel fetch commands that have additional query string parameters appended in the form of ‘PARAMETER NAME’ = ‘PARAMETER VALUE’ pairs that in turn send tracking code data to Yahoo! Web Analytics.

By default, a page view in Yahoo! Web Analytics is created with each data transmission to Yahoo! Web Analytics. If you would rather record an action than the default page view, users can append the pair ‘ca=1’.

The syntax for this pixel tracking code will generally look something like this:

<img src = "http://a.analytics.yahoo.com/p.pl?a=1001234567&[PARAM_NAME1=PARAM1_VALUE]
&[PARAM_NAME2= PARAM2_VALUE] &[PARAM_NAME3= PARAM3_VALUE] &[PARAM_NAME4= PARAM4_VALUE]
...etc..etc..." width="1" height="1">

The examples below illustrate the usage of an <img> tag in an HTML page to capture visitor data.

Example Code Using <img> Tag for Pixel Tracking

Capturing a Page View with Page Name and Document Group

To capture a page view with page name and document group, use the following:

<img src="http://a.analytics.yahoo.com/p.pl?a=10001234567
&b=Sony+PS3+Review&c=Product+Reviews " width="1" height="1">

This is equivalent to the JavaScript code:

<script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
<script type="text/javascript">
var YWATracker = YWA.getTracker("10001234567");
YWATracker.setDocumentName("Sony PS3 Review ");
YWATracker.setDocumentGroup("Product Reviews ");
YWATracker.submit();
</script>

Capturing a Product View Action

To capture a product view action (without recording a page view) for product id SKU991919:

<img src="http://a.analytics.yahoo.com/p.pl?a=10001234567&ca=1&x=PRODUCT_VIEW&p=SKU991919" width="1" height="1">

This is equivalent to the JavaScript code:

<script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
<script type="text/javascript">
var YWATracker = YWA.getTracker("10001234567");
YWATracker.setSKU("SKU991919");
YWATracker.setAction("PRODUCT VIEW");
YWATracker.submit_action();
</script>

Capturing a Page View and Video View Action

To capture a page view with a video view action (with the video title captured as page view associated custom field number 7 and action 04 configured in Settings as “Video View”):

<img src="http://a.analytics.yahoo.com/p.pl?a=10001234567&x=04&cf07=Skateboarding+Dog" width="1" height="1">

This is equivalent to the JavaScript code:

<script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
<script type="text/javascript">
var YWATracker = YWA.getTracker("10001234567");
YWATracker.setCF(7,"Skateboarding Dog");
YWATracker.setAction("04");
YWATracker.submit();
</script>

Capturing a “Pause Video” Action

To capture an action of pausing a video (with the video title captured as an action associated custom field number 17 and action 07 is configured in Settings as a meaning of “Video Pause”):

<img src="http://a.analytics.yahoo.com/p.pl?a=10001234567&ca=1&x=07&cf17=Skateboarding+Dog" width="1" height="1">

This is equivalent to the JavaScript code:

<script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
<script type="text/javascript">
var YWATracker = YWA.getTracker("10001234567");
YWATracker.setCF(17,"Skateboarding Dog");
YWATracker.setAction("07");
YWATracker.submit_action();
</script>

Capturing a Page View with Page Name & Document for a Specific URL

To capture a page view with page name, document group from a specified URL of http://www.mysite.com/example.html, use the following code:

<img src="http://a.analytics.yahoo.com/p.pl?a=10001234567 f=http%3A%2F%2Fwww.mysite.com%2Fexample.html&b=Sony+PS3+Review&c=Product+Reviews " width="1" height="1">

This is equivalent (in this specified URL example case) to the JavaScript code on a web page located at http://www.mysite.com/example.html:

<script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
<script type="text/javascript">
var YWATracker = YWA.getTracker("10001234567");
YWATracker.setDocumentName("Sony PS3 Review ");
YWATracker.setDocumentGroup("Product Reviews ");
YWATracker.submit();
</script>

The value PARAMETER NAME ‘a’ is the Yahoo! Web Analytics project ID (which typically starts with 1000). The name & value pairs are additional key value pairs you can provide in the tag. The possible keys are defined below:

Parameter Name Description Equivalent JavaScript Function Sample Value
a Yahoo! Web Analytics project ID. Provided to you during setup. -- a=10001234567
b Name of the page. Equivalent to JS function. setDocumentName b=Home+Page
c Document group of the page. setDocumentGroup c=Help+Pages
ca If this parameter is set to 1, the page view will not be recorded, just the action itself. submitAction ca=1
cq -- setCmpQuery cq=ref%3Dgoogle%26kw%3Dkeyword
e Referrer to the current page. If blank, no referrer will be recorded. setReferrer e=http%3A%2F%2Fwww.google.com%2F
f Current page url. This is captured automatically (from HTTP header information) but it’s recommended to pass on as in certain cases proxy servers rewrite the HTTP header and this information gets lost. setUrl f=http%3A%2F%2Fwww.mysite.com%2F example.html
xa Parameters to support e-commerce transactions. Capture the order id, amount, tax, shipping, discount, SKU etc., for reporting. setAmount oa=USD99.95
oc setOrderId oc=A100009999
xt setTax xt=USD99.95
xs setShipping xs=USD99.95
xd setDiscount xd=USD99.95
p setSKU p=SKU001%3BSKU002
q setUnits q=1%3B2
r setAmounts r=USD99.95%3BUSD45.25
x Event Tracking. Events are configured in settings and event numbers are used as values. setAction x=01
(for sale action)
cfN
(where N = the number of the custom field)
Capture custom fields. They have to be initially configured under settings. setCF cf3=62
cf19=abcdefgh
h Java support. Captured automatically by the JavaScript code. h=Y
j Screen resolution. j=1680×1050
k Color depth. k=16
l Cookie support. l=true
n Time zone (can set time zone in the event that no Browser Time is being recorded). n=-2
flv Flash plug-in version. flv=WIN+9%2C0%2C115%2C0
sid Proxy for session id to tie different events together. Not required if you are using <img> tag. In JavaScript, this is achieved by setting up session id in a cookie in the client browser. sid=86CF81D1D9E78C35EDB3D6372A259A
fn Name of the file being downloaded. Download should be captured as an action. -- fn=Details.pdf
m -- setMemberId m=Alan34

Pixel Tracking and Yahoo! Web Analytic Reports

While using the traditional JavaScript based tracking code captures the data reported in the wide array of Yahoo! Web Analytics reports, using the above techniques populate data for only a subset of reports.

The following reports will not work using just the <img> tag with cookie enabled in the browser (as opposed to pages that use the JavaScript tracking code):

  1. Top Browsing Hour Report
  2. Geography > Time Zone
  3. Exits > Exit Link by full URL
    • Exit Link by domain
    • Pages with Exit Links > By Title
    • Pages with Exit Links > By URL
    • Pages with Exit Links > By Document Group
  4. System > JavaScript Support
    • JavaScript Version
  5. Demographics > Age & Gender reports
  6. Interest Groups

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