Consider using SKU as item_id
instead of the WordPress post ID
#471
Labels
type: enhancement
The issue is a request for an enhancement.
User Story
Currently, your plugin uses the WordPress post ID as the
item_id
sent to Google Analytics for events such as "add to cart" or "purchase."This is problematic because the product ID isn't always permanent, and the Google Analytics tracking may become inaccurate if products are re-uploaded, or if the site is reinstalled. This results in inconsistent tracking.
Desired Solution
Since product/post IDs can change—especially when products are re-uploaded into new entries or when the site is reinstalled—using the SKU would be a more reliable choice.
SKUs can be reused across sites, whereas product IDs are not necessarily consistent.
Even the Google Analytics documentation recommends using SKU values in their examples:
Google Analytics Events Documentation
Technical
The SKU should be attached to the product data, which is available under the window.ga4w variable.
The text was updated successfully, but these errors were encountered: