3

Is it possible to create a page with different structured data depending on the URL parameters?

According to Google:

Also, Google can read JSON-LD data when it is dynamically injected into the page's contents, such as by JavaScript code or embedded widgets in your content management system.

Example

  • There is a page with the address https://example.com/some/page/url.html?attribute3=5.
  • There are structured data on this page.
  • This page has a dropdown.
  • The URL parameters specify what dropdown value to select.
  • When the page is loaded, the value specified in the URL parameter is selected.
  • The value of dropdown is changed using JavaScript.
  • When you change the value of dropdown, the structured data changes.
  • In the Structured Data Testing Tool, structured data remains unchanged regardless of the URL parameters.

A simple example page and result in Structured Data Testing Tool. In the example, only the price is passed and changed in the URL parameter (https://testforstackoverflow.github.io/jsonld.html?p=2).

Probably Google ignores the URL parameters when reading structured data or reads structured data before JavaScript is used.

1 Answer 1

1

The URL design isn’t relevant to this issue. If you would change a path segment instead of a parameter value in the query, you would likely see the same result.

The reason for the issue is using JavaScript to change the structured data.

Some consumers support it, others don’t. Google, for example, seems to support it for JSON-LD, but not for Microdata and RDFa.

The best solution is not to rely on JavaScript for providing your content/data. Not all users/bots/services will run your JavaScript.

3
  • i added an example to the question. Because what you describe in my case does not work.
    – Victor S.
    Commented May 30, 2018 at 10:09
  • @VictorS.: With "does not work", do you mean that Google’s SDTT doesn’t see the data after JS got executed? If yes: Google claiming to support JS for JSON-LD doesn’t necessarily mean that their SDTT supports it, too, I guess. They could support it for the rich snippets, but not for the testing tool. But I don’t know to which extent this is the case -- like I recommend in my last paragraph, I don’t use JS for such a purpose, so I have no experience with it.
    – unor
    Commented May 30, 2018 at 12:28
  • everything was verified also by the real site, not only in the Structured Data Testing Tool. The behavior on the real site is the same as in the Structured Data Testing Tool. Unfortunately in my case, I have to implement this as described in the example using JavaScript. Thanks for the help. I'll look further for information on what Google means under similar support for the JSON-LD format.
    – Victor S.
    Commented May 30, 2018 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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