3

Until now I collected Google optimize Experiment ID for a/b page testing from the URL params (utm_expid). But for some reason, they stopped providing it, Is there a way to continue collecting the Experiment ID and if there is, what is the best way to do it?

Before: https://wwww.Domain.com/?utm_expid=.SdQHL1lMSi-Au9qe-MKg3Q.0&utm_referrer=

Now: https://wwww.Domain.com/

4

1 回答 1

3

谷歌优化可能出于美学原因停止将 utm_expid 添加到 URL。

相反,您可以通过 cookie 获取它,该 cookie 名为 _gaexp。

function getCookieByName(cname) {
  var name = cname + "=";
  var ca = document.cookie.split(';');

  for (var i = 0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0) == ' ') c = c.substring(1);
    if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
  }

  return "";
}

getCookieByName("_gaexp")
于 2020-11-22T14:06:59.610 回答