javascriptphpgoogle-analyticsuniversal-analyticsgoogle-experiments

Server-side Google Analytics Experiments


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.


Solution

  • 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