I have managed to calculate total events by ISOweek but not unique events for a given Google Analytics Event using BigQuery. When checking GA, total_events matches the GA interface on the dot but unique_events are off. Do you know how I can solve this?
The query:
SELECT INTEGER(STRFTIME_UTC_USEC(PARSE_UTC_USEC(date),"%V")) iso8601_week_number,
hits.eventInfo.eventCategory,
hits.eventInfo.eventAction,
COUNT(hits.eventInfo.eventCategory) AS total_events,
EXACT_COUNT_DISTINCT(fullVisitorId) AS unique_events
FROM
TABLE_DATE_RANGE([XXXXXX.ga_sessions_], TIMESTAMP('2017-05-01'), TIMESTAMP('2017-05-07'))
WHERE
hits.type = 'EVENT' AND hits.eventInfo.eventCategory = 'BIG_Transaction'
GROUP BY
iso8601_week_number, hits.eventInfo.eventCategory, hits.eventInfo.eventAction
AND totals.visits=1in your where clause? Does it work? - Willian FuksTABLE_DATE_RANGEis not including intradays and ga_sessions table at the same time (what would cause data to duplicate), also maybe make sure if the analyzes in GA is done correctly. Other than that I can't see any error in this query (if there's one, i can't see it). Also, I recommend you to use the standard version of BQ. cloud.google.com/bigquery/docs/reference/standard-sql It's much better. - Willian Fuks