woocommerce / woocommerce-google-analytics-integration

WordPress plugin: Provides the integration between WooCommerce and Google Analytics.
http://wordpress.org/plugins/woocommerce-google-analytics-integration/
170 stars 69 forks source link

Avoid tracking data when user is not opted-in #428

Closed puntope closed 3 months ago

puntope commented 3 months ago

Changes proposed in this Pull Request:

When the user is not opted into WooCommerce tracking we should avoid tracking the data for the extension. However, right now we are not doing that and we track the data without checking if the user is opted-in. This PR fixes that.

Checks:

Screenshots:

Screenshot 2024-05-30 at 12 24 59 Screenshot 2024-05-30 at 12 23 45

Detailed test instructions:

  1. Checkout this PR
  2. Run wp option update woocommerce_allow_tracking "no" in WP CLI or set woocommerce_allow_tracking option as "no"
  3. Run wp wc tracker snapshot --format=yaml in WPCLI
  4. See the wc-google-analytics not appearing in the tracking
  5. Run wp option update woocommerce_allow_tracking "yes" in WP CLI or set woocommerce_allow_tracking option as "yes"
  6. Run wp wc tracker snapshot --format=yaml in WPCLI
  7. . See the wc-google-analytics appearing in the tracking

Additional details:

Changelog entry

Fix - Avoid tracking data when user is not opted-in

puntope commented 3 months ago

WC _Tracks is already preventing to send the data when user is not Opted in. So this check is not necessary.