如何通过 URL 参数获取访问者来自何处的统计信息

How to get statistics of where visitors come from via URL params

有很多包含URL网站的QR码,例如:(它只是演示link)

http://www.popupstore.com/index.php?qrcode_type=magazine&location=Singapore http://www.popupstore.com/index.php?qrcode_type=banner&location=Vietnam

我需要一种可以汇总的方法来了解客户来自何处(与 Google 分析中的 source/channel 几乎相同):

谁能帮帮我:)

您可以创建两个自定义维度,每个用于 Type,另一个用于 Country

根据您的需要定义适当的 Scope 维度,Hit 级别或 Session 级别范围将是合适的。

您需要将自定义维度推送到 Google 分析,即您网站中的附加 JS 代码。

ga('send', 'pageview', {
  'dimension1':  'Magzine',
   'dimension2':  'Singapore'
});

这是如何工作的

  • 用户扫码光顾店铺
  • 网站有一个 JS 代码片段,可以从 URL 获取查询参数并为每个参数设置自定义维度
  • 设置自定义维度会让 Google Analytics 知道 TypeCountry
  • 的值

是您的 JS 代码告诉 Google Analytics 为自定义维度取什么值。 Google 分析不会知道该值来自 URL。

要通过 javascript 获取查询参数值,您可以 refer to this answer,如果您采用 Jan Turon 提供的功能(前往并给他一个支持,这对您有帮助):

function getJsonFromUrl() {
  var query = location.search.substr(1);
  var result = {};
  query.split("&").forEach(function(part) {
    var item = part.split("=");
    result[item[0]] = decodeURIComponent(item[1]);
  });
  return result;
}

您可以使用它根据 url 动态设置尺寸。您首先将函数调用到 return 一个 JSON 对象,该对象具有来自查询参数的 key/value 对,然后插入所需的值以设置维度:

 result = getJsonFromUrl();
 ga('send', 'pageview', {
      'dimension1':  result.qrcode_type,
      'dimension2':  result.location
    });