google / site-kit-wp

Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
https://sitekit.withgoogle.com
Apache License 2.0
1.25k stars 290 forks source link

Script error on the front end with Enhanced conversion tracking enabled #9381

Open wpdarren opened 1 month ago

wpdarren commented 1 month ago

Bug Description

I noticed a script error within Query Monitor. It is appearing on a site that has Ninja Forms activated and enhanced conversion tracking enabled. This appears when I go on the front end.

Missing Dependencies. nf-front-end-deps (missing)

I did test this and the conversation was getting tracked when the form is completed.

I am unsure if this issue also occurs for other third-party plugins that we support, so we might want to spend time going through each plugin and confirming.

image.png

Steps to reproduce

  1. Install and activate the Ninja Forms plugin.
  2. Install and activate the Query Monitor plugin
  3. Set up Site Kit with Analytics and/or Ads module.
  4. Enable Enhanced conversion tracking in Site Kit settings
  5. Go to the front end of the website and observe script error above.

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation Brief

Test Coverage

QA Brief

Changelog entry

nrgyapp commented 1 week ago

I have the same issue. SItekit shouldn't have the option to automatically do this. They all should be disabled and should be optional under connected services.

nrgyapp commented 1 week ago

I was able to disable this with this custom code in function :

add_action( 'wp_enqueue_scripts', 'disable_sitekit_ninja_forms_js' ); function disable_sitekit_ninja_forms_js() { // Check if Ninja Forms is active and the integration is enabled in Site Kit. if ( function_exists( 'ninja_forms_get_form_by_id' ) && ! empty( Google\Site_Kit\Core\Util\Feature_Flags::enabled( 'keyMetrics' ) ) ) { wp_dequeue_script( 'googlesitekit-events-provider-ninja-forms' ); } }

add_action( 'wp_loaded', 'disable_sitekit_ninja_forms_integration' ); function disable_sitekit_ninja_forms_integration() { remove_filter( 'googlesitekit_analytics_events_providers', array( 'Google\Site_Kit\Modules\Analytics\Events\NinjaForms', 'register_event_provider' ) ); }