I am trying to connect my Custom Query in BigQuery with Data Studio. I have read the guide from here: https://support.google.com/360suite/datastudio/answer/6370296?hl=en&ref_topic=6370347 but I have a few more questions.
My query is supposed to pull last 7 days funnel flow data so when using custom query in Data Studio, how can I write in such a way that BQ will pull the data, if possible?
If not, how can I modify my query in such a way that Data Studio will pull the data from BigQuery based on the date range I define in Data Studio? I will add the date range selector in Data Studio.
Below is the sample of my query to get goal funnel data.
SELECT
s0.fullVisitorId,
s0.visitId,
s0.firstHit,
s1.firstHit
FROM (
SELECT
fullVisitorId,
visitId,
MIN(hits.hitNumber) AS firstHit
FROM
(TABLE_DATE_RANGE([xxx.ga_sessions_],
DATE_ADD(CURRENT_TIMESTAMP(), -7, 'DAY'),
CURRENT_TIMESTAMP()))
WHERE
REGEXP_MATCH(hits.page.pagePath, '/pageA/')
AND totals.visits = 1
GROUP BY
fullVisitorId,
visitId) s0
LEFT OUTER JOIN EACH (
SELECT
fullVisitorId,
visitId,
MIN(hits.hitNumber) AS firstHit
FROM
(TABLE_DATE_RANGE([xxx.ga_sessions_],
DATE_ADD(CURRENT_TIMESTAMP(), -7, 'DAY'),
CURRENT_TIMESTAMP()))
WHERE
REGEXP_MATCH(hits.page.pagePath, '/pageB/')
AND totals.visits = 1
GROUP BY
fullVisitorId,
visitId) s1
ON
s0.fullVisitorID = s1.fullVisitorID
AND s0.visitID = s1.visitID