开发者

Is there a way to send tracking info to Google Analytics from PHP?

I have a PHP code that will return a image. the link is given to 3rd party. so, i need to keep track wh开发者_Go百科ere the php request coming from. Because the PHP only return the image, I cannot use the Javascript code for Google analytics. I know that I can get the information from the access.log, but i think I can't dump the access.log to GA for analyzing, right? so, is there a way that I can do in PHP (e.g. sending a CURL ), send somethig to Google Analytics for tracking?


In practice, what GA will do is to issue a HTTP GET for a 1-pixel sized GIF image, in which the GET parameters will contain the information to store in GA servers. If you figure out the format of the GET request, you may be able to store the information you want to. You can use any net monitoring tool or browser plugin of similar functionality (like Firebug, etc) to understand the parameters that are passed to GA servers. These are nowhere to be found in GA documentation, although the architecture of this process is.

In practice, what you're trying to accomplish is the same as enabling GA for a javascript-disabled client. By limiting the information you can provide to GA to the one that the server obtains from browser requests you won't be able to get some detailed info such as the screen resolution, etc. On the bright side, the information that won't be accessible by this method is actually very little (and probably of little significance) and the web is full of resources on using GA for the javascript-impaired that you can use as example, eventually adapting to PHP and to your particular case.


Galvanize is an open source project that does what Miguel is describing. This is the blog post introducing Galvanize.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜