magento2
magento2 copied to clipboard
Adding Gtag consent
Description (*)
This PR is implementing Gtag consent mentioned in the feature request below.
It doesn't include yet:
- Checkbox to determine which cookies to accept.
- Updating the Gtag after the customer browser and accepts cookies to get historical behavioral data pushed.
Related Pull Requests
Fixed Issues (if relevant)
- https://github.com/magento/magento2/issues/38039
Manual testing scenarios (*)
- Configure cookie consent in Magento using GTM.
- Add GTM scripts that requires consent and another one that doesn't require consent.
- When you start browsering in the website without accepting the cookie consent banner, it won't inject your GTM's script that doesn't require consent. All GTM scripts are blocked.
- Add a GA script.
- Go to the website and doesn't accept the cookies banner.
- Browsering through the website you will see that data has been pushed to GA, but anonymously, following the lasted international cookies policies.
- Accept the cookie banner and continue browsering.
- You will see customer data pushed to your GA account.
Questions or comments
Learn more about consent mode → https://support.google.com/analytics/... Check out the demo code for this series → https://github.com/googleanalytics/ga... Youtube Set up consent mode in Google Analytics → https://www.youtube.com/...
Contribution checklist (*)
- [x] Pull request has a meaningful description of its purpose
- [x] All commits are accompanied by meaningful commit messages
- [x] All new or changed code is covered with unit/integration tests (if applicable)
- [x] README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
- [ ] All automated tests passed successfully (all builds are green)
Hi @rafaelstz. Thank you for your contribution! Here are some useful tips on how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:
-
@magento give me test instance
- deploy test instance based on PR changes -
@magento give me 2.4-develop instance
- deploy vanilla Magento instance
:exclamation: Automated tests can be triggered manually with an appropriate comment:
-
@magento run all tests
- run or re-run all required tests against the PR changes -
@magento run <test-build(s)>
- run or re-run specific test build(s) For example:@magento run Unit Tests
<test-build(s)>
is a comma-separated list of build names.
Allowed build names are:
-
Database Compare
-
Functional Tests CE
-
Functional Tests EE
-
Functional Tests B2B
-
Integration Tests
-
Magento Health Index
-
Sample Data Tests CE
-
Sample Data Tests EE
-
Sample Data Tests B2B
-
Static Tests
-
Unit Tests
-
WebAPI Tests
-
Semantic Version Checker
You can find more information about the builds here :information_source: Run only required test builds during development. Run all test builds before sending your pull request for review.
For more details, review the Code Contributions documentation. Join Magento Community Engineering Slack and ask your questions in #github channel.
Thanks for your work on this. One thing it seems to be lacking at the moment are the parameters for V2, which have been introduced since the original feature request. I believe that without these, it won't be compliant. https://developers.google.com/tag-platform/security/guides/consent?consentmode=advanced#upgrade-consent-v2