Display star ratings for Discourse pages in search engine results (SERPs)

AI-generated summary

The discussion explores how to display star ratings in search engine results (SERPs) for Discourse pages using Google Tag Manager (GTM) and JSON-LD structured data. Gulshan_Kumar outlines a step-by-step process involving GTM setup, adding JSON-LD markup, filtering triggers, and publishing the tag. neil clarifies that the GTM script can be added via Discourse settings, though Gulshan_Kumar notes it currently places in the body instead of the head, prompting a fix. neil confirms the update to place the script in the head as per Google’s updated guidelines. angus suggests an alternative using the Topic Ratings plugin, which automatically adds average ratings as structured data. PoojaPatel asks about missing star ratings in SERPs, and Gulshan_Kumar confirms the method works and the absence was intentional.

Displaying star rating with Discourse is easy. I am happy to share, It can be done in simple few steps

Process

  1. Setup Google Tag Manager for your Discourse Application

  2. Add a new HTML Tag containing JSON-LD markup

  3. Filter trigger by page view for particular URL

  4. Publish, wait for 24 hrs to see the result in SERPs.

Thanks

8 likes

Interesting. Where are you getting the rating from, Google?

1 like

Yes, it is Google SERPs. :blush:

Looks interesting and useful for other types of integrations with tag manager. Can you show what to add in head section of Discourse?

Just by editing Theme, I added Tag Manager Script in the </head> section.

Oh but Discourse has a setting to do that for you. Search settings for GTM.

3 likes

Good to know, we can add GTM script via Settings. Thanks for the hint about better way.
Updated, above quick guide.

@neil There is one problem when I add GTM script via Discourse settings, it places inside body.

Expected: It should be in the head.


Previously, it was recommended by Google to place in the body.


But now, they have updated their guidelines: “Paste this code as high in the <head> of the page as possible”.

Can we make this possible?

5 likes

Thanks for pointing that out. Yes we should change it to be in the head. Added to my list.

5 likes

“As high in the <head> as possible”

… :roll_eyes: I think they’re just being greedy there. A normal position in the head should be fine.

3 likes

Depending on the kind of rating you’re after you can also use the ratings plugin, which automatically adds the average rating for a topic as structured data to the topic page html.

Example from a user here: Topic Ratings Plugin - #159 by frold

6 likes

@Gulshan_Kumar I updated our GTM support today so it adds the code to the head and the body according to the new instructions.

7 likes

Currently I could not see star rating showing in SERP for above two post.

  1. Bunny CDN Review.
  2. Obstetrics and Cynecology at studmed.dk

@Gulshan_Kumar - are you removing star rating in gtm or use any method?

The method which I suggested (using GTM+JSON-LD for star rating) works completely fine. You can continue to use it.

In my case, I intentionally removed from that post due to some personal reason. Nothing else.

1 like