douyuanqia665858 2014-08-07 14:10
浏览 26
已采纳

如何根据3个不同的细分获取跳出率?

UPDATE: Cross posting in Google Groups to draw more attention.

I manage to get my php client using Google Analytics v3 API.

However, I have trouble navigating to get the bounce rate based on 3 different segments:

My code is below:

// create service and get data
$service = new Google_Service_Analytics($client);

// ids - Unique table ID for retrieving Analytics data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.
// startDate - Start date for fetching Analytics data. Requests can specify a start date formatted as YYYY-MM-DD, or as a relative date (e.g., today, yesterday, or 7daysAgo). The default value is 7daysAgo.
// endDate - End date for fetching Analytics data. Request can should specify an end date formatted as YYYY-MM- DD, or as a relative date (e.g., today, yesterday, or 7daysAgo). The default value is yesterday.
// metrics - A comma-separated list of Analytics metrics. E.g., 'ga:sessions,ga:pageviews'. At least one metric must be specified.
$ids = 'ga:59542xxx';
$startDate = '2014-01-01';
$endDate = '2014-01-31';
$metrics = 'ga:bounces';
$optParams = array('segment' => 'users::sequence::ga:userType==New Vistor');
$call = $service->data_ga->get($ids, $startDate, $endDate, $metrics, $optParams);

My code is largely based on this link.

The 3 segments I want is Organic Traffic, New Users, Returning Users.

I know the condition is

ga:userType==New Visitor
ga:userType==Returning Visitor
ga:medium==organic

My questions are:

  1. do I need to send 3 separate calls?

  2. How do I structure the conditionScope and conditionType? Based on https://developers.google.com/analytics/devguides/reporting/core/v3/segments#reference

  • 写回答

1条回答 默认 最新

  • dopt85756 2014-08-10 15:46
    关注
    1. Yes, as you can only apply a single segment at a time.
    2. You are likely looking to get this information at the session (visit) scope, rather than the user scope, as some items wouldn't make sense at the user scope (i.e. a user who visits twice would be both a new visitor and a returning visitor in the user scope, and bounce rate is a session-level metric); so your conditionScope will be sessions::. In terms of conditionType, these are simple conditions rather than sequences (see some info regarding sequence segments), so you'll be using condition::. Thus based on the <conditionScope><conditionType><dimensionOrMetricConditions> format, your segments would be:

      sessions::condition::ga:userType==New Visitor

      sessions::condition::ga:userType==Returning Visitor

      sessions::condition::ga:medium==organic

    Additionally, you should be aware that ga:bounces will give you the total number of bounces in your request, rather than the bounce rate; you can use ga:bounceRate for bounce rate or additionally pull in ga:sessions to calculate the rate yourself.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 echarts动画效果失效的问题。官网下载的例子。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加