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 support for Google Analytics for WooCommerce version 2.0.0 #2287

Merged

Conversation

martynmjones
Copy link
Contributor

Changes proposed in this Pull Request:

⚠️ Requires: woocommerce/woocommerce-google-analytics-integration#322

Google Analytics for WooCommerce updates how the Global Site Tag is loaded so this PR updates the integration in GLA to support version 2.0.0 and above while maintaining backwards compatibility.

The main difference is that instead of simply adding a script to the page with a call to gtag, we now use wp_add_inline_script and the Google Analytics for WooCommerce script handle where applicable.

Detailed test instructions:

  1. Build Google Analytics for WooCommerce from #322
  2. Complete onboarding if needed
  3. Debug a GLA test site via TagAssistant
  4. Confirm the GLA tag is found
  5. Confirm that the GLA events are sent:
    • page_view
    • view_item
    • purchase
    • conversion

Changelog entry

Add - Support for Google Analytics for WooCommerce version 2.0.0 and above

@martynmjones martynmjones self-assigned this Feb 29, 2024
@github-actions github-actions bot added the changelog: update Big changes to something that wasn't broken. label Feb 29, 2024
Copy link

codecov bot commented Feb 29, 2024

Codecov Report

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

Project coverage is 63.9%. Comparing base (a6e8a4c) to head (f9a5637).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             develop   #2287     +/-   ##
===========================================
+ Coverage       62.2%   63.9%   +1.6%     
- Complexity      4190    4196      +6     
===========================================
  Files            748     455    -293     
  Lines          21547   17853   -3694     
  Branches         532       0    -532     
===========================================
- Hits           13406   11400   -2006     
+ Misses          7690    6453   -1237     
+ Partials         451       0    -451     
Flag Coverage Δ
js-unit-tests ?
php-unit-tests 63.9% <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% <0.0%> (ø)
src/Google/GlobalSiteTag.php 0.0% <0.0%> (ø)

... and 293 files with indirect coverage changes

@martynmjones martynmjones requested a review from a team February 29, 2024 19:40
);
}
);
if ( version_compare( \WC_GOOGLE_ANALYTICS_INTEGRATION_VERSION, '2.0.0', '>=' ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

🚧
I don't get into this line when I run it with the new GA, as the one above returns false.
GLA still expect the old GA settings to be there https://github.com/woocommerce/google-listings-and-ads/blob/3a423a2d5cfca64486c74cf41905d01db1cc4c52/src/Proxies/GoogleGtagJs.php#L24:L33

The latest GA does not set ga_gtag_enabled

Copy link
Member

Choose a reason for hiding this comment

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

tomalec added a commit that referenced this pull request Mar 1, 2024
…analytics-version-2-enabled

Consider `ga_gtag_enabled=yes` for  WCGAI >= 2
Copy link
Member

@tomalec tomalec left a comment

Choose a reason for hiding this comment

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

Reviewed the code, tested locally LGTM, thanks! :)

@martynmjones martynmjones merged commit 439ff3c into develop Mar 4, 2024
11 checks passed
@martynmjones martynmjones deleted the update/global-site-tag-for-analytics-version-2 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: update Big changes to something that wasn't broken.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants