我希望通过自定义维度属性吸引访问者,其中每一行都是唯一的fullvisitorid,列是所需的customdimension.values。
以伦敦头盔为例,这里我正在提取我感兴趣的两个自定义维度的访问者:
SELECT fullvisitorid, customDimensions.index, customDimensions.value
FROM [google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910]
where customDimensions.index in (2,3)
group by fullvisitorid, customDimensions.index, customDimensions.value
它会给出类似以下的结果:
+---------------+------------------------+------------------------+
| fullvisitorid | customDimensions_index | customDimensions_value |
+---------------+------------------------+------------------------+
| 1 | 2 | Bronze |
| 1 | 3 | Yes |
| 2 | 2 | Bronze |
| 2 | 3 | No |
| 3 | 2 | Bronze |
| 3 | 3 | Yes |
| 4 | 2 | Platinum |
| 4 | 3 | Yes |
+---------------+------------------------+------------------------+
我希望将值转置,其中customDimension_index 2是颜色,customDimension_value 3是yesno,因此结果看起来应该像这样:
+---------------+----------+-------+
| fullvisitorid | color | yesno |
+---------------+----------+-------+
| 1 | Bronze | Yes |
| 2 | Bronze | No |
| 3 | Bronze | Yes |
| 4 | Platinum | Yes |
+---------------+----------+-------+
我可以分别抓取这两个数据并按照fullvisitorid连接起来,但希望能够一次性地以这种方式提取数据。谢谢!