GA4-API可以从分钟和区域和会议的组合中获取数据吗?
问题
在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).
(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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
代码中的错误,请确保使用实际维度名称,而不是UI名称。该维度的正确名称是
dateHourminute
不是日期小时和分钟
查询探索返回此请求,只是fine
<
a href =“ https://i.sstatic.net/kzno6.png” rel =“ nofollow noreferrer”>
限制区域维度的使用量
为区域。由于错误消息指出了尺寸和指标不兼容。问题是
date -hourminute
无法与区域一起使用。切换到date
或date 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
notDate hour and minute
The query explore returns this request just fine
results
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 todate
ordatehour
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.