Send Analytics measurement ID with script tag request #4434
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.
Confirmed with gtag team that including measurementId in initial script tag request does not trigger a page_view event. page_view is in fact triggered on first config call. Tested this out as well.
We now wait for measurementID to be fetched from the dynamic config endpoint, then insert the script tag. All events sent with firebase.analytics() are still queued until after all initialization requests complete, so the delay shouldn't cause any problems?
This should prevent 2 downloads of gtag reported by users here: #2628 which causes a cluttered and confusing log when using the Google Analytics Debugger chrome extension.
I'm still not sure if the double download causes any functionality issues (I don't think so) but it seems to make it distracting and confusing when diagnosing other analytics problems.
(Observed results: There are 2 events sent, one is
user_engagement
, and one ispage_view
, they both seem to be sent properly with FID and are viewable in the Firebase console dashboard.)I will make a separate PR for exp if this approach is good.