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

Add gtag consent mode v0 support #2290

Merged
merged 3 commits into from
Mar 4, 2024
Merged

Add gtag consent mode v0 support #2290

merged 3 commits into from
Mar 4, 2024

Conversation

tomalec
Copy link
Member

@tomalec tomalec commented Mar 1, 2024

Changes proposed in this Pull Request:

Add the minimalistic implementation to add support for Google Consent mode

We want to add MVP ASAP before Google starts penalizing merchants without this setup. (pcTzPl-25o-p2)

This PR adds a basic default and documents how to customize/extend it.

Screenshots:

image

Detailed test instructions:

  1. Build, install, activate the extension
  2. Deactivate Google Analytics Integration extension
  3. Open Tag assistant
  4. Visit shop page
  5. You should see consent mode set up
    image
  6. Read the docs, check if they are explanatory enough
  7. Try the following snippet
add_filter(
    'woocommerce_gla_gtag_consent',
    function( $old_config ) {
        $additional_config = "
        gtag( 'consent', 'default', {
            analytics_storage: 'granted',
            ad_storage: 'granted',
            ad_user_data: 'denied',
            ad_personalization: 'denied',
            region: ['PL'], // <--------- SET IT TO YOUR REGION
        } );
        ";
        return $old_config . $additional_config;
    }
);
  1. You should see another consent entry specified
    image

Additional details:

Changelog entry

Add - Google Analytics consent mode support.

@tomalec tomalec self-assigned this Mar 1, 2024
@tomalec tomalec requested a review from a team March 1, 2024 19:33
@github-actions github-actions bot added changelog: add A new feature, function, or functionality was added. type: enhancement The issue is a request for an enhancement. labels Mar 1, 2024
@tomalec tomalec requested a review from martynmjones March 1, 2024 19:33
Copy link

codecov bot commented Mar 4, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 63.8%. Comparing base (f9a5637) to head (de77d2b).

Additional details and impacted files

Impacted file tree graph

@@                                Coverage Diff                                 @@
##             update/global-site-tag-for-analytics-version-2   #2290     +/-   ##
==================================================================================
- Coverage                                              63.9%   63.8%   -0.0%     
- Complexity                                             4196    4197      +1     
==================================================================================
  Files                                                   455     455             
  Lines                                                 17853   17859      +6     
==================================================================================
  Hits                                                  11400   11400             
- Misses                                                 6453    6459      +6     
Flag Coverage Δ
php-unit-tests 63.8% <0.0%> (-<0.1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/Proxies/GoogleGtagJs.php 0.0% <ø> (ø)
src/Google/GlobalSiteTag.php 0.0% <0.0%> (ø)

Copy link
Contributor

@martynmjones martynmjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @tomalec, thanks for your work on consent in GLA!

I've left two comments on the docs but all is working well so LGTM ✅

Base automatically changed from update/global-site-tag-for-analytics-version-2 to develop March 4, 2024 11:45
@tomalec tomalec merged commit 119ed3b into develop Mar 4, 2024
11 checks passed
@tomalec tomalec deleted the add/gtag-consent branch March 4, 2024 11:45
@jorgemd24 jorgemd24 mentioned this pull request Mar 5, 2024
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: add A new feature, function, or functionality was added. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants