简体   繁体   English

php cURL或file_get_content对Google Analytics(分析)有影响

[英]php cURL or file_get_content affect on google analytics

Im wondering what affect loading an external page with php has on a sites analytics. 我想知道对网站分析使用php加载外部页面有什么影响。 If php is loading an external page, and not an actual browser, will the javascript that reports back to google analytics register the page load as a hit? 如果php加载的是外部页面,而不是实际的浏览器,则报告给Google Analytics(分析)的javascript是否会将页面加载注册为匹配?

Any JavaScript within the fetched page will not be run and therefore have no effect on analytics. 提取的页面中的任何JavaScript将不会运行,因此对分析没有影响。 The reason for this is that the fetched HTML page is never parsed in an actual browser, therefore, no JavaScript is executed. 这样做的原因是,在实际的浏览器中从未解析过提取的HTML页面,因此,不执行JavaScript。

Curl will not automatically download JavaScript files the HTML refers to. Curl不会自动下载HTML所引用的JavaScript文件。 So unless you explicitly download the Google Analytics JavaScript file, Google won't detect the Curl hit. 因此,除非您明确下载Google Analytics(分析)JavaScript文件,否则Google不会检测到Curl匹配。

Google offers a non-JavaScript method of tracking hits . Google提供了一种非JavaScript跟踪匹配的方法 It's intended for mobile sites, but may be repurposable for your needs. 它适用于移动网站,但可以根据您的需要进行调整。

You're misunderstanding how curl/file_get_contents work. 您误解了curl / file_get_contents的工作方式。 They're executed on the server, not on the client browser. 它们在服务器上执行,而不是在客户端浏览器上执行。 As far as Google and any regular user is concerned, they'll see the output of those calls, not the calls themselves. 就Google和任何普通用户而言,他们将看到这些呼叫的输出,而不是呼叫本身。

eg 例如

  1. client requests page from server A 客户端从服务器A请求页面
  2. server A requests page from server B 服务器A从服务器B请求页面
  3. server B replies with page data to server A 服务器B用页面数据答复服务器A
  4. server A accepts page data from server B 服务器A接受来自服务器B的页面数据
  5. server A sends page data to client 服务器A将页面数据发送到客户端

Assuming that all the requests work properly and don't issue any warnings/errors and there's no network glitches between server A and server B, then there is absolutely no way for the client to see exactly what server A's doing. 假设所有请求均正常工作,并且不发出任何警告/错误,并且服务器A和服务器B之间没有网络故障,那么客户端绝对没有办法确切地看到服务器A的运行情况。 It could be sending a local file. 它可能正在发送本地文件。 It could be executing a local script and send its output. 它可能正在执行本地脚本并发送其输出。 It could be offshoring the request to a server in India which does the hard work and then simply claims the credit for it, etc... 可能将请求转移到印度的服务器上,该服务器进行了艰苦的工作,然后仅要求功劳,等等。

Now, you CAN get the client to talk to server B directly. 现在,您可以使客户端直接与服务器B通信。 You could have server A spit out an HTML page that contains an iframe, image tag, script tag, css file, etc... that points to server B. But that's no longer transparent to the client - you're explicitly telling the client "hey, go over there for this content". 您可以让服务器A吐出一个HTML页面,该页面包含指向服务器B的iframe,图像标签,脚本标签,css文件等。但这对客户端不再透明-您明确地告诉客户端“嘿,去那里看看这个内容”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM