Skip to content

Instantly share code, notes, and snippets.

@LRENZ
LRENZ / ga4_attribution.sql
Created October 31, 2023 15:15 — forked from markrittman/ga4_attribution.sql
GA4 Multi-Step, Multi-Cycle Marketing Attribution example using the BigQuery GA4 Sample Dataset at https://developers.google.com/analytics/bigquery/web-ecommerce-demo-dataset
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,
@LRENZ
LRENZ / script.js
Created October 22, 2022 08:53 — forked from Startouf/script.js
Modern UTM & Referral Cookie Replicator
<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