Server-side Google Analytics Experiments

允我心安 提交于 2019-12-24 10:39:32

问题


I'm wondering why I have to include the JavaScript cxApi when I'm running the experiments server-side. Furthermore, can I send the chosen experiment and variations by PHP? Or maybe by injecting a JavaScript snippet without external resources (like the cxApi).

I'm using Universal Analytics on the front-end and on the back-end.


回答1:


Take a look at this library: php-gacx (Server-Side Google Analytics Content Experiments PHP Client) https://github.com/thomasbachem/php-gacx

They parse cxApi response on server-side and update cxApi cookie. Also take a look at this comment: https://github.com/thomasbachem/php-gacx/issues/4

hope it helps




回答2:


Alternative approach: You can do randomization yourself and just set GA custom dimensions "expId" and "varId" with ga('set',...) syntax and then send any hit (i.e. pageview). https://developers.google.com/analytics/solutions/experiments-server-side

Here is nice article how to do weight-based randomization: http://codetheory.in/weighted-biased-random-number-generation-with-javascript-based-on-probability/



来源:https://stackoverflow.com/questions/27900705/server-side-google-analytics-experiments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!