Use the SQL code below and change {{projectId}}
and {{datasetName}}
to your own.
#Preparing eventTrafficSource object
WITH input AS
(
SELECT
PARSE_DATE('%Y%m%d','20220901') AS date_start,
PARSE_DATE('%Y%m%d','20220930') AS date_end
)
SELECT
CAST(FARM_FINGERPRINT(CONCAT( --deviceHash
IFNULL(events.source, ''),
IFNULL(events.medium, ''),
IFNULL(events.campaign, ''),
IFNULL(events.keyword, ''),
IFNULL(events.adContent , '')
)) AS STRING) AS eventTrafficSourceHash,
events.source,
events.medium,
events.campaign,
events.keyword,
events.adContent
FROM input as i, `{{projectId}}.{{datasetName}}._temp_sessions`,
UNNEST (events) as events
WHERE date BETWEEN i.date_start AND i.date_end
GROUP BY 1,2,3,4,5,6
You will get the data in the table 'eventstrafficsources' with the schema below:
Field name | Type | |
---|---|---|
eventTrafficSourceHash |
STRING | |
source |
STRING | |
medium |
STRING | |
campaign |
STRING | |
keyword |
STRING | |
adContent |
STRING |
0 Comments