we're trying to use script for a funnel for google BigQuery that Doug Mackenzie created linked here:http://online-behavior.com/analytics/funnel-analysis
We have run into some problems with our SQL call.
We're trying to use a filter from a hits.customDimensions.index = 20 where the value is 1. These values are always present so a simple filter such as the ones used as examples in his introduction is unfortunately not adequate.
A filter such as:WHERE hits.customDimensions.index = '20' Does not filter what we need to have filtered.
Rather we need (we imagine) something like this:
WHERE MAX(IF(hits.customDimensions.index=20,hits.customDimensions.value,NULL)) WITHIN hits as locked= '1'
This is how we've tried doing it:
FROM (
SELECT
fullVisitorId,
visitId,
MIN(hits.hitNumber) AS firstHit,
MAX(IF(hits.isExit, 1, 0)) AS exit
FROM(
SELECT
*,
MAX(IF(hits.customDimensions.index=20,hits.customDimensions.value,NULL)) WITHIN hits as locked,
FROM
TABLE_DATE_RANGE([[dataset.ga_sessions_], TIMESTAMP('2017-06-01'), TIMESTAMP('2017-06-04'))
)
WHERE
REGEXP_MATCH(hits.page.pagePath, '^/plus/.*/[0-9]')
AND totals.visits = 1
AND locked= '1'
GROUP BY
fullVisitorId,
visitId) s0
This returns the error:
Error: Cannot query the cross product of repeated fields customDimensions.index and hits.kunde. ; Cannot query the cross product of repeated fields customDimensions.value and hits.kunde.
We have seen that there are some suggestions to use FLATTEN on problems with the above mentioned error. However this did seem to give syntax errors:
FROM (
SELECT
fullVisitorId,
visitId,
MIN(hits.hitNumber) AS firstHit,
MAX(IF(hits.isExit, 1, 0)) AS exit,
MAX(IF(hits.customDimensions.index=20,hits.customDimensions.value,NULL)) WITHIN hits AS locked
FROM
FLATTEN(TABLE_DATE_RANGE([[dataset.ga_sessions_], TIMESTAMP('2017-06-01'), TIMESTAMP('2017-06-04')),hits.customDimension)
WHERE
REGEXP_MATCH(hits.page.pagePath, '^/plus/.*/[0-9]')
AND totals.visits = 1
AND locked = '1'
GROUP BY
fullVisitorId,
visitId) s0
Just gives the error: Error: Not found: Table eb-bigquery:3917183.ga_sessions_
So any suggestions to how we can get the filter to work would be much appreciated.