---
title: "Web Analytics工具domodomain的B/S交互实现机制分析"
author: "java.guru"
date: "2007-10-20T23:27:30Z"
tags: []
slug: "web-analytics-domodomain-b-s"
draft: false
lastmod: "2007-10-20T23:27:30Z"
id: 133873
url: "https://java-guru.iteye.com/blog/133873"
---

最近在[YMU网络](http://youmonitor.us/)的开发过程中试用了[domodomain](http://www.domodomain.com/)提供的Web Analytics服务，发现其分析功能很强，能很精确地定位访问来源，而且能展现一个用户的页面访问顺序，界面也挺好用（见截图）。但是其服务不是免费的，价格还挺贵的，不过你可以免费试用一个月哦！  
![](http://java-guru.iteye.com/upload/picture/pic/5761/40b0b7a5-c32d-4805-a27c-f6e60ea7ea30.jpg)

```
在使用domodomain及Google Analytics这两种Web Analytics工具过程中，顺便分析了一下，发现两者在Browser和Server间交互的实现机制是基本一致的。
```

```
<o:p> </o:p>
```

```
下面以domodomain为例说明实现机制，其中目标监测网页：http://youmonitor.us/index.shtml；
而referrer为http://java-guru.iteye.com/blog/133803。
```

```
<o:p> </o:p>
```

```
1. 首先需要在index.shtml的下增加以下js代码：<o:p></o:p>
```

```
<script src="http://www.domodomain.com/DomoDomain/Sensor/DDSense.aspx?id=73083351-f537<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="True" hasspace="False" sourcevalue="45" unitname="C">-45c</st1:chmetcnv>0-abd3<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="True" hasspace="False" sourcevalue="88" unitname="F">-88f</st1:chmetcnv>171b<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="24" unitname="a">24a</st1:chmetcnv>85" 
      type="text/javascript" language="javascript">script><o:p></o:p>
```

&lt;o:p&gt; &lt;/o:p&gt;

其中id是申请服务时分配的标识。

&lt;o:p&gt; &lt;/o:p&gt;

**2. 生成base page&lt;o:p&gt;&lt;/o:p&gt;**

当index.shtml被访问时，js代码(http://www.domodomain.com/DomoDomain/Sensor/DDSense.aspx?id=73083351-f537&lt;st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="True" hasspace="False" sourcevalue="45" unitname="C"&gt;-45c&lt;/st1:chmetcnv&gt;0-abd3&lt;st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="True" hasspace="False" sourcevalue="88" unitname="F"&gt;-88f&lt;/st1:chmetcnv&gt;171b&lt;st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="24" unitname="a"&gt;24a&lt;/st1:chmetcnv&gt;85)被下载、执行，并返回如下结果：

&lt;o:p&gt; &lt;/o:p&gt;

```
function DD()<o:p></o:p>
```

```
{<o:p></o:p>
```

```
var n = new Date();<o:p></o:p>
```

```
var sTimezone = n.getTimezoneOffset();<o:p></o:p>
```

```
var sWidth=screen.width;<o:p></o:p>
```

```
var sHeight=screen.height;<o:p></o:p>
```

```
var sApp=navigator.appName;<o:p></o:p>
```

```
var sReferrer=""+escape(document.referrer);<o:p></o:p>
```

```
var sLocation=""+escape(document.URL);<o:p></o:p>
```

```
var sColor=0;<o:p></o:p>
```

```
if (sApp!="Netscape") sColor=screen.colorDepth;<o:p></o:p>
```

```
else sColor=screen.pixelDepth;<o:p></o:p>
```

```
document.write("/DDWebSensor.aspx?id=73083351-f537<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="True" hasspace="False" sourcevalue="45" unitname="C">-45c</st1:chmetcnv>0-abd3<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="True" hasspace="False" sourcevalue="88" unitname="F">-88f</st1:chmetcnv>171b<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="24" unitname="a">24a</st1:chmetcnv>85&keywords="+<o:p></o:p>
```

```
    "&rnd="+Math.random()+<o:p></o:p>
```

```
    "&location="+sLocation+<o:p></o:p>
```

```
    "&referrer="+sReferrer+<o:p></o:p>
```

```
    "&color="+sColor+<o:p></o:p>
```

```
    "&width="+sWidth+<o:p></o:p>
```

```
    "&height="+sHeight+<o:p></o:p>
```

```
    "&timezone="+sTimezone+<o:p></o:p>
```

```
    "\" width=\"1\" height=\"1\" >"); <o:p></o:p>
```

```
}<o:p></o:p>
```

```
function DD2(){<o:p></o:p>
```

```
var n = new Date();<o:p></o:p>
```

```
var sTimezone = n.getTimezoneOffset();<o:p></o:p>
```

```
var sWidth=screen.width;<o:p></o:p>
```

```
var sHeight=screen.height;<o:p></o:p>
```

```
var sApp=navigator.appName;<o:p></o:p>
```

```
var sReferrer=""+escape(document.referrer);<o:p></o:p>
```

```
var sLocation=""+escape(document.URL);<o:p></o:p>
```

```
var sColor=0;<o:p></o:p>
```

```
if (sApp!="Netscape") sColor=screen.colorDepth;<o:p></o:p>
```

```
else sColor=screen.pixelDepth;<o:p></o:p>
```

```

document.write(
"
-45c0-abd3<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="True" hasspace="False" sourcevalue="88" unitname="F">-88f</st1:chmetcnv>171b<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="24" unitname="a">24a</st1:chmetcnv>85<o:p></o:p>
```

```
&keywords="+<o:p></o:p>
```

```
    "&rnd="+Math.random()+<o:p></o:p>
```

```
    "&location="+sLocation+<o:p></o:p>
```

```
    "&referrer="+sReferrer+<o:p></o:p>
```

```
    "&color="+sColor+<o:p></o:p>
```

```
    "&width="+sWidth+<o:p></o:p>
```

```
    "&height="+sHeight+<o:p></o:p>
```

```
    "&timezone="+sTimezone+<o:p></o:p>
```

```
    "\" width=\"1\" height=\"1\" >"); <o:p></o:p>
```

```
}<o:p></o:p>
```

```
DD();<o:p></o:p>
```

```
<o:p> </o:p>
```

```
此时DD()函数会被进一步执行，DD函数会生成对象。
```

```
<o:p></o:p>
```

```
3. load 对象<o:p></o:p>
```

```
Base page装载完毕，浏览器会load其他内嵌对象，domodomain生成的也会被获取，此时其src为访问来源记录url：
```

```
http://www.domodomain.com/Domodomain/Sensor/DDWebSensor.aspx?id=73083351-f537<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="True" hasspace="False" sourcevalue="45" unitname="C">-45c</st1:chmetcnv>0-abd3<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="True" hasspace="False" sourcevalue="88" unitname="F">-88f</st1:chmetcnv>171b<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="24" unitname="a">24a</st1:chmetcnv>85&keywords=    &rnd=0.9592277737313195&location=http://youmonitor.us/&referrer= http://java-guru.iteye.com/blog/133803&color=32&width=1152&height=864&timezone=-480<o:p></o:p>
```

&lt;o:p&gt; &lt;/o:p&gt;

*该**URL**发送目标网页、访问来源、访问机器的分辨率和时区等信息给服务器，并返回以下内容：*

```
<!DOCTYPE html PUBLIC "-//W<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="3" unitname="C">3C</st1:chmetcnv>//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional<o:p></o:p>
```

```
.dtd"><o:p></o:p>
```

```
<html xmlns="http://www.w3.org/1999/xhtml" ><o:p></o:p>
```

```
<head><title><o:p></o:p>
```

```
    Untitled Page<o:p></o:p>
```

```
</title></head><o:p></o:p>
```

```
<body><o:p></o:p>
```

```
    <form name="form1" method="post" action="DDWebSensor.aspx?id=73083351-f537<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="True" hasspace="False" sourcevalue="45" unitname="C">-45c</st1:chmetcnv>0-abd3<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="True" hasspace="False" sourcevalue="88" unitname="F">-88f</st1:chmetcnv>171b<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="24" unitname="a">24a</st1:chmetcnv>85<o:p></o:p>
```

```
&amp;keywords=&amp;rnd=0.9592277737313195&amp;location=http%<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="3" unitname="a">3a</st1:chmetcnv>%<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="2" unitname="F">2f</st1:chmetcnv>%2fyoumonitor.us%<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="2" unitname="F">2f</st1:chmetcnv>&amp;referrer=http<o:p></o:p>
```

```
%<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="3" unitname="a">3a</st1:chmetcnv>%<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="2" unitname="F">2f</st1:chmetcnv>%2fjava-guru.iteye.com%2fblog%<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="2" unitname="F">2f</st1:chmetcnv>133803&amp;color=32&amp;width=1152&amp;height=864&amp;timezone<o:p></o:p>
```

```
=-480" id="form1"><o:p></o:p>
```

```
<div><o:p></o:p>
```

```
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNzgzNDMwNTMzZGS0W7hZuJUQAI4YTS7CaLL9MJYR<st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="9" unitname="g">9g</st1:chmetcnv><o:p></o:p>
```

```
==" /><o:p></o:p>
```

```
</div><o:p></o:p>
```

```
    <div><o:p></o:p>
```

```
    </div><o:p></o:p>
```

```
    </form><o:p></o:p>
```

```
</body><o:p></o:p>
```

```
</html><o:p></o:p>
```

```
<o:p></o:p>
```

```
<o:p></o:p>
```