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

Remove functionality preventing GA4 from outputting tags when GTM takes over #8196

Closed
26 tasks done
jimmymadon opened this issue Jan 29, 2024 · 11 comments
Closed
26 tasks done
Labels
P2 Low priority Type: Enhancement Improvement of an existing feature

Comments

@jimmymadon
Copy link
Collaborator

jimmymadon commented Jan 29, 2024

Feature Description

Originally, when GA was already connected, and the selected Tag Manager container had a tag that was a valid UA trackingId which matched the existing propertyId saved in Analytics settings, we would prevent the Analytics module from outputting the snippet. This was mainly to prevent UA from tracking duplicate events. This screen is highlighted in point 2 of this comment. This issue does not arise as having multiple snippets for the same GA4 data stream does not duplicate events in GA4.


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

Acceptance criteria

  • Code and infrastructure solely in place to prevent the Analytics module from outputting the tag snippet when a GTM container had a UA tag within it with the same property ID (or now, a Google Tag after Adapt GTM integration with GA to support GA4 #7990 is merged) should be removed.

Implementation Brief

Note: Removing code from the old Analytics module is unnecessary since this will be removed in a couple of sprints. However, for completeness of this PR/issue and since SAM might not launch at the same time as this issue being merged, we should remove these pieces anyways.

  • Remove the gaPropertyID setting and all of its usage from the Tag Manager module:

    • In includes/Modules/Tag_Manager/Settings.php:
      • Remove the gaPropertyID setting.
    • In includes/Modules/Tag_Manager.php:
      • Remove the googlesitekit_analytics_can_use_snippet filter and its implementation in can_analytics_use_snippet.
    • In assets/js/modules/tagmanager/datastore/base.js:
      • Remove the gaPropertyID setting field.
    • Remove assets/js/modules/tagmanager/hooks/useGAPropertyIDEffect.js and all of its usage from:
      • assets/js/modules/tagmanager/components/settings/SettingsEdit.js
      • assets/js/modules/tagmanager/components/setup/SetupMain.js
  • Remove the canUseSnippet setting and all of its usage from the Analytics and Analytics-4 modules:

    • Remove the backend setting and its usage from:
      • includes/Modules/Analytics/Settings.php
      • includes/Modules/Analytics_4/Settings.php
    • Remove the entire tag guard: includes/Modules/Analytics/Tag_Guard.php
    • In assets/js/modules/analytics/datastore/base.js:
      • Remove the canUseSnippet setting.
    • In assets/js/modules/analytics/datastore/settings.js:
      • Remove the getCanUseSnippet selector.
    • Remove usage from:
      • assets/js/modules/analytics/components/common/AdsConversionIDTextField.js
      • assets/js/modules/analytics/components/common/UseSnippetSwitch.js
      • assets/js/modules/analytics/components/settings/OptionalSettingsView.js
      • assets/js/modules/analytics/components/settings/SettingsUseSnippetSwitch.js
      • assets/js/modules/analytics/components/setup/SetupUseSnippetSwitch.js

Test Coverage

  • No new tests required.
  • Remove all tests related to the googlesitekit_analytics_can_use_snippet from tests/phpunit/integration/Modules/Tag_ManagerTest.php and tests/phpunit/integration/Modules/Analytics/SettingsTest.php.
  • Remove the getCanUseSnippet selector tests from assets/js/modules/analytics/datastore/settings.test.js.
  • Remove all references to canUseSnippet and gaPropertyID that have been removed above from stories, tests and fixtures.

QA Brief

  • Connect GTM module and select a container that includes GA4 property.
  • The GTM snippet should be placed in the Website.
  • Now connect GA4 and configure the same property as GTM.
  • There will be two snippets in the front end. One from GA4 module and the other from GTM.

Changelog entry

  • Allow multiple snippets when using Google Analytics 4 and Google Tag Manager.
@ivonac4
Copy link
Collaborator

ivonac4 commented Jan 30, 2024

@jimmymadon is it possible to add Type and Priority label to this ticket at this moment?

@jimmymadon jimmymadon added P2 Low priority Type: Enhancement Improvement of an existing feature labels Jan 30, 2024
@mxbclang mxbclang changed the title [GTM + GA4] Remove functionality preventing GA4 from outputting tags when GTM takes over Remove functionality preventing GA4 from outputting tags when GTM takes over Feb 5, 2024
@jimmymadon jimmymadon removed their assignment Feb 21, 2024
@eugene-manuilov eugene-manuilov self-assigned this Feb 21, 2024
@eugene-manuilov
Copy link
Collaborator

AC 🌶️

@jimmymadon jimmymadon removed their assignment Feb 21, 2024
@mxbclang mxbclang added the Next Up Issues to prioritize for definition label Feb 22, 2024
@tofumatt tofumatt self-assigned this Feb 22, 2024
@tofumatt
Copy link
Collaborator

IB ✅

@tofumatt tofumatt removed their assignment Feb 22, 2024
@jimmymadon jimmymadon self-assigned this Feb 22, 2024
@mxbclang mxbclang removed the Next Up Issues to prioritize for definition label Feb 23, 2024
@kuasha420 kuasha420 removed their assignment Feb 27, 2024
@zutigrm zutigrm self-assigned this Feb 27, 2024
@zutigrm
Copy link
Collaborator

zutigrm commented Feb 28, 2024

Unnasigning myself as it will take me more time to go through whole PR, in order to focus on priority issue I need to finalize till EOD before the vacation

@zutigrm zutigrm removed their assignment Feb 28, 2024
@tofumatt tofumatt self-assigned this Feb 28, 2024
@tofumatt tofumatt removed their assignment Feb 29, 2024
@wpdarren wpdarren self-assigned this Feb 29, 2024
@wpdarren
Copy link
Collaborator

wpdarren commented Mar 1, 2024

QA Update: ⚠️

@tofumatt I was wondering if you could help here in Jimmy's absence. I am not seeing the GA4 snippet. Here are the steps I undertook. I created an account on GTM and added a GA4 measurement Id (and Google tag) to the new container. Submitted the container with tag. I connected GTM and selected that I didn't want to set up Analytics and instead set up with GTM, but no GA4 snippet appears as per the QAB.

I don't feel like I missed any steps, but I wondered if you could review the QAB and provide additional details.

@tofumatt
Copy link
Collaborator

tofumatt commented Mar 1, 2024

I just ran through the QA steps as you did and saw both tags:

Screenshot 2024-03-01 at 12 37 56

The QA Brief omits this bit of info, but did you remember to check the website in a private browsing window/another browser where you aren't logged in to WordPress? Otherwise a tag/tags might be missing because they don't appear for signed-in users.

But I was able to see both after testing, as long as I viewed the site as an "anonymous" user on the front-end. 🤔

@tofumatt tofumatt removed their assignment Mar 1, 2024
@wpdarren
Copy link
Collaborator

wpdarren commented Mar 4, 2024

QA Update: ⚠️

@tofumatt I am not sure if its me being stupid (possible) but I cannot get this to pass. I am looking at the QAB:

Connect GTM module and select a container that includes GA4 property.
The GA4 snippet should be placed in the Website.

When setting up GTM, I selected Complete setup without Analytics because Analytics is not connected I looked at the site in incognito and did not see the GA4 snippet in the source code.

image

Within GTM, I added a GA4 measurement ID and Google tag.

Here's my GTM setup. I clicked on submit and published the tag within the container.

Screenshots

image
image
image

Any ideas why I cannot see the GA4 code like in your screenshot?

@tofumatt
Copy link
Collaborator

tofumatt commented Mar 4, 2024

@wpdarren You do need to select GA4 and set up Analytics on Site Kit as well. Are you connecting Tag Manager AND Analytics on the site?

@tofumatt tofumatt removed their assignment Mar 4, 2024
@wpdarren
Copy link
Collaborator

wpdarren commented Mar 5, 2024

@tofumatt No, as I said in my comment, I have not set up Analytics, just Google Tag Manager with a GA4/Google Tag against a container. I think we need to sync about this because I have spent much time trying to get this to work as per the QAB. I will reach out to you when I am online.

@tofumatt
Copy link
Collaborator

tofumatt commented Mar 5, 2024

Screenshot.2024-03-05.at.11.29.24.mp4

I've attached a screenshot showing the QA steps I took to get both. Seems like the QA Brief was misunderstood, thinking GA shouldn't be connected, but it should 😄

@tofumatt tofumatt removed their assignment Mar 5, 2024
@wpdarren
Copy link
Collaborator

wpdarren commented Mar 5, 2024

QA Update: ✅

  • The GTM snippet is placed in the Website.
  • There are two snippets in the front end. One from GA4 module and the other from GTM.
Screenshots

image
image

@wpdarren wpdarren removed their assignment Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Low priority Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

9 participants