-
Hi,
I need to update GTINs for rich results, google schema, etc.
I do not need any additional columns as GTIN since my SKU is my GTIN.
All the products which have GTINs have been updated as SKU for those products.All I need to do is tell google to refer to my SKU as my GTIN. How do I do that?
-
Hello,
Thank you for reaching out to us regarding updating GTINs for rich results and Google schema using your SKUs as GTINs. To map your SKU as GTIN for Google Rich Results Schema, you can follow these steps:
- Go to your WordPress Dashboard.
- Navigate to Rank Math SEO and click on General Settings.
- Select WooCommerce from the options.
- Look for the Global Identifier section.
- In the Global Identifier drop-down list, choose the appropriate identifier that matches your SKU format (e.g., GTIN-12, GTIN-13).
- Enable the Global Identifier Label by toggling the button to display the Global Identifier on the Product page.
Here is an example screenshot of how to configure the Global Identifier setting in Rank Math WooCommerce settings:
By following these steps, you can inform Google to consider your SKUs as GTINs for your products in the rich results and Google schema.
If you encounter any issues or need further assistance, please feel free to reach out to our support team.
We are here to help!
Best regards.
Sources:
Adding GTIN, ISBN & MPN Schema to WooCommerce Products Using Rank Math » Rank Math
Product Schema Type » Rank Math
Google Search Console Missing Field Warning » Rank MathHi,
There is no section called Global Identifier in WordPress Dashboard > Rank Math SEO > General Settings > WooCommerce
I have rank math free. I do not need a separate GTIN field. I just want to be able to re-use the SKU field as GTIN field.
Is there a way to do that from functions.php, please?
Hello,
Apologies for the confusion, but the option our bot shared is available with Rank Math PRO only.
However, you can use and modify this filter to fetch the SKU value from the database and set it to your GTIN:
add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) { global $product; $entity['gtin'] = $product->get_sku(); return $entity; });
Here’s a way to apply the filter on your site:
https://rankmath.com/kb/filters-hooks-api-developer/Hope that helps.
Thank You very much. Appreciate your help even though I am using the free version. I will definitely choose Rank Math Pro when I am generating enough revenue 🙂
A Quick question in this regard – Let’s say that I am selling bread. I want to sell 10 slices and 20 slices. I should have 3 products (1 variable, 2 variations) in the eyes of woocommerce.
For the 10 slice pack the GTIN is 0010 and for the 20 slice the GTIN is 0020.
Lets say I plug in those GTINs for both the variations.Bread (variable): GTIN = NA
– 10 slices : GTIN = 0010 (variation)
– 20 slices : GTIN = 0020 (variation)But since google will recognize the canonical (variable) link, even if I plug in the GTINs for each of the slices, the main bread variable GTIN still remains NA.
What should I do? – Should I leave that main variable product GTIN empty or fill in with both the GTINs one after the other [0100, 0200]. What is the best from SEO and Product Optimization standpoint?
Hello,
In your schema, you can also set each variation with its own GTIN. Here’s a code you can follow:
add_filter('rank_math/snippet/rich_snippet_product_entity', function ($entity) { if (!is_product()) { return $entity; } $product = wc_get_product(get_the_ID()); if (!$product->is_type('variable')) { return $entity; } $variations = $product->get_available_variations(); if (!empty($variations)) { $offers = []; foreach ($variations as $variation) { $price_valid_until = get_post_meta($variation['variation_id'], '_sale_price_dates_to', true); $offers[] = [ '@type' => 'Offer', 'description' => strip_tags($variation['variation_description']), 'price' => $variation['display_price'], 'priceCurrency' => get_woocommerce_currency(), 'availability' => $variation['is_in_stock'] ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock', 'priceValidUntil' => $price_valid_until ? date_i18n('Y-m-d', $price_valid_until) : '2025-12-31', 'itemCondition' => 'http://schema.org/NewCondition', 'url' => $variation->get_permalink(), 'gtin' => $variation['sku'] ]; } } $entity['offers'] = $offers; return $entity; });
Let us know if that helps.
Thanks for the code.
My question was more towards SEO purposes.
Does google list individual variations of the product or the canonical variable product?
If the canonicals are listed, then how should I incorporate merging GTINs of its 2 variations?
Does the above code ask google to list the individual variations of products instead of the canonical variable product?Hello,
Google generally prefers to list the canonical (parent) product but may show variations in certain cases (for example, in specific search phrases on the SERP). Regarding GTINs, you can also provide unique GTINs for each variation for optimal SEO. The provided code ensures that each variation includes its own GTIN, enhancing product visibility and accuracy in search results.
Don’t hesitate to get in touch with us if you have any other questions.
Hi, please respond to the above question. Thanks!
Hello,
The first code will only set the main SKU as the GTIN for single products. It will not work for the variable products. You will have to use the second filter for them.
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.
The ticket ‘Map SKU as GTIN for Google Rich Results Schema’ is closed to new replies.