Skip to content

Better detect Ga3, Ga4, GTM and remove duplicate code and more tests #20381

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

Merged
merged 12 commits into from
Feb 22, 2023

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Feb 18, 2023

Description:

fix #20380

In Cloud we need to be able to detect the CMS of a site. As we currently already had two different logics for detecting websites in core and one in Cloud figured to refactor this slightly to only have one in core and then be able to reuse that one in Cloud.

It also adds more ways to detect GA/GTM and removes some of the private methods that were there into public methods so they can be tested. Was then able to remove some duplicate code in the controller.

Review

@tsteur tsteur added the Needs Review PRs that need a code review label Feb 18, 2023
@tsteur tsteur added this to the 4.13.4 milestone Feb 18, 2023
@sgiehl sgiehl removed the Needs Review PRs that need a code review label Feb 20, 2023
@tsteur tsteur added the Needs Review PRs that need a code review label Feb 20, 2023
@tsteur
Copy link
Member Author

tsteur commented Feb 21, 2023

@sgiehl changed the caching to be be url. Tested it locally and worked, even for sites where no url is defined

@sgiehl
Copy link
Member

sgiehl commented Feb 21, 2023

@tsteur One last thing just came to my mind. Is it on purpose that a detection of Google Analytics and similar is more important that the detection of a CMS like wordpress? If we detect GA3 for example, the no data screen will show the tracking code, with the note, that data from GA can be imported, even though the page might also be using wordpress and the information how to integrate it in wordpress might be more important.

@tsteur
Copy link
Member Author

tsteur commented Feb 21, 2023

@sgiehl I had noticed this as well and found it a bit odd that the Integration page is hidden in that case. Since it would be more impactful to see the integration page in the case of WordPress rather than the GA link + tracking code. It may have actually reduced people starting to track.

@bx80 do you remember or can check the original issue if that was on purpose?

@bx80
Copy link
Contributor

bx80 commented Feb 21, 2023

@tsteur I remember there was some discussion about whether the integration or tracking code tab should get priority when a consent manager was detected, as well as whether the UI would need changing to highlight both at once, but it didn't lead to anything definitive. In some cases the consent manager could be more important for getting tracking working than the CMS since most of the consent managers actively block all scripts on the site.

I think the current logic is grouping the consent manager detection with GA3/GA4/GTM which isn't correct.

The intention would have been:
Consent manager detected? ===> Tracking Code Tab
No consent manager, CMS Detected ===> Integrations Tab
No consent manager, no CMS, GA3/GA4/GTM Detected ===> Tracking Code Tab

@tsteur
Copy link
Member Author

tsteur commented Feb 22, 2023

@bx80 @sgiehl fixed that also. And noticed a typo in the wording as well which is now fixed too. Adjusted the tests.

@sgiehl sgiehl merged commit bf5a0aa into 4.x-dev Feb 22, 2023
@sgiehl sgiehl deleted the ga4detect branch February 22, 2023 09:21
@bx80 bx80 added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Development

Successfully merging this pull request may close these issues.

Improve detection of GA3 and GA4 to more accurately suggest correct tracking set up guides
3 participants