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

Update _source Parameter Used by Proxy Event Tracking Function Citing Site Kit as Source of ICE Events & Rename trackEvent #8815

Closed
5 tasks done
10upsimon opened this issue Jun 5, 2024 · 4 comments
Labels
javascript Pull requests that update Javascript code P0 High priority PHP Team S Issues for Squad 1 Type: Enhancement Improvement of an existing feature

Comments

@10upsimon
Copy link
Collaborator

10upsimon commented Jun 5, 2024

Feature Description

#8641 saw the introduction of a helper/proxy style function to facilitate the tracking of events against gtag's. This function is merely an abstraction against the gtag('event') API call.

However, it was incorrectly instructed that the custom event parameter name citing Site Kit as the source of the event be _source. This is an illegal parameter name as said parameter names may only be alphanumeric and contain underscores, but may not begin with an underscore.

This custom _source event parameter name should be updated to be event_source.

No updates to individual event provider scripts are needed, as they all leverage this helper function.

Further to the event parameter name change, the current trackEvent function name should be updated to be something a little further removed from the internal trackEvent function of the same name. A suitable name would be gtagEvent. This will need to be updated across all existing event provider JS scripts, as they currently call the global._googlesitekit?.trackEvent?.() function as part of individual event provider logic.


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

Acceptance criteria

  • The currently named trackEvent function in includes/Core/Conversion_Tracking/Conversion_Tracking.php (created as wp_add_inline_script()) should be updated to be named gtagEvent.
    • All event providers making use of window._googlesitekit.trackEvent() should have their JS code updated to instead reference window._googlesitekit.gtagEvent()
  • The currently named _source parameter passed to gtag() within the (now updated) gtagEvent() function at includes/Core/Conversion_Tracking/Conversion_Tracking.php (created as wp_add_inline_script()) should be updated to be named event_source
    • No event provider updates are required as a result of this change

Implementation Brief

  • Update includes/Core/Conversion_Tracking/Conversion_Tracking.php
    • Find the wp_add_inline_script() call defining window._googlesitekit.trackEvent and rename trackEvent to gtagEvent
    • Update the _source gtag event parameter and rename it to event_source
  • In assets/js/event-providers
    • Update all instances of event provider JS to make use of the renamed function global._googlesitekit?.gtagEvent where there is current usage of global._googlesitekit?.trackEvent

Test Coverage

  • No test coverage updates are required as a result of the changes in this issue.

QA Brief

  • QA For this issue involves validating that all existing supported ICE plugins continue to track their events as expected
    • Activate Site Kit with Ads and/or GA4 modules enabled
    • Enabled the conversionInfra feature flag in Site Kit Tester plugin
    • Enabled Enhanced Conversion Tracking in either Ads or GA4 settings, it is a shared state between the two modules
    • Continue to activate and test the ICE plugins for conversion events, at the time of writing these are:
      • Contact Form 7
      • Mailchimp for WordPress
      • Optin Monster
      • Popup Maker
      • WooCommerce
      • WP Forms
    • Applicable events should be tracked for each
      • Within the gtag('event') API call, the (previously named) _source event parameter should now be listed as event_source as per the screenshot below:

Tag Assistant  Connected  2024-06-06 at 11 14 05 AM

Changelog entry

  • Update conversion event sources to be tracked as event_source instead of __source.
@10upsimon 10upsimon added javascript Pull requests that update Javascript code P0 High priority PHP Team S Issues for Squad 1 Type: Enhancement Improvement of an existing feature labels Jun 5, 2024
@aaemnnosttv aaemnnosttv self-assigned this Jun 5, 2024
@aaemnnosttv
Copy link
Collaborator

LGTM @10upsimon. The only thing missing is the test coverage section. I don't know if we'd need updates here or not but please update with guidance as to whether or not any changes are needed.

@aaemnnosttv aaemnnosttv assigned 10upsimon and unassigned aaemnnosttv Jun 5, 2024
@10upsimon
Copy link
Collaborator Author

Thanks @aaemnnosttv I've updated to indicate that no test updates are required, as we do not have coverage for the helper/proxy function.

@10upsimon 10upsimon assigned aaemnnosttv and unassigned 10upsimon Jun 5, 2024
@aaemnnosttv
Copy link
Collaborator

Great, thanks! IB ✅

@kelvinballoo
Copy link
Collaborator

QA Update ✅

  • Confirming that the events for each plugin is triggered with the relevant event name and the source is 'event_source' and not '_source'.

    • Contact 7 - contact
    • WooCommerce - add_to_cart
    • WPForms - submit_lead_form
    • Mailchimp for WordPress - submit_lead_form
    • Popup Maker - submit_lead_form
    • OptinMonster - submit_lead_form
  • Also tested that there is no tracking when enhance toggle is off

  • Deactivated one of the modules and tracking was still good with the enhance toggle on

Moving ticket to Approval

  • Contact 7 - contact
    Contact 7

  • WooCommerce - add_to_cart

    Woocommerce
  • WPForms - submit_lead_form
    WP forms

  • Mailchimp for WordPress - submit_lead_form
    Mail Chimp

  • Popup Maker - submit_lead_form
    Popup maker

  • OptinMonster - submit_lead_form
    Monster optin

@kelvinballoo kelvinballoo removed their assignment Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
javascript Pull requests that update Javascript code P0 High priority PHP Team S Issues for Squad 1 Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

4 participants