magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Adding Gtag consent

Open rafaelstz opened this issue 1 year ago • 2 comments

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)

  1. https://github.com/magento/magento2/issues/38039

Manual testing scenarios (*)

  1. Configure cookie consent in Magento using GTM.
  2. Add GTM scripts that requires consent and another one that doesn't require consent.
  3. 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.
  4. Add a GA script.
  5. Go to the website and doesn't accept the cookies banner.
  6. Browsering through the website you will see that data has been pushed to GA, but anonymously, following the lasted international cookies policies.
  7. Accept the cookie banner and continue browsering.
  8. 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)

rafaelstz avatar Oct 03 '23 19:10 rafaelstz

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:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. 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.

m2-assistant[bot] avatar Oct 03 '23 19:10 m2-assistant[bot]

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

ricomonkeon avatar Feb 26 '24 12:02 ricomonkeon