No global identifier provided (e.g., gtin, mpn, isbn)

#23191
  • Resolved Barry
    Rank Math pro

    Hello Support,

    WooCommerce products e.g. The Cheeky Possum which have not been changed in months are now generating warnings in Google Search Console. I guess Google in some way have decided sku is no longer a substitute for gtin?

    In attempting to fix this I found the Rich Snippits filter:

    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
    	return [];
    }, 10, 2);

    However, I’m unclear what I should do here if this might allow me to add the gtin ?

    In further researching I found:

     /**
      * Customizing structured data using WooCommerce filters
      */
     add_filter( 'woocommerce_structured_data_product','add_gtin',10,2);
     function add_gtin( $markup, $product ) {
        $markup['gtin'] = str_replace('-', '',$markup['sku']);
        return $markup;
    };

    This nicely added to the $markup array, but has no effect on what is output under:
    <!-- Search Engine Optimization by Rank Math - https://s.rankmath.com/home -->
    in the script:
    <script type="application/ld+json">

    What should I be doing and where to include:

    "http://schema.org/gtin": [
          {
            "@value": "9780987645104"
          }
        ],

    in the Product data?

    Many thanks,
    Barry

Viewing 15 replies - 1 through 15 (of 15 total)
  • Todd
    Rank Math free

    Hi Barry,

    Thanks a lot for your query and we are so sorry about the trouble this must have caused.

    When you add this code to your theme’s functions.php file:

    /**
      * Customizing structured data using WooCommerce filters
      */
     add_filter( 'woocommerce_structured_data_product','add_gtin',10,2);
     function add_gtin( $markup, $product ) {
        $markup['gtin'] = str_replace('-', '',$markup['sku']);
        return $markup;
    };

    That will automatically use your product SKU as your GTIN.

    There is no need to fiddle with the code further. To change the GTIN, you only have to change the SKU using WooCommerce product editor UI.

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Hi Todd,

    Thank you for your response, however, as I said originally, while the code adds to the $markup array, it has no effect on what is output to the ld+json script and thus Google Search Console is blind to it.

    I’m still seeing:
    <script type="application/ld+json">[{"@context":"https:\/\/schema.org\/","@type":"Product","sku":"978-0-9876451-0-4","name":"The Cheeky Possum","description":"A soft cover A4 landscape illustrated children's story about a possum who enjoys scaring people in the night time.\u00a0 Contains a dozen beautifully illustrated double page spreads of story and pictures.","releaseDate":"2018-03-29T10:42:24+11:00","brand":{"@type":"Thing","name":"Data Stream Pty Limited"},"url":"http:\/\/10.0.1.2\/child\/the-cheeky-possum\/","category":"Book Publisher","weight":{"@type":"QuantitativeValue","unitCode":"GRM","value":"180"},"height":{"@type":"QuantitativeValue","unitCode":"CMT","value":".4"},"width":{"@type":"QuantitativeValue","unitCode":"CMT","value":"30"},"depth":{"@type":"QuantitativeValue","unitCode":"CMT","value":"21"},"image":{"@type":"ImageObject","url":"http:\/\/10.0.1.2\/child\/wp-content\/uploads\/2018\/03\/CheekyPossum-cover.jpg","width":1123,"height":794},"aggregateRating":{"@type":"AggregateRating","ratingValue":"5.00","bestRating":"5","ratingCount":1,"reviewCount":1},"review":[{"@type":"Review","@id":"http:\/\/10.0.1.2\/child\/the-cheeky-possum\/#li-comment-499","description":"Delightful children's picture and story book. Full of light and shadow.","datePublished":"2019-10-03 10:18:17","reviewRating":{"@type":"Rating","ratingValue":5},"author":{"@type":"Person","name":"Barry Brunning","url":""}}],"offers":{"@type":"Offer","price":"15.00","priceCurrency":"AUD","availability":"https:\/\/schema.org\/InStock","itemCondition":"NewCondition","seller":{"@type":"Organization","@id":"http:\/\/10.0.1.2\/child\/","name":"Data Stream Pty Limited","url":"http:\/\/10.0.1.2\/child","logo":"http:\/\/10.0.1.2\/child\/wp-content\/uploads\/2018\/03\/DSdelta.png"},"url":"http:\/\/10.0.1.2\/child\/the-cheeky-possum\/","priceValidUntil":""},"additionalProperty":[{"@type":"PropertyValue","name":"pa_isbn","value":"978-0-9876451-0-4"},{"@type":"PropertyValue","name":"pa_publisher","value":"Data Stream Pty Limited"},{"@type":"PropertyValue","name":"pa_illustrator","value":"Paige Tilley, Rhiannon Tilley"},{"@type":"PropertyValue","name":"pa_seller","value":"Data Stream Pty Limited"},{"@type":"PropertyValue","name":"pa_seller_abn","value":"25 001 659 178"}]}]</script>
    with no sign of “gtin”.

    I have cleared the browser cache and as you will see this is a localhost test, so there’s no Cloudflare or hosting caches to confuse the issue.

    Maybe Rank Math is looking at $markup before the filter executes?

    I even tried replacing $markup[‘sku’] with $markup[‘gtin’] in case some array structure assumptions were being made (although I’m sure Rank Math developers do not commit such sins 😊). I’m confident in what I’ve done to $markup because I’ve checked the variable in phpStorm debugging mode.

    Best regards,
    Barry

    Hello Again Todd,

    Well, now there’s a thing, just updated to 10.0.36.1 and voilà, I now have ‘gtin’ and not ‘sku’. Wonders will never cease.

    Maybe some form of database update took place? I had previously tried saving the product, but to no avail. Anyway …

    Thank you,
    Barry

    Hello Once More Todd,

    Oh dear!, Should have checked with the Google Structured Data Testing Tool before shouting Eureka. It’s more unhappy than ever and now has three warnings:

    warningbrand	
    The brand field is recommended. Please provide a value if available.
    warningsku	
    The sku field is recommended. Please provide a value if available.
    warning	
    This Product is missing a global identifier (e.g. isbn, mpn or gtin8). Please see documentation for valid identifiers.

    1. I’ll look into why we’ve lost brand in the update, maybe just needs re-selecting.
    2. ‘sku’ I can put back, so no problem there. As I said I’d replaced it with ‘gtin’.
    3. Although ‘gtin’ is mentioned in schema.org, maybe I need ‘isbn’? Will research further.

    When I’ve found out more I’ll raise a new ticket if necessary.

    Never easy.

    Best regards,
    Barry

    Hello,

    Thanks for the follow up and sorry for the inconvenience caused.

    We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WP logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.`

    Hello Michael,

    Thank you to you, Todd and all your colleagues at Rank Math for perseverance with this issue. It is appreciated.

    I will follow the advice you’ve given, however, we have now arrived at the holiday season with family arriving today from all parts and for the present that becomes my priority. Hopefully, you will indulge me if I return to this after a short break.

    I see from the screen shot that you have a ‘Ticket Resolution’ prompt that I as a user don’t see? Maybe this ticket should revert to ‘not resolved’?

    Thank you again,
    Barry

    Hi Barry,

    Thanks for the follow up.

    I will keep the ticket open so that we can resume with debugging after the Christmas break.

    Happy holidays!

    Patrick
    Rank Math business

    I have the same problem and I urgently need the GTIN in schema for my products. I would be very happy about an update!

    Hello Patrick,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    I’d love to debug this issue and try to get to the bottom of the same.

    Please edit the first post on this ticket and include your WP logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello Michael and Todd,

    Hope you were able to take a holiday break. I’m back and refreshed, happily.

    So the code:

    
    /**
      * Customizing structured data using WooCommerce filters
    */
    add_filter( 'woocommerce_structured_data_product','add_gtin',10,2);
    function add_gtin( $markup, $product ) {
    
       $markup['gtin'] = str_replace('-', '',$markup['sku']);
       
       return $markup;
    };

    is under the plugin theme-customisations.php in custom/functions.php at the end.

    However, as stated this does not flow through to a ‘gtin’ in the structured data.

    Many thanks,
    Barry

    Hello,

    Thank you for contacting Rank Math today.

    I have added the following code to the customization plugin on the same location to fix the errors:

    /**
     * Filter to modify schema data.
     *
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
        if(isset($entity['isRelatedTo'])){
           unset($entity['isRelatedTo']);
    	   $entity['gtin13'] = str_replace('-', '',$entity['sku']);
    	   //$entity['offers']['priceValidUntil'] = '2020-12-31';
           return $entity;
        }
    	
       
        return $entity;
    });

    You can fix the ‘priceValidUntil’ warning by assigning an expiry date for sale price on each of your WC products or you can remove the comment on the code above to set the expiry date to the end of this year for all products.

    Looking forward to helping you. Thank you.

    ​​​​​​

    Patrick
    Rank Math business

    I can’t find the “sensitive data” field!?

    Screenshot:
    https://ibb.co/CbJjQyf

    • This reply was modified 4 years, 3 months ago by Patrick.

    Hello Michael,

    Well the fix didn’t work initially. There was no ‘gtin13’ property manifesting in <script type=”application/ld+json”> on the product page. So I wondered about:
    if(isset($entity['isRelatedTo']))
    and decided I couldn’t see why it would be set. So now I have:

    /**
     * Filter to modify schema data.
     *
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
       
    	$entity['gtin13'] = str_replace('-', '',$entity['sku']);
    	$entity['offers']['priceValidUntil'] = '2020-12-31';
    	return $entity;
    });

    which works fine. I’ve extracted the script data from the page and it passes in the Google Structured Data Testing Tool. Terrific.

    And thank you for the ‘priceValidUntil’ property. WooCommerce only populates this with a sale price and we don’t have sale prices, so that’s an excellent solution for us.

    RankMath’s support has been diligent. Thank you.
    Barry

    Hi Barry,

    Thanks for the reply.

    I am glad that this is now resolve 🙂 Don’t hesitate to contact us for any other questions, comments or suggestions!


    @post16
    I am sorry for the problem. The sensitive data section is only available to the OP. To be able to enter a gtin value to your products, you can install the following plugin to add a field to the product edit page:
    https://wordpress.org/plugins/product-gtin-ean-upc-isbn-for-woocommerce/

    For additional help in this, please create a new ticket and share some more details.

    Thank you.

    • This reply was modified 4 years, 3 months ago by Michael Davis.
Viewing 15 replies - 1 through 15 (of 15 total)

The ticket ‘No global identifier provided (e.g., gtin, mpn, isbn)’ is closed to new replies.