docs(gtm): add subdomain regex dot separator gotcha
The pattern (www|app|...|\.)?josunhotel does NOT match www.josunhotel.com. Fix: (www|app|...)?\.?josunhotel moves the dot outside the alternation as a separate optional match. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -284,6 +284,22 @@ The JHR container has two content group variables for menu categories:
|
|||||||
|
|
||||||
**Gotcha — adding new subdomains**: When a new hotel brand subdomain launches (e.g., `les.josunhotel.com`), the subdomain alternation group `(www|app|...|les|\.)` in ALL main-domain rules must be updated. This affects 14+ rules in the URL-based variable.
|
**Gotcha — adding new subdomains**: When a new hotel brand subdomain launches (e.g., `les.josunhotel.com`), the subdomain alternation group `(www|app|...|les|\.)` in ALL main-domain rules must be updated. This affects 14+ rules in the URL-based variable.
|
||||||
|
|
||||||
|
### Gotcha — Subdomain Regex Dot Separator
|
||||||
|
|
||||||
|
**Bug**: `(www|app|jpg|les|\.)?josunhotel\.com` does NOT match `www.josunhotel.com`.
|
||||||
|
|
||||||
|
The `\.` inside the alternation group matches a literal dot OR `www` matches `www`, but neither consumes the `.` between the subdomain and `josunhotel`. The regex engine sees `www` then expects `josunhotel` but finds `.josunhotel`.
|
||||||
|
|
||||||
|
**Fix**: Move the dot outside the group as an optional separator:
|
||||||
|
```
|
||||||
|
BROKEN: (www|app|jpg|gjb|gjj|grp|les|\.)?josunhotel\.com
|
||||||
|
FIXED: (www|app|jpg|gjb|gjj|grp|les)?\.?josunhotel\.com
|
||||||
|
```
|
||||||
|
|
||||||
|
This correctly matches: `www.josunhotel.com`, `les.josunhotel.com`, `josunhotel.com` (bare), `app.josunhotel.com`.
|
||||||
|
|
||||||
|
**Note**: GTM's "Full Matches Only = OFF" means `re.search` (partial match) is used, which may accidentally match the broken pattern on some URLs. But strict `re.match` or JavaScript `pattern.test()` will fail. Always test with the full URL in JavaScript console.
|
||||||
|
|
||||||
### Audit Checklist for Content Grouping
|
### Audit Checklist for Content Grouping
|
||||||
|
|
||||||
- [ ] Run `dtm var info <var_id>` to dump the full regex table
|
- [ ] Run `dtm var info <var_id>` to dump the full regex table
|
||||||
|
|||||||
@@ -284,6 +284,22 @@ The JHR container has two content group variables for menu categories:
|
|||||||
|
|
||||||
**Gotcha — adding new subdomains**: When a new hotel brand subdomain launches (e.g., `les.josunhotel.com`), the subdomain alternation group `(www|app|...|les|\.)` in ALL main-domain rules must be updated. This affects 14+ rules in the URL-based variable.
|
**Gotcha — adding new subdomains**: When a new hotel brand subdomain launches (e.g., `les.josunhotel.com`), the subdomain alternation group `(www|app|...|les|\.)` in ALL main-domain rules must be updated. This affects 14+ rules in the URL-based variable.
|
||||||
|
|
||||||
|
### Gotcha — Subdomain Regex Dot Separator
|
||||||
|
|
||||||
|
**Bug**: `(www|app|jpg|les|\.)?josunhotel\.com` does NOT match `www.josunhotel.com`.
|
||||||
|
|
||||||
|
The `\.` inside the alternation group matches a literal dot OR `www` matches `www`, but neither consumes the `.` between the subdomain and `josunhotel`. The regex engine sees `www` then expects `josunhotel` but finds `.josunhotel`.
|
||||||
|
|
||||||
|
**Fix**: Move the dot outside the group as an optional separator:
|
||||||
|
```
|
||||||
|
BROKEN: (www|app|jpg|gjb|gjj|grp|les|\.)?josunhotel\.com
|
||||||
|
FIXED: (www|app|jpg|gjb|gjj|grp|les)?\.?josunhotel\.com
|
||||||
|
```
|
||||||
|
|
||||||
|
This correctly matches: `www.josunhotel.com`, `les.josunhotel.com`, `josunhotel.com` (bare), `app.josunhotel.com`.
|
||||||
|
|
||||||
|
**Note**: GTM's "Full Matches Only = OFF" means `re.search` (partial match) is used, which may accidentally match the broken pattern on some URLs. But strict `re.match` or JavaScript `pattern.test()` will fail. Always test with the full URL in JavaScript console.
|
||||||
|
|
||||||
### Audit Checklist for Content Grouping
|
### Audit Checklist for Content Grouping
|
||||||
|
|
||||||
- [ ] Run `dtm var info <var_id>` to dump the full regex table
|
- [ ] Run `dtm var info <var_id>` to dump the full regex table
|
||||||
|
|||||||
Reference in New Issue
Block a user