Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amend GA4 tag placement logic to use Google Tag ID if set #6080

Closed
felixarntz opened this issue Oct 27, 2022 · 4 comments
Closed

Amend GA4 tag placement logic to use Google Tag ID if set #6080

felixarntz opened this issue Oct 27, 2022 · 4 comments
Labels
Good First Issue Good first issue for new engineers Module: Analytics Google Analytics module related issues P0 High priority QA: Eng Requires specialized QA by an engineer Type: Enhancement Improvement of an existing feature

Comments

@felixarntz
Copy link
Member

felixarntz commented Oct 27, 2022

Instead of assuming that the GA4 web data stream measurement ID is the correct ID to inject in the frontend, the Analytics_4\Web_Tag implementation needs to instead place the Google Tag ID determined by the module (will be implemented in a separate issue) if it is already set. Existing sites may not have it set yet, so in those cases it still needs to fall back to using the measurement ID like it has been doing.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation Brief

  • Using includes/Modules/Analytics_4.php,
    • Within the register_tag method,
      • Check if the gteSupport feature flag is enabled via the Feature_Flags::enabled method.
      • Check if googleTagID from the module settings ($settings) is set and if it's the case, instantiate Web_Tag with the googleTagID settings value, if not, fallback to the existing measurementID.

Test Coverage

  • Add tests for the above changes.

QA Brief

QA:Eng

  • In order to QA this, a GA4 property is required with Google Tag settings populated. However, that won't be possible until Add Analytics setup/settings logic to determine Google Tag settings #6081 (the task that actually populates Google Tag settings) is merged.
  • Wait until Add Analytics setup/settings logic to determine Google Tag settings #6081 is merged.
  • Enable the gteSupport feature flag from the tester plugin.
  • Connect the Analytics module, with a GA4 property having Google Tag settings.
  • Make sure GA4 snippet is inserted in Analytics module settings.
  • View the page source of a WordPress page.
  • Look for a <script> tag with the ID google_gtagjs-js-after.
  • Verify that the tag placement for GA4 is the Google Tag ID, instead of the GA4 measurement ID.
  • If the gteSupport feature flag is disabled, verify that the Google Tag ID is replaced with the fallback GA4 measurement ID.

Changelog entry

  • Use the configured Google Tag ID for the Analytics 4 snippet if present.
@felixarntz felixarntz added P0 High priority Type: Enhancement Improvement of an existing feature Module: Analytics Google Analytics module related issues labels Oct 27, 2022
@felixarntz felixarntz self-assigned this Oct 27, 2022
@felixarntz felixarntz added the Good First Issue Good first issue for new engineers label Oct 27, 2022
@felixarntz felixarntz removed their assignment Oct 27, 2022
@asvinb asvinb assigned asvinb and unassigned asvinb Nov 1, 2022
@techanvil
Copy link
Collaborator

IB ✅

@techanvil techanvil assigned techanvil and unassigned techanvil Nov 1, 2022
@derweili derweili assigned derweili and unassigned derweili Nov 23, 2022
@mxbclang
Copy link

NOTE: This issue is blocked by #6078 in Sprint 91.

@nfmohit nfmohit self-assigned this Jan 3, 2023
@nfmohit nfmohit added the QA: Eng Requires specialized QA by an engineer label Jan 5, 2023
@nfmohit nfmohit removed their assignment Jan 5, 2023
@jimmymadon jimmymadon assigned jimmymadon and unassigned jimmymadon Jan 6, 2023
@techanvil techanvil self-assigned this Jan 9, 2023
techanvil added a commit that referenced this issue Jan 9, 2023
…le-tag

Place Google Tag ID if available instead of GA4 tag
@techanvil techanvil removed their assignment Jan 9, 2023
@jimmymadon jimmymadon assigned jimmymadon and unassigned jimmymadon Jan 11, 2023
@kuasha420 kuasha420 self-assigned this Jan 13, 2023
@wpdarren
Copy link
Collaborator

QA Update: ✅

@kuasha420 it's my understanding that we were going to do some quick checks and move this ticket to approved. We need to make sure any additional testing would be picked up in #6081. My understanding is that you completed some regression testing and all seems good.

I have therefore moved this to approved!

@aaemnnosttv
Copy link
Collaborator

Gave this a quick review as well; a simple change that will get more testing before we start to roll it out as well, but LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue Good first issue for new engineers Module: Analytics Google Analytics module related issues P0 High priority QA: Eng Requires specialized QA by an engineer Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

10 participants