GA4-API可以从分钟和区域和会议的组合中获取数据吗?

发布于 2025-01-29 04:06:19 字数 1980 浏览 5 评论 0原文

问题

在UA的情况下,我能够每分钟每分钟(分钟,区域和会话的组合)获得每区域的会话数量,但是GA4不可能?

如果没有,将来是否有任何计划来支持这一点?


细节

我ran

但是我有一个不兼容的错误。


我尝试的

我已经检查了 ga4尺寸&指标探索者并确认了分钟和区域的组合是不可能的。 (请参见下图)。

“我检查的结果的图像”

(更新了2022/05/16 15:35),由代码执行

我和Ruby一起运行了它。

require "google/analytics/data/v1beta/analytics_data"
require 'pp'
require 'json'

ENV['GOOGLE_APPLICATION_CREDENTIALS'] = '' # service acount file path
client = ::Google::Analytics::Data::V1beta::AnalyticsData::Client.new

LIMIT_SIZE = 1000
offset = 0

loop do
  request = Google::Analytics::Data::V1beta::RunReportRequest.new(
    property: "properties/xxxxxxxxx",
    date_ranges: [
      { start_date: '2022-04-01', end_date: '2022-04-30'}
    ],
    dimensions: %w(date hour minute region).map { |d| { name: d } },
    metrics: %w(sessions).map { |m| { name: m } },
    keep_empty_rows: false,
    offset: offset,
    limit: LIMIT_SIZE
  )

  ret = client.run_report(request)
  dimension_headers = ret.dimension_headers.map(&:name)
  metric_headers = ret.metric_headers.map(&:name)
  puts (dimension_headers + metric_headers).join(',')
  ret.rows.each do |row|
    puts (row.dimension_values.map(&:value) + row.metric_values.map(&:value)).join(',')
  end

  offset += LIMIT_SIZE

  break if ret.row_count <= offset
end

结果是一个错误。

3:尺寸和指标不兼容.. debug_error_string:{“创建”:“@1652681913.393028000”,“描述”:“从PEER IPV4:172.217.175.234:172.217.175.234:443:443”,“ src/ src/ src/ src/ src/ src/ src”,“ src/ src/ src/ src/ src/ src/ src/ src”,“: core/lib/surface/call.cc“,“ file_line”:953,“ grpc_message”:“尺寸和指标不兼容。”,“ grpc_status”:3}

Problem

With UA, I was able to get the number of sessions per region per minute (a combination of minute, region, and sessions), but is this not possible with GA4?

If not, is there any plan to support this in the future?


Detail

I ran GA4 Query Explorer with date, hour, minute, region in Dimensions and sessions in Metrics.

But I got an incompatibility error.


What I tried

I have checked with GA4 Dimensions & Metrics Explorer and confirmed that the combination of minute and region is not possible. (see image below).

image of the result I checked

(updated 2022/05/16 15:35)Checked by Code Execution

I ran it with ruby.

require "google/analytics/data/v1beta/analytics_data"
require 'pp'
require 'json'

ENV['GOOGLE_APPLICATION_CREDENTIALS'] = '' # service acount file path
client = ::Google::Analytics::Data::V1beta::AnalyticsData::Client.new

LIMIT_SIZE = 1000
offset = 0

loop do
  request = Google::Analytics::Data::V1beta::RunReportRequest.new(
    property: "properties/xxxxxxxxx",
    date_ranges: [
      { start_date: '2022-04-01', end_date: '2022-04-30'}
    ],
    dimensions: %w(date hour minute region).map { |d| { name: d } },
    metrics: %w(sessions).map { |m| { name: m } },
    keep_empty_rows: false,
    offset: offset,
    limit: LIMIT_SIZE
  )

  ret = client.run_report(request)
  dimension_headers = ret.dimension_headers.map(&:name)
  metric_headers = ret.metric_headers.map(&:name)
  puts (dimension_headers + metric_headers).join(',')
  ret.rows.each do |row|
    puts (row.dimension_values.map(&:value) + row.metric_values.map(&:value)).join(',')
  end

  offset += LIMIT_SIZE

  break if ret.row_count <= offset
end

The result was an error.

3:The dimensions and metrics are incompatible.. debug_error_string:{"created":"@1652681913.393028000","description":"Error received from peer ipv4:172.217.175.234:443","file":"src/core/lib/surface/call.cc","file_line":953,"grpc_message":"The dimensions and metrics are incompatible.","grpc_status":3}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仙女 2025-02-05 04:06:19

代码中的错误,请确保使用实际维度名称,而不是UI名称。该维度的正确名称是dateHourminute不是日期小时和分钟

dimensions: %w(dateHourMinute).map { |d| { name: d } },

查询探索返回此请求,只是fine

<

a href =“ https://i.sstatic.net/kzno6.png” rel =“ nofollow noreferrer”> “在此处输入图像描述”

限制区域维度的使用量

为区域。由于错误消息指出了尺寸和指标不兼容。问题是date -hourminute无法与区域一起使用。切换到datedate hour

在撰写时,这是一个beta api。我已向Google发送了一条消息,以了解是否可以按预期工作或是否可以更改。

Error in your code, Make sure you use the actual dimension name and not the UI name. The correct name of that dimension is dateHourMinute not Date hour and minute

dimensions: %w(dateHourMinute).map { |d| { name: d } },

The query explore returns this request just fine

enter image description here

results

enter image description here

Limited use for region dimension

The as for region. As the error message states the dimensions and metrics are incompatible. The issue being that dateHourMinute can not be used with region. Switch to date or datehour

at the time of writing this is a beta api. I have sent a message off to google to find out if this is working as intended or if it may be changed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文