Skip to content

Commit e4e0e85

Browse files
committed
docs: clarify override key conflict resolution
1 parent 7cccb9f commit e4e0e85

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

data-inputs/platform-supporting-resources/shopify/backfilling-utm-attribution-via-checkout-attributes.mdx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ To reduce collisions with other checkout apps, prefer the `sm_utm_*` / `sm_utmPa
4545
| `sm_utm_source`, `sm_utm_medium`, `sm_utm_campaign`, `sm_utm_content`, `sm_utm_term`, `sm_utm_id` | SourceMedium override UTMs (recommended) | `sm_utm_source=facebook` |
4646
| `utm_source`, `utm_medium`, `utm_campaign`, `utm_content`, `utm_term`, `utm_id` | Standard UTMs | `utm_campaign=summer_sale_2025` |
4747
| `sm_utmParams`, `utmParams`, `GE_utmParams` | Aggregate UTM query string (parsed) | `utm_source=google&utm_medium=cpc` |
48-
| `referrer` | Referring URL | `https://blog.example.com/review` |
48+
| `sm_referrer`, `referrer` | Referring URL | `https://blog.example.com/review` |
4949

5050
### Click IDs (fallback inference)
5151

@@ -62,6 +62,16 @@ Click IDs are processed but **not stored as raw values**. If no explicit `utm_so
6262

6363
If multiple click IDs exist, the system prioritizes: `scclid` > `irclickid` > `msclkid` > `ttclid` > `fbclid` > `gclid`.
6464

65+
### Conflict resolution (deterministic)
66+
67+
If you provide conflicting values (e.g., both `sm_utm_source` and `utm_source`, or both direct keys and `utmParams`), SourceMedium resolves each final field with a deterministic waterfall:
68+
69+
- **UTM fields**: direct `sm_utm_*` → direct `utm_*` → parsed from `sm_utmParams` → parsed from `utmParams` → parsed from `GE_utmParams`
70+
- **`utm_source` only**: if still missing, infer from click IDs (`scclid``irclickid``msclkid``ttclid``fbclid``gclid`)
71+
- **Referrer**: `sm_referrer``referrer`
72+
73+
If the same normalized key appears multiple times at the same level (e.g., `utm_source` and `UTM_SOURCE`), SourceMedium de-dupes deterministically using `MAX()` (lexicographically largest value). To avoid surprises, only set each key once.
74+
6575
---
6676

6777
## Backfilling Historical Orders
@@ -400,7 +410,7 @@ const attributes = {
400410
ttclid: getParam('ttclid'),
401411
fbclid: getParam('fbclid'),
402412
gclid: getParam('gclid'),
403-
referrer: document.referrer || null,
413+
sm_referrer: document.referrer || null,
404414
};
405415

406416
const cleanAttributes = Object.fromEntries(

data-transformations/attribution-source-hierarchy.mdx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,30 @@ Keys are **normalized** (case + delimiter + snake/camel agnostic) before matchin
8181
| `sm_utm_source`, `sm_utm_medium`, `sm_utm_campaign`, `sm_utm_content`, `sm_utm_term`, `sm_utm_id` | SourceMedium override keys (recommended to avoid collisions with other apps) |
8282
| `utm_source`, `utm_medium`, `utm_campaign`, `utm_content`, `utm_term`, `utm_id` | Standard UTM keys |
8383
| `sm_utmParams`, `utmParams`, `GE_utmParams` | Aggregate UTM query-string fields (parsed into individual UTM keys) |
84-
| `referrer` | Referring URL |
84+
| `sm_referrer`, `referrer` | Referring URL |
85+
86+
### Conflict resolution (deterministic)
87+
88+
If your `customAttributes` data is messy (duplicate keys, multiple sources provided), SourceMedium applies a deterministic waterfall to resolve each final field.
89+
90+
#### Field-level precedence
91+
92+
For each UTM field, the **first non-empty value wins** (highest → lowest):
93+
94+
1. Direct SM override key (`sm_utm_*`)
95+
2. Direct standard UTM key (`utm_*`)
96+
3. Parsed from `sm_utmParams` (query string)
97+
4. Parsed from `utmParams` (query string)
98+
5. Parsed from `GE_utmParams` (query string)
99+
6. **`utm_source` only**: click ID inference (`scclid``irclickid``msclkid``ttclid``fbclid``gclid`)
100+
101+
`referrer` is resolved similarly: `sm_referrer``referrer`.
102+
103+
#### Duplicate keys (same tier)
104+
105+
If the same normalized key appears multiple times at the same tier (for example both `utm_source` and `UTM_SOURCE`, or repeated `utm_source` entries), SourceMedium de-dupes deterministically using `MAX()` (lexicographically largest value after decoding/cleaning).
106+
107+
To avoid surprises, only set each key once.
85108

86109
<Note>
87110
Click IDs are processed as a **fallback** (see below), but the raw click ID values are not stored as attribution fields.
@@ -106,6 +129,11 @@ When only a click ID is present (no explicit `utm_source`), the system infers a
106129

107130
If an order has multiple click IDs, the highest-priority click ID wins. This preserves more specific intent signals (like affiliates or smaller platforms) over ambient IDs from high-volume platforms.
108131

132+
Click IDs are checked in this order:
133+
1. Direct `customAttributes` click ID keys (e.g., `scclid`, `gclid`)
134+
2. Click IDs embedded inside `utmParams`
135+
3. Click IDs embedded inside `GE_utmParams`
136+
109137
<Note>
110138
Click IDs are **fallback only**. If an explicit `utm_source` exists, it takes precedence over any click ID inference.
111139
</Note>

0 commit comments

Comments
 (0)