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 plugin version, Google Merchant Center account ID, and Google Ads account ID to frontend pageview tracking events #2200

Merged
merged 4 commits into from
Jan 24, 2024

Conversation

eason9487
Copy link
Member

Changes proposed in this Pull Request:

Project thread: pcTzPl-20H-p2

This PR implements another JS part of the project. The target is to attach the following properties when Woo core sends pageview tracking events related to this plugin's pages:

  • Plugin Version
  • Google Merchant Center account ID if connected
  • Google Ads account ID if connected

To achieve the above target, this PR:

  • Rename the prepareEventProperties in tracks.js to prepareEventProperties and export it.
  • Add base properties to the plugin's page view tracking events via the woocommerce_tracks_client_event_properties filter.
  • Extra change: Set the mocked globals.wcAdminFeatures.navigation to false for jest as the new WooCommerce navigation experience is currently on hold and disabled forcibly.
  • Extra change: In js/src/index.js, adjust the namespace string that calls addFilter to match its uniquely identified convention.
    • Quoted from @wordpress/hooks doc:

      One notable difference between the JS and PHP hooks API is that in the JS version, addAction() and addFilter() also need to include a namespace as the second argument. Namespace uniquely identifies a callback in the form vendor/plugin/function.

Screenshots:

1

Detailed test instructions:

  1. Go to WooCommerce > Settings > Advanced > Woo.com. Tick off the Enable tracking option.
    • This tracking event can't be tested via the Console tab and localStorage.setItem( 'debug', 'wc-admin:*' ).
  2. Open the Network tab of the browser DevTool. Filter All requests and keyword t.gif.
  3. Go to this plugin's admin pages and inspect the requests in the Network tab to check if all wcadmin_page_view tracking events have the base properties.
    * - gla_version: Plugin version
    * - gla_mc_id: Google Merchant Center account ID if connected
    * - gla_ads_id: Google Ads account ID if connected
  4. Go to other admin pages such as Marketing > Overview. Check if the wcadmin_page_view tracking events sent from other pages don't have the base properties.

Changelog entry

@eason9487 eason9487 requested a review from a team January 17, 2024 15:02
@eason9487 eason9487 self-assigned this Jan 17, 2024
@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 Jan 17, 2024
Copy link
Contributor

@jorgemd24 jorgemd24 left a comment

Choose a reason for hiding this comment

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

Thanks @eason9487, I followed the steps mentioned in the PR and I see that the gla_mc_id and the gl_ads_id and gla_version properties are added to the event. I disconnected the Ads and the MC accounts and reconnected them and everything works well. I tested the events in pages that does not belong to the GLA plugins and I see that the new properties are not added, so LGTM 👍

Base automatically changed from add/base-properties-frontend-tracks to develop January 24, 2024 02:20
@eason9487 eason9487 merged commit 9591b88 into develop Jan 24, 2024
5 checks passed
@eason9487 eason9487 deleted the add/pageview-base-properties-frontend-tracks branch January 24, 2024 02:24
@jorgemd24 jorgemd24 mentioned this pull request Jan 30, 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