将分析数据发送到不同的域,而不作出响应 [英] Send analytic data to different domain without response
问题描述
前提条件
-
我拥有
mysite.com
>
问题
-
如何将分析数据从
othersite.com
发送到mysite.com
?
-
预期:
othersite.com
客户端 - >mysite .com
server -
未预期:
othersite.com
othersite.com
伺服器 - >mysite.com
伺服器 -
其原理似乎与
Google Analytics
类似,但我不知道确切的原则
< -
- p>如果我拥有
othersite.com
? -
如何发送分析数据反应?
- 例如,
Heap Analytics
发送无响应的分析数据
- 例如,
我知道的网络分析工具是通过动态创建一个图像源,指向跟踪服务器,并附加用户数据(如每个用户的唯一ID)作为图像源的URL参数的跨域传输数据。
除了通过图像源发送的所有内容之外,您还将从http请求(ip地址,用户代理等)获取数据。
对于一个简单的系统,您可以创建一个脚本,在返回一个(1像素透明)图像之前,将url和http数据直接存储到数据库。如果你想要一些可伸缩的东西,你可能会将数据写入日志文件,并使用一些目前被大量使用的大数据技术(hadoop,hive等)来处理。
在任何情况下,解耦数据收集和处理是一个好主意,您可以更轻松地将跟踪应用程序的组件切换为改进的版本,而不会影响其他部分
发送图像是可靠的,因为它适用于任何浏览器,而不启用任何特殊配置(cors等)。
如果其他域名是您的域名,您可以
- 通过ajax跟踪
- 直接读取服务器日志或将其导入您选择的仪表板
如果您无法实际访问服务器,但所有者允许您配置其名称服务器,则可以通过跟踪脚本,然后将其重定向到所请求的页面。
我看了一下Heap Analytics。他们像其他工具一样发送图片请求:
https://heapanalytics.com/h?a=236035469&u = 4184751431615606& v = 2274541888& s = 3701858993& b = web& z = 2& h =%2F& d = heapanalytics.com& t = Heap%20%7C%20Mobile%20and%20Web%20A分析& 3A%2F%2Fwww.google.de%2F& k = Screen%20Dimensions& k = 1050%20x%201680& k = Window%20Width& k = 1973& k = Window%20Height& k = 1039& tm = 1432884624859
这会返回http 200响应代码和1像素透明图像,因此看起来不像没有反应毕竟。
Precondition
I own
mysite.com
I do not own
othersite.com
, but I can embed javascript code there
Question
How to send analytic data from
othersite.com
tomysite.com
?Expected :
othersite.com
client ->mysite.com
serverNot expected :
othersite.com
client ->othersite.com
server ->mysite.com
serverIts principle seems like to be similar with
Google Analytics
, but I don't know the exact principleI know that it couldn't be done by ajax due to cross-domain problem
How does it change if I own
othersite.com
?How to send analytic data without response ?
- For example,
Heap Analytics
send analytic data without response
- For example,
The default scenarion with Google Analytics (and all other Web Analytics Tools I know) is to transfer data across domains by dynamically creating an image with a source that points to the tracking server and appending user data (like unique id per user) as url parameters to the image source.
Apart from everything you send via the image source you will also get the data from the http request (ip adress, user agent etc).
For a simple system you could create a script that stores the url and http data directly to a database before it returns a (1 pixel transparent) image. If you want something scalable you would probably write the data to a log file and use some currently hyped big data technology (hadoop, hive etc) for processing.
Decoupling data collection and processing is a good idea in any case, in that allows you to more easily switch components of your tracking application for improved versions without affecting the other parts of the system.
Sending an image is reliable inasfar as it works for any browser without enabling any special configurations (cors etc). It is however rather easily blocked (users just have to block pixel images or redirect calls to your server via their host file).
If the other domain was yours you could
- track via ajax
- read the server logs directly or pipe them to a dashboard of your choice
If you do not have access physically to the server but the owners let you configure their name servers you could run all incoming http requests through your tracking script before redirecting them to the requested page.
I took a look at Heap Analytics. They send an image request just like the other tools:
https://heapanalytics.com/h?a=236035469&u=4184751431615606&v=2274541888&s=3701858993&b=web&z=2&h=%2F&d=heapanalytics.com&t=Heap%20%7C%20Mobile%20and%20Web%20Analytics&r=https%3A%2F%2Fwww.google.de%2F&k=Screen%20Dimensions&k=1050%20x%201680&k=Window%20Width&k=1973&k=Window%20Height&k=1039&tm=1432884624859
which returns http 200 response code and an 1 pixel transparent image, so it does not look like they "track without response" after all.
这篇关于将分析数据发送到不同的域,而不作出响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!