I have Google Analytics export set-up for Bigquery activated.
This is a query for previous page path, page:
SELECT
LAG(hits.page.pagePath, 1) OVER (PARTITION BY fullVisitorId, visitId ORDER BY hits.hitNumber ASC) AS Previous,
hits.page.pagePath AS Page
FROM
[xxxxxxxx.table]
WHERE
hits.type="PAGE"
LIMIT
100
I am trying to also get a custom dimension for the previous page request but I am stuck.
Basically I want to retrieve a custom dimension (which is a nested value) with LAG.
This works but it also throws a lot of extra null rows:
LAG ( IF (hits.customDimensions.index = 10, hits.customDimensions.value, NULL)) ,1) OVER (PARTITION BY fullVisitorId, visitId ORDER BY hits.hitNumber ASC) AS Previous_PT
If I use max (https://support.google.com/analytics/answer/4419694?hl=en#query7_MultipleCDs ) it throws an error.
Any help would be much appreciated.
Thanks.