首页 文章

如何在谷歌大查询中选择谷歌分析细分? SQL

提问于
浏览
2

我在Tableau中创建了Google Analytics数据源 . 数据源具有"new user"的段 .
enter image description here

现在,我想在Google Bigquery中推送Google Analytics,并通过从Google Bigquery创建数据源在Tableau中创建相同的数据源 .

检查Google Bigquery项目中的GA数据源后 . Bigquery中没有任何细分 .

如何在Google Bigquery中按段“新用户”进行查询?

enter image description here

1 回答

  • 3

    您可以查看BigQuery GA Schema以查看在那里导出的所有字段 .

    totals.newVisits 字段有你要找的东西:

    select
    hits.transaction.transactionid tid,
    date,
    totals.pageviews pageviews,
    hits.item.itemquantity item_qtd,
    hits.transaction.transactionrevenue / 1e6 rvn,
    totals.bounces bounces,
    fullvisitorid fv,
    visitid v,
    totals.timeonsite tos,
    totals.newVisits new_visit
    FROM
        `project_id.dataset_id.ga_sessions*`,
        unnest(hits) hits
      WHERE
        1 = 1
        AND PARSE_TIMESTAMP('%Y%m%d', REGEXP_EXTRACT(_table_suffix, r'.*_(.*)')) BETWEEN TIMESTAMP('2017-05-10')
        AND TIMESTAMP('2017-05-10')
    group by 
    tid, date, pageviews, item_qtd, rvn, bounces, fv, v, tos, new_visit
    

    请注意,此字段在会话级别中定义 .

相关问题