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

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
 * @community     https://businessbloomer.com/club/
 */

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;
}

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: Add Second Description @ Product Category Pages
    In terms of SEO, if you’re trying to rank your product category pages, you really need to make the most of the default WooCommerce product category “description” and “thumbnail”. Most themes, if compatible with WooCommerce, will show this content right below the product category name and above products. Nothing new so far. But what if […]
  • WooCommerce: Hide Category & Tag @ Single Product Page
    SKU, Category list and Tag list on the WooCommerce single product page are called “product meta”. We already saw how to hide just the SKU (while leaving Cats and Tags there), so in this “episode” we will study how to do the opposite i.e. keeping the SKU there while hiding Cats and/or Tags. If you […]
  • WooCommerce: Should I Noindex Product Tag Pages?
    Ah, yet another million dollar question. If you have organized your WooCommerce products properly, you have “N” product categories and “M” product tags, where “M > N” (actually, if there were such a thing in algebra, it should be “M >>> N” as each product should be assigned to 1 category and multiple tags). This […]
  • WooCommerce: Hide SKU @ Single Product Page
    This is a very common task. As a WooCommerce store manager, sometimes you need to hide the SKU field on the single product page, while keeping it in the backend (Product Edit page) for order tracking and product import/export purposes. Here’s a simple snippet you can use to remove the SKU immediately ๐Ÿ™‚
  • WooCommerce: Show SKU @ Cart, Checkout, Order & Emails
    When SKU matters to the end user, displaying it in the Cart page, Checkout page, Thank you page, My Account View Order page and Order Emails under the item name is a must. Ideal for B2B businesses and international brands, this simple customization can help you learn how to add any sort of content under […]

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

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

  1. FYI – The PHP Error Log is telling me “PHP Warning: Undefined array key “sku” in …../wp-content/themes/flatsome-child/functions.php on line 424″
    I’ll comment this out, but if you have a fix I’d love to know it.
    Thank you!

    1. I guess the problem is here – in case SKU is not set this may throw a warning:

      $markup['gtin8'] = str_replace( '-', '', $markup['sku'] );

      You could try this alternative:

      $markup['gtin8'] = isset( $markup['sku'] ) ? str_replace( '-', '', $markup['sku'] ) : '';
Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *