Menu Close

WooCommerce: Fix Google Search Console “No global identifier provided” Error

default

If you registered your WooCommerce website on Google Search Console for monitoring your SEO efforts and search appearance errors, you probably got this “No global identifier provided (e.g. gtin, brand)” email notification at some stage. I got it too.

Search Console optionally requests you set a unique product GTIN structured data for all your products – I believe in case you wish to sell on Google Shopping – and therefore sends you this error notification whenever a product is missing this.

You could use a WooCommerce GTIN plugin from the WP repo, yes. Or you could be smart, and programmatically set the GTIN to the same value of the product SKU, as long as all your products have a unique SKU value. Today, we will cover the latter. Enjoy!

Google Search Central documentation screenshot, where they show an example of product structured data, which includes the GTIN value.

PHP Snippet: Programmatically Set Product GTIN Based on SKU

/**
 * @snippet       Set WooCommerce Product GTIN
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 7
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_filter( 'woocommerce_structured_data_product', 'bbloomer_set_gtin_from_sku', 9999, 2 );

function bbloomer_set_gtin_from_sku( $markup, $product ) {
	$markup['gtin8'] = str_replace( '-', '', $markup['sku'] );
	return $markup;
}
View Source
Posted in WooCommerce Tips