woocommerce / google-listings-and-ads

Sync your store with Google to list products for free, run paid ads, and track performance straight from your store dashboard.
https://woo.com/products/google-listings-and-ads/
GNU General Public License v3.0
47 stars 21 forks source link

Product ID prefix prevents ID from corresponding with WooCommerce product ID #1770

Open sukafia opened 1 year ago

sukafia commented 1 year ago

Describe the bug:

WooCommerce product IDs only consist of numbers, while the Google Listings & Ads product ID uses a prefix that precedes the numbers:

– WooCommerce product ID: 12345 – GL&A product ID: gla_12345

We're seeing reports regarding the difference in GL&A product IDS from WooCommerce and other analytics integration such as WooCommerce Google Analytics causing a problem with remarketing as the product IDs don't correspond.

According to one user, WooCommerce Google Analytics Integration” plugin instead sends plain product IDs data in gtag events that get captured by Google Ads as you can see here:

(yk6XP1.png).

Due to this difference in product IDs between GL&A and WooCommerce Google Analytics (as well as other analytics integrations), Google Ads cannot find any correspondence between products IDs added by the user in the shopping cart and the merchant feed as you can see here:

EIN2cC.png

sukafia commented 1 year ago

Affected users

https://wordpress.org/support/topic/gla_-a-prefix-before-the-id-product/ https://wordpress.org/support/topic/100-of-id-values-received-dont-match-your-feed-2

scalaxofaiur commented 1 year ago

These are the javascript snippets added by WooCommerce Google Analytics Integration plugin that tracks add_to_cart and view_item events. As you can see the product id is #110635 while the one uploaded in merchant center by Google Listings and Ads would be gla_110635.

This breaks correspondence between Google Analytics segments data and Merchant Center products that is needed for remarketing campaigns.

$( '.single_add_to_cart_button' ).on( 'click', function() {
    gtag( 'event', 'add_to_cart', { 
            'event_category': 'ecommerce', 
            'event_label': '#110635', 
            'items': [ {
            'id': '#110635',
            'name': 'Disco Freno Mtb Saccon 160mm 6 fori',
            'quantity': $( 'input.qty' ).val() ? $( 'input.qty' ).val() : '1'
        } ] 
    } );
});
gtag( 'event', 'view_item', {
    'items': [ {
        'id': '#110635',
        'name': 'Disco Freno Mtb Saccon 160mm 6 fori',
        'category': 'Altre marche/Componenti MTB/Dischi Freno',
        'price': '14.90',
    } ]
} );
scalaxofaiur commented 1 year ago

The best option, in my honest opinion, would be to add a setting that lets the user decide wich prefix use for product ids.

This would give maximum compatibility over different plugins.

sukafia commented 1 year ago

New review/feedback

demiah commented 1 year ago

I have the same problem. It's interesting not solved yet. This problem is a killer for effective ad campaigns. Someone immediately should fix it.

vilainocencia commented 1 year ago

How can such a serious problem go unsolved for almost a year. We're throwing money down the drain with remarketing campaigns

shameemreza commented 1 year ago

Another report here: https://wordpress.org/support/topic/id-merchant-center-gla_

Babylon1999 commented 1 year ago

zd-6735502

sukafia commented 1 year ago

If you're experiencing this issue, here is a code snippet that would sync products without the gla_ prefix:

// Sync products without GLA prefix.
add_action(
    'woocommerce_gla_get_google_product_offer_id',
    function ( $mc_id, $product_id ) {
        return (string) $product_id;
    },
    10,
    2
);

Please read How do I remove the gla_ prefix from synced products for additional instructions.

It's worth mentioning that our developers are looking into the best way to address this issue, ensuring Google Listings & Ads data matches that of Google Analytics and other integrations.

younan70 commented 9 months ago

If you're experiencing this issue, here is a code snippet that would sync products without the gla_ prefix:

// Sync products without GLA prefix.
add_action(
  'woocommerce_gla_get_google_product_offer_id',
  function ( $mc_id, $product_id ) {
      return (string) $product_id;
  },
  10,
  2
);

Please read How do I remove the gla_ prefix from synced products for additional instructions.

It's worth mentioning that our developers are looking into the best way to address this issue, ensuring Google Listings & Ads data matches that of Google Analytics and other integrations.

where I enter this code ?

Choo-lux commented 3 months ago

I just added this code and its only randomly removing the gla

Same log file:

2024-08-09T05:54:20+00:00 Debug Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductSyncer::update_by_batch_requests Submitted 100 products: [{"woocommerce_id":259643,"google_id":"online:en:AU:gla_259643"},

2024-08-09T05:54:46+00:00 Debug Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductSyncer::update_by_batch_requests Submitted 100 products: [{"woocommerce_id":259743,"google_id":"online:en:AU:259743"},{"woocommerce_id":259744,"google_id":"online:en:AU:259744"},

SKR2004 commented 3 months ago

Can someone explain to me where to add the code to remove the gla prefix? In which file or place to put the code

SKR2004 commented 3 months ago

He is working on a file. functions

SKR2004 commented 3 months ago

With the new update

The status readings for events in Google Analytics have become

For each event twice

I don't know where the problem is, but when the universe is stopped

The events are once

And when it is turned on, they become twice

Is anyone facing the same problem?

Choo-lux commented 3 months ago

I ended up removing the $slug from google-listings-and-ads\src\Product\WCProductAdapter.php

I saw that the code might be this though:

add_action( 'woocommerce_gla_get_google_product_offer_id', function ( $mc_id, $product_id ) { return (string) strreplace('gla', '', $product_id); }, );

SKR2004 commented 3 months ago

Works once and every update It's up to putting gla tag in product data Tired of the situation All our money went into the sea To run a remarketing campaign Everything is gone From here I say to all those responsible for this add-on We will hold you accountable on the Day of Judgment

SKR2004 commented 2 months ago

Choo-lux

Do I include the code in the functions file?

Choo-lux commented 2 months ago

yes, but install the snippets plugin and add it there.

SKR2004 commented 2 months ago

image