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

Consider using SKU as item_id instead of the WordPress post ID #471

Closed
martincpt opened this issue Oct 12, 2024 · 3 comments
Closed

Consider using SKU as item_id instead of the WordPress post ID #471

martincpt opened this issue Oct 12, 2024 · 3 comments
Labels
type: enhancement The issue is a request for an enhancement.

Comments

@martincpt
Copy link

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.

@martincpt martincpt added the type: enhancement The issue is a request for an enhancement. label Oct 12, 2024
@mikkamp
Copy link
Contributor

mikkamp commented Nov 7, 2024

Hi @martincpt

It is correct that the Product ID is used by default. However there is a setting to choose what kind of identifier is used. Can you go to WooCommerce > Settings > Integrations > Google Analytics and confirm the Product Identification is set to SKU.

Image

@mikkamp mikkamp closed this as completed Nov 7, 2024
@martincpt
Copy link
Author

Hi @mikkamp

I can confirm that the Product Identification is set to SKU under WooCommerce > Settings > Integrations > Google Analytics. However, it still appears to use the post ID regardless of this setting. Could this be caused by using WCML (WooCommerce Multilingual)?

@mikkamp
Copy link
Contributor

mikkamp commented Nov 11, 2024

Thanks for clarifying. If that setting is enabled it just uses the default WooCommerce function to retrieve the SKU and falls back to the ID prefixed with a # if the SKU is not available. So there isn't a whole lot the extension itself does there.

It's possible that WooCommerce Multilingual could interfere with which SKU is returned, you might want to check with their developers if there is a specific way to configure the SKU, or how it should be setup for multiple languages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

No branches or pull requests

2 participants