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 对于这个复杂问题的解释说明
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败