next.js
7e093afb - Eslint: Improve Google Tag manager third parties message (#51903)

Commit
32 days ago
Eslint: Improve Google Tag manager third parties message (#51903) Note: new PR description written by @timneutkens ## What? Improves the detection of Google Tag Manager vs Google Analytics. As indicated by the author of this PR it was confusing that when you have Google Tag Manager set up it gives you an error message saying you're adding Google Analytics even though it's Tag Manager. I've updated the PR to have a separate message for Google Tag Manager and expanded the error message docs too. It also mentioned `next/script` in a bunch of places even though the error doc recommends `@next/third-parties`. I've updated all cases to refer to `@next/third-parties` instead. <details> <summary>Previous PR description</summary> Google has multiple products with similar names: the "Google Tag" and "Google Tag Manager". Google Tag Manager uses `gtm.js` whereas the "Google Tag" uses `gtag`. Google Analytics previously used `analytics.js` (<2017) and is now delivered via the "Google Tag". Google Tag: `www.googletagmanager.com/gtag/js` Google Tag Manager: `www.googletagmanager.com/gtm.js` The `next-script-for-ga.ts` rule's matching list (`SUPPORTED_HTML_CONTENT_URLS`) includes `gtm.js` which means when a developer adds Google Tag Manager to their NextJS website, they'll receive the warning and be encouraged to swap from `gtm.js` to `gtag`. A developer asleep at the wheel (...me) may think... > I'm using Google Analytics via Google Tag Manager, and NextJS is suggesting I swap `gtm.js` for `gtag` because it will improve performance. `gtag` sounds like it is part of "Google Tag Manager" so I am going to follow the instructions so that my website is faster. However, `gtag` is **not** compatible with `gtm.js` (they're different products with similar names and similar purposes) and so making this change will cause very confusing Google Tag Manager behaviour. I am suggesting that `gtm.js` is removed completely from the rule, because anyone using `gtm.js` should not be following these instructions. A separate rule could be added specifically for Google Tag Manager, that does not refer to `gtag`. </details> --------- Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Author
Parents
Loading