Eslint: Improve Google Tag manager third parties message #51903
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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/scriptin a bunch of places even though the error doc recommends@next/third-parties. I've updated all cases to refer to@next/third-partiesinstead.Previous PR description
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/jsGoogle Tag Manager:
www.googletagmanager.com/gtm.jsThe
next-script-for-ga.tsrule's matching list (SUPPORTED_HTML_CONTENT_URLS) includesgtm.jswhich means when a developer adds Google Tag Manager to their NextJS website, they'll receive the warning and be encouraged to swap fromgtm.jstogtag. A developer asleep at the wheel (...me) may think...However,
gtagis not compatible withgtm.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 thatgtm.jsis removed completely from the rule, because anyone usinggtm.jsshould not be following these instructions. A separate rule could be added specifically for Google Tag Manager, that does not refer togtag.