Server-side Google Analytics Experiments

2019-08-09 00:06发布

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.

2条回答
SAY GOODBYE
2楼-- · 2019-08-09 00:35

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

查看更多
戒情不戒烟
3楼-- · 2019-08-09 00:45

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/

查看更多
登录 后发表回答