This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script id="gtm-modern-cookie-replicator"> | |
/** | |
* Modern UTM & Referral Cookie Replicator | |
* | |
* Inspired from the UTMZ cookie replicator, | |
* whose goal was to makes a generally faithful representation | |
* of the old __utmz cookie from Classic Analytics. ; | |
* | |
* the "Modern" cookie replicator | |
* - stores and decodes the cookie as/from JSON format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH | |
events AS ( | |
SELECT | |
TIMESTAMP_MICROS(event_timestamp) AS event_ts, | |
CONCAT(user_pseudo_id,'-',event_name,'-',CAST(event_timestamp AS STRING)) AS event_id, | |
user_pseudo_id AS user_pseudo_id, | |
user_id, | |
traffic_source.name AS utm_channel, | |
traffic_source.medium AS utm_medium, | |
traffic_source.source AS utm_source, |