7. UserTrafficSource

Use the SQL code below and change {{projectId}} and {{datasetName}} to your own.

#Preparing UserTrafficSource 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(user_source, ''),
          IFNULL(user_medium, ''),
          IFNULL(user_campaign, '')
        )) AS STRING) AS trafficSourceHash,        
    user_source,        
    user_medium,
    user_campaign
  FROM input as i, `{{projectId}}.{{datasetName}}._temp_sessions`
  WHERE date BETWEEN i.date_start AND i.date_end
  GROUP BY 1,2,3,4

 

You will get the data in the table 'usertrafficsources' with the schema below:

Field name Type  
trafficSourceHash STRING  
user_source STRING  
user_medium STRING  
user_campaign STRING  

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.