Google Analytics Experiments with Ajax

I would like to integrate Google Analytics experiments into our website.

My situation: we have a solution for switching functions, which also allows us to test A / B. Functions are stored in the database and have a percentage that determines how many users will see this function. We also store functions in a cookie, so users will see the same view when it refreshes the page.

Now I want to use the javascript API server to track the status of a function ( Google Experiments Documentation ). In my understanding, I should send a request to google whenever an experiment is used, and I should also tell Google the alternative identifier. This must happen on the correct page in order to correlate the experiment with the correct page view. The problem is ajax requests that can test functions tested with split. In this case, it is difficult to say which functions are used for the current page.

I see 3 options:

  • Track all experiments, even if they are not used on this site. (I think that doesn't make much sense)
  • Create a tool / configuration to identify the experiments and functions that are used on each site (it is very easy to make mistakes here).
  • Track experiments using server-side code (but I don’t know how GA will connect these calls to page view).

What is the official guide for ajax queries and google analytics experiments?

+5
source share

Source: https://habr.com/ru/post/1259584/


All Articles