4

Google show stars in Google search with JavaScript dynamically generated rich snippets?

I'm thinking about starting a widget that my users will put in their website. My widget will generate rich snippets in order to allow Google show stars on Google search.

I know that rich snippets work when they are put in static HTML. Can they be dynamically generated via JavaScript as well?

  • Sure. Why not? As long as the code created by the widget is correct, it will work just fine. – closetnoc Oct 17 '14 at 18:00
  • Yes, but depends on the service or product your website uses... using the marking doesn't necessary mean you will receive stars. – Simon Hayter Oct 18 '14 at 0:43
  • @closetnoc I think it my not work because google cannot crawl 100% dynamically generated widgets – Cleyton Oct 20 '14 at 11:29
  • Are you saying that the microdata is placed into the page dynamically by JavaScript? I don't think that Googlebot is going to be able to see that. Please explain more about exactly how this works. – Stephen Ostermiller Nov 7 '14 at 11:26
  • Yes @StephenOstermiller . I've added more details for my question – Cleyton Nov 7 '14 at 11:49
2

Google says that they can read dynamically added structured data if the JSON-LD syntax is used:

Also, Google can read JSON-LD data even when it is dynamically injected into the page's contents, such as by Javascript code or embedded "widgets".

They don’t document this for the other syntaxes they support (Microdata, RDFa), but this doesn’t necessarily mean that they can’t/won’t read it.

  • searchengineland.com/… Also seems to confirm various DOM mitigations are good to go. Doesn't test JSON-LD but we can infer, especially if based on the quote you provided. – dhaupin May 15 '15 at 1:35
0

I tested now and it didn't work.

In general Google can process JavaScript just fine, but considering these should be static tags it probably considers it doesn't comply with standards and ignores them (if printed with JavaScript).

  • How long did you wait to see live results? Not sure if their testing tool runs scripts...could take months for live validate and GWT to report it. – dhaupin May 15 '15 at 1:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.