I am willing to use Google Analytics to track stats about usage of my Client/Server application (no Browser on the user computer!).
我愿意使用Google Analytics跟踪有关我的客户端/服务器应用程序使用情况的统计信息(用户计算机上没有浏览器!)。
So I guess if anyone ever tried to craft requests to __utm.gif from serverside code.
所以我想如果有人试图从服务器端代码处理__utm.gif的请求。
I have found some information on the request and relevant cookies at google website but there are no details on the cookies values passed in the "utmcc" variable.
我在谷歌网站上找到了有关请求和相关cookie的一些信息,但没有关于“utmcc”变量中传递的cookie值的详细信息。
I understand that I will not be able to "craft" some of the information which Analytics server derives from the request itself (one for all: the source IP address!). I can't generate requests from the Client computer.
我知道我无法“制作”分析服务器从请求本身派生的一些信息(一个对所有人:源IP地址!)。我无法从客户端计算机生成请求。
Does anyone have experience with this scenario? Any detailed information or resource? Any working code snippet (any language will do! :)?
有没有人有这种情况的经验?任何详细信息或资源?任何工作的代码片段(任何语言都可以!:)?
7 个解决方案
#1
I asked a similar question recently and somebody gave me a link, and I found another from the same site:
我最近问了一个类似的问题,有人给了我一个链接,我从同一个网站找到了另一个:
http://www.vdgraaf.info/wp-content/uploads/image-url-explained.txt
http://www.vdgraaf.info/wp-content/uploads/urchin-image.txt (included here)
http://www.vdgraaf.info/wp-content/uploads/image-url-explained.txt http://www.vdgraaf.info/wp-content/uploads/urchin-image.txt(此处包含)
Google's Analytics code is provided in the form of a JS library, ga.js. When a tracking function is called from this library, a request is made to a gif file on the GA servers at either of the following URLs:
Google的Google Analytics代码以JS库ga.js的形式提供。从此库调用跟踪功能时,会通过以下任一URL向GA服务器上的gif文件发出请求:
http://www.google-analytics.com/__utm.gif //from http pages https://ssl.google-analytics.com/__utm.gif //from https pages
The following are parameters that may be used in the request to provide GA with detailed information:
以下是在向GA提供详细信息的请求中可以使用的参数:
?utmwv=1 //Urchin/Analytics version
&utmn=634440486
&utmcs=UTF-8 //document encoding
&utmsr=1440x900 //screen resolution
&utmsc=32-bit //color depth
&utmul=nl //user language
&utmje=1 //java enabled
&utmfl=9.0%20%20r28 //flash
&utmcr=1 //carriage return
&utmdt=Linklove » The optimum keyword density //document title
&utmhn=www.vdgraaf.info //document hostname
&utmr=http://www.google.nl/search?q=seo+optimal+keyword+density&sourceid=navclient-ff&ie=UTF-8&rlz=1B3GGGL_nlNL210NL211 //referer URL
&utmp=/the-optimum-keyword-density.html //document page URL
&utmac=UA-320536-6 //Google Analytics account
&utmcc= //cookie settings
__utma=
21661308. //cookie number
1850772708. //number under 2147483647
1169320752. //time (20-01-2007) cookie first set
1172328503. //time (24-02-2007) cookie previous set
1172935717. //time (03-03-2007) today
3;+
__utmb=
21661308;+ //cookie number
__utmc=
21661308;+ //cookie number
__utmz=
21661308. //cookie number
1172936273. //time (03-03-2007) today
3.
2.
utmccn=(organic)| //utm_campaign
utmcsr=google| //utm_source
utmctr=seo+optimal+keyword+density| //utm_term
utmcmd=organic;+ //utm_medium
Remember that the &utmcc
values need to be URL encoded.
请记住,&utmcc值需要进行URL编码。
The links in this answer have proven to be a little unreliable, so here are some other resources that might be useful:
事实证明,这个答案中的链接有点不可靠,所以这里有一些其他可能有用的资源:
- Server Side Google Analytics for PHP
- GIF URL Parameters (Google's Troubleshooting Page)
服务器端Google Analytics for PHP
GIF网址参数(Google的疑难解答页面)
#2
you might want to give http://code.google.com/p/serversidegoogleanalytics/ a try. its working for me (in combination with zend framework for the http request).
您可以尝试http://code.google.com/p/serversidegoogleanalytics/。它为我工作(与http请求的zend框架结合)。
#3
Years after this question was posted a new method emerged.
这个问题发布多年后,出现了一种新的方法。
Google Analytics now has a measurement protocol. You should favor this because it's supported and documented, unlike the other solutions that try to emulate a protocol that is not fully supported.
Google Analytics现在有一个测量协议。您应该支持这一点,因为它支持并记录在案,与尝试模拟不完全支持的协议的其他解决方案不同。
In order to use it you need to create a new Web Property that is Universal Analytics enabled.
要使用它,您需要创建一个启用了Universal Analytics的新Web属性。
Full details about the Measurement Protocol in the developer docs.
有关开发人员文档中的度量协议的完整详细信息。
#4
From inspecting my cookies in firefox for a site that is a known user of google analytics I see it stores 3 values (all 3 start with 2 underscores):
通过在Firefox中检查我的cookie以获得谷歌分析的已知用户的网站,我看到它存储了3个值(所有3个值都以2个下划线开头):
- __utmc - 9 digit integer (probably)
- __utma - very long integer with periods thrown in (starts with 9 digits above)
- __utmz - long string period seperated (starts with 9 digits from utmc)
__utmc - 9位整数(可能)
__utma - 带有句点的非常长的整数(以9位数开头)
__utmz - 长字符串句点分隔(从utmc开始的9位数字)
My guess is utmc is your tracking session id.
我猜是utmc是你的跟踪会话ID。
#5
As an alternative, if you are on AWS, you can use custom metrics in CloudWatch, very easy to use but you need to take care of every thing, depending on what you want to achieve with "server-side" metrics it may be exactly what you need.
作为替代方案,如果您在AWS上,您可以在CloudWatch中使用自定义指标,非常易于使用,但您需要处理所有事情,具体取决于您希望通过“服务器端”指标实现的目标,它可能正是如此你需要什么。
#6
Interesting requirement...
Your best bet would probably be to attempt to reverse engineer the google analytics javascript a little...
你最好的选择可能是尝试对谷歌分析javascript进行一些反向工程...
With firefox, and firebug, go to a web site that uses google analytics then open firebug and look at the GET that is submitted to google analytics. If you can then create an HttpRequest with those same parameters and headers you should be able to fool google analytics into thinking you're coming from a web page.
使用firefox和firebug,转到使用谷歌分析的网站,然后打开firebug并查看提交给谷歌分析的GET。如果您可以使用相同的参数和标题创建HttpRequest,那么您应该能够欺骗Google Analytics以为您来自网页。
#7
Embed the script in an HTML page with variable placeholders for page title and such, then load the page in an embedded IE instance server side. The GA script allows you to track page events by specifying parameters to the main tracking function, so all you'd have to do is keep the template HTML page in memory, replace the placeholders, and load the page in the embedded IE instance. The IE instance would parse and execute the javascript like it were a normal page and bingo, you've got your tracking.
将脚本嵌入到具有页面标题等可变占位符的HTML页面中,然后在嵌入式IE实例服务器端加载页面。 GA脚本允许您通过为主跟踪功能指定参数来跟踪页面事件,因此您所要做的就是将模板HTML页面保留在内存中,替换占位符,并在嵌入式IE实例中加载页面。 IE实例将解析并执行javascript,就像它是普通页面和宾果游戏一样,你有跟踪。
This is theoretical, of course, and not tested.
当然,这是理论上的,没有经过测试。
#1
I asked a similar question recently and somebody gave me a link, and I found another from the same site:
我最近问了一个类似的问题,有人给了我一个链接,我从同一个网站找到了另一个:
http://www.vdgraaf.info/wp-content/uploads/image-url-explained.txt
http://www.vdgraaf.info/wp-content/uploads/urchin-image.txt (included here)
http://www.vdgraaf.info/wp-content/uploads/image-url-explained.txt http://www.vdgraaf.info/wp-content/uploads/urchin-image.txt(此处包含)
Google's Analytics code is provided in the form of a JS library, ga.js. When a tracking function is called from this library, a request is made to a gif file on the GA servers at either of the following URLs:
Google的Google Analytics代码以JS库ga.js的形式提供。从此库调用跟踪功能时,会通过以下任一URL向GA服务器上的gif文件发出请求:
http://www.google-analytics.com/__utm.gif //from http pages https://ssl.google-analytics.com/__utm.gif //from https pages
The following are parameters that may be used in the request to provide GA with detailed information:
以下是在向GA提供详细信息的请求中可以使用的参数:
?utmwv=1 //Urchin/Analytics version
&utmn=634440486
&utmcs=UTF-8 //document encoding
&utmsr=1440x900 //screen resolution
&utmsc=32-bit //color depth
&utmul=nl //user language
&utmje=1 //java enabled
&utmfl=9.0%20%20r28 //flash
&utmcr=1 //carriage return
&utmdt=Linklove » The optimum keyword density //document title
&utmhn=www.vdgraaf.info //document hostname
&utmr=http://www.google.nl/search?q=seo+optimal+keyword+density&sourceid=navclient-ff&ie=UTF-8&rlz=1B3GGGL_nlNL210NL211 //referer URL
&utmp=/the-optimum-keyword-density.html //document page URL
&utmac=UA-320536-6 //Google Analytics account
&utmcc= //cookie settings
__utma=
21661308. //cookie number
1850772708. //number under 2147483647
1169320752. //time (20-01-2007) cookie first set
1172328503. //time (24-02-2007) cookie previous set
1172935717. //time (03-03-2007) today
3;+
__utmb=
21661308;+ //cookie number
__utmc=
21661308;+ //cookie number
__utmz=
21661308. //cookie number
1172936273. //time (03-03-2007) today
3.
2.
utmccn=(organic)| //utm_campaign
utmcsr=google| //utm_source
utmctr=seo+optimal+keyword+density| //utm_term
utmcmd=organic;+ //utm_medium
Remember that the &utmcc
values need to be URL encoded.
请记住,&utmcc值需要进行URL编码。
The links in this answer have proven to be a little unreliable, so here are some other resources that might be useful:
事实证明,这个答案中的链接有点不可靠,所以这里有一些其他可能有用的资源:
- Server Side Google Analytics for PHP
- GIF URL Parameters (Google's Troubleshooting Page)
服务器端Google Analytics for PHP
GIF网址参数(Google的疑难解答页面)
#2
you might want to give http://code.google.com/p/serversidegoogleanalytics/ a try. its working for me (in combination with zend framework for the http request).
您可以尝试http://code.google.com/p/serversidegoogleanalytics/。它为我工作(与http请求的zend框架结合)。
#3
Years after this question was posted a new method emerged.
这个问题发布多年后,出现了一种新的方法。
Google Analytics now has a measurement protocol. You should favor this because it's supported and documented, unlike the other solutions that try to emulate a protocol that is not fully supported.
Google Analytics现在有一个测量协议。您应该支持这一点,因为它支持并记录在案,与尝试模拟不完全支持的协议的其他解决方案不同。
In order to use it you need to create a new Web Property that is Universal Analytics enabled.
要使用它,您需要创建一个启用了Universal Analytics的新Web属性。
Full details about the Measurement Protocol in the developer docs.
有关开发人员文档中的度量协议的完整详细信息。
#4
From inspecting my cookies in firefox for a site that is a known user of google analytics I see it stores 3 values (all 3 start with 2 underscores):
通过在Firefox中检查我的cookie以获得谷歌分析的已知用户的网站,我看到它存储了3个值(所有3个值都以2个下划线开头):
- __utmc - 9 digit integer (probably)
- __utma - very long integer with periods thrown in (starts with 9 digits above)
- __utmz - long string period seperated (starts with 9 digits from utmc)
__utmc - 9位整数(可能)
__utma - 带有句点的非常长的整数(以9位数开头)
__utmz - 长字符串句点分隔(从utmc开始的9位数字)
My guess is utmc is your tracking session id.
我猜是utmc是你的跟踪会话ID。
#5
As an alternative, if you are on AWS, you can use custom metrics in CloudWatch, very easy to use but you need to take care of every thing, depending on what you want to achieve with "server-side" metrics it may be exactly what you need.
作为替代方案,如果您在AWS上,您可以在CloudWatch中使用自定义指标,非常易于使用,但您需要处理所有事情,具体取决于您希望通过“服务器端”指标实现的目标,它可能正是如此你需要什么。
#6
Interesting requirement...
Your best bet would probably be to attempt to reverse engineer the google analytics javascript a little...
你最好的选择可能是尝试对谷歌分析javascript进行一些反向工程...
With firefox, and firebug, go to a web site that uses google analytics then open firebug and look at the GET that is submitted to google analytics. If you can then create an HttpRequest with those same parameters and headers you should be able to fool google analytics into thinking you're coming from a web page.
使用firefox和firebug,转到使用谷歌分析的网站,然后打开firebug并查看提交给谷歌分析的GET。如果您可以使用相同的参数和标题创建HttpRequest,那么您应该能够欺骗Google Analytics以为您来自网页。
#7
Embed the script in an HTML page with variable placeholders for page title and such, then load the page in an embedded IE instance server side. The GA script allows you to track page events by specifying parameters to the main tracking function, so all you'd have to do is keep the template HTML page in memory, replace the placeholders, and load the page in the embedded IE instance. The IE instance would parse and execute the javascript like it were a normal page and bingo, you've got your tracking.
将脚本嵌入到具有页面标题等可变占位符的HTML页面中,然后在嵌入式IE实例服务器端加载页面。 GA脚本允许您通过为主跟踪功能指定参数来跟踪页面事件,因此您所要做的就是将模板HTML页面保留在内存中,替换占位符,并在嵌入式IE实例中加载页面。 IE实例将解析并执行javascript,就像它是普通页面和宾果游戏一样,你有跟踪。
This is theoretical, of course, and not tested.
当然,这是理论上的,没有经过测试。