• Resolved dezpfab

    (@dezpfab)


    Hi,

    I am building a review website. On a page, I have 2 kind of reviews :
    – Author based
    – Customer based (cf. Site reviews)

    I am trying to have the best Schema possible. I’ve created a JSON-LD using GTM schema with the following structure :

    	    "@context": "https://schema.org",
    	    "@type": "Review",
    	    "author": {
    	        "@type": "Person",
    	        "name": "{{SCHEMA - Author}}"
    	    },
    	    "url": "{{Page URL}}",
    	    "datePublished": "2014-03-13T20:00",
    	    "publisher": {
    	        "@type": "Organization",
    	        "name": "website",
    	        "sameAs": "https://website.com"
    	    },
    	    "description": "",
    	    "inLanguage": "fr",
    	    "itemReviewed": {
    	        "@type": "Product",
    	        "name": "{{SCHEMA - Product Name}}",
    	        "image": "{{SCHEMA - Logo}}",
                    "aggregateRating": {
                    "@type": "AggregateRating",
                    "ratingValue": "88",
                    "bestRating": "100",
                    "ratingCount": "20"
                 }
    	    },
    	    "reviewRating": {
    	        "@type": "Rating",
    	        "worstRating": 0,
    	        "bestRating": 5,
    	        "ratingValue": {{SCHEMA - RatingValue}}
    	    }
    	};

    Is there a way to easily populate the AggregateRating fields without having a duplicate JSON-LD ?

    Thanks a lot

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    I don’t really understand this question.

    Thread Starter dezpfab

    (@dezpfab)

    I am gonna try again… I am using Google Tag Manager to create a JSON-LD schema with the following structure :

    	    "@context": "https://schema.org",
    	    "@type": "Review",
    	    "author": {
    	        "@type": "Person",
    	        "name": "{{SCHEMA - Author}}"
    	    },
    	    "url": "{{Page URL}}",
    	    "datePublished": "2014-03-13T20:00",
    	    "publisher": {
    	        "@type": "Organization",
    	        "name": "website",
    	        "sameAs": "https://website.com"
    	    },
    	    "description": "",
    	    "inLanguage": "fr",
    	    "itemReviewed": {
    	        "@type": "Product",
    	        "name": "{{SCHEMA - Product Name}}",
    	        "image": "{{SCHEMA - Logo}}",
                    "aggregateRating": {
                    "@type": "AggregateRating",
                    "ratingValue": "XX",
                    "bestRating": "XX",
                    "ratingCount": "XX"
                 }
    	    },
    	    "reviewRating": {
    	        "@type": "Rating",
    	        "worstRating": 0,
    	        "bestRating": 5,
    	        "ratingValue": {{SCHEMA - RatingValue}}
    	    }
    	};

    I would like to populate the “AggregateRating” fields with Site Reviews data. Is their a way to surface the data on the page so I can create variables with GTM ?

    Thanks

    Plugin Author Gemini Labs

    (@geminilabs)

    bestRating = The highest value allowed in this rating system. If bestRating is omitted, 5 is assumed.

    // Gets the average rating for the assigned post
    $ratingValue = floatval( get_post_meta( get_the_ID(), '_glsr_average', true ));
    
    // Gets the review count for the assigned post
    $counts = array_filter( (array)get_post_meta( get_the_ID(), '_glsr_count', true ));
    $ratingCount = isset( $counts['local'] )
        ? array_sum( $counts['local'] )
        : 0;
    
    Plugin Author Gemini Labs

    (@geminilabs)

    I have not heard back from you in a week so will mark this as resolved.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Schema question’ is closed to new replies.