Google SDTT error: "All values provided for http://www.example.com/ must have the same domain."
Asked Answered
U

7

14

When I copy/paste JSON-LD example from Google Documentation (code-snippet below) I get an error in the Structured Data Testing Tool:

http://www.your-company-site.com (All values provided for http://www.example.com/ must have the same domain.)

Why is Google's own documentation example giving an error?

Code snippet from Google’s documentation:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Organization",
  "url": "http://www.your-company-site.com",
  "contactPoint": [{
    "@type": "ContactPoint",
    "telephone": "+1-401-555-1212",
    "contactType": "customer service"
  }]
}
</script>
Unheard answered 27/10, 2016 at 7:56 Comment(4)
It's weird, the code didn't throw error message one month ago.Bomarc
A single line of documentation would make the tester way more usable!Neel
The answers and comments below seem to hold the correct info. Let's add an accepted answer and link all the other questions on this topic.Neel
Another FYI: apparently this "error" only pops up for Organization types; I don't get this error for a Website entityNeel
P
10

It appears the testing tool assumes example.com as its domain.

When testing if you can update your url to "www.example.com" it will validate successfully.

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Organization",
  "url": "http://www.example.com/",
  "contactPoint": [{
    "@type": "ContactPoint",
    "telephone": "+1-401-555-1212",
    "contactType": "customer service"
  }]
}
</script>
Perrone answered 3/1, 2017 at 14:40 Comment(4)
I confirmed this.Reality
Confirmed. Apparently just the main URL will do, which is double weird.Neel
as in @Bryan Heckler answer it should be the domain of the page that the snippet is embedded in: "url": "search.google.com"Defazio
It appears this is no longer trueFrailty
M
5

This error started appearing somewhere in the month before your post. Since the error disappears when the "contactPoint" is left out, even though it doesn't contain an URL, this is most likely a bug in the validation tool.

I came across the same problem and asked about it on the support forum.

Magnate answered 2/11, 2016 at 13:49 Comment(4)
It appears that if you update the @context from http://schema.org to the same URL as your site, the 'all values provided' error goes away but causes a new "invalid type" errorCooksey
@BenParizek: You shouldn’t do that, as you would no longer use the Schema.org vocabulary, but your own vocabulary instead.Tadzhik
Changing @context to something else changes the meaning of the data. If you want to work with schema.org, you need to have that context (or fabricate one with the same definitions). Look up the JSON-LD spec if you want more details.Magnate
Understood. I wasn't proposing to do it as much as sharing a detail that seems to reveal which URL the error is trying to match when it fails validation in the testing tool right now. Worthwhile points to call out, however.Cooksey
A
5

If you change your URL to "https://search.google.com/structured-data/testing-tool/", the tool will drop the error, just make sure before you put the code on your website that you update it.

Also, checking Search Console is likely a more reliable way (currently) to see if your markup has an error.

Aroid answered 29/3, 2017 at 18:1 Comment(0)
C
0

They can't prepopulate the examples in their documentation with the URL of the site you are going to write code for. They don't know what site you are writing code for.

Condensate answered 27/10, 2016 at 9:2 Comment(7)
Ok. But if I replace the snippet with my own data or other examples Implementing JSON-LD I still get the same URL-error.Unheard
Or does this only work on a live website? And how do I check that JSON-LD snippet?Unheard
@PieceofCode — That testing tool, when you feed it copy/paste of the data instead of a URL, assumes the data is for example.com. You can either ignore errors about having the wrong hostname, change the data for the purposes of testing, or test in your live environment.Condensate
Ok. Thanks for clearing that up. I was set on the wrong foot by validated screenshots in some blogposts but I assume those are from live/search console, not the testing-tool I referred to right?Unheard
I voted your anwer up but because i'm new the vote is recorded and not displayed.Unheard
@pieceofcode new users are restricted in voting answers up, it should show when your reputation is higher. Check SO's help section for more info.Stevana
That's true but a) this is undocumented and b) only seems to be an issue for Organization entities; try it for a WebsiteNeel
T
0

If you are pasting some code on the page and running it, Google assumes that it should be an example page. Instead do like this,

  1. Test all other except "url"
  2. Update the index.html on your server
  3. Finally run test with your url (Choose New Test > Fetch URL)

Now you will not see the error again.

Thomasinethomason answered 2/3, 2017 at 21:26 Comment(0)
R
0

I found that by implementing the JSON-LD snippet (with your correct details) in your website and clicking on 'New Test' at the top right of the Structured Data Test Page and using your correct URL it will not throw the error.

Rapport answered 18/3, 2017 at 3:23 Comment(1)
@Nathan I debated with myself whether to use the line you removed.. lolRapport
L
0

One reason this happens is because of the testing tool's UX. It seems kinda buggy to me.

First run a fresh test on a domain. You will see the Organization url is correct and there are no warnings since all matches.

Now, click in the source code (left pane) and add a single space somewhere harmless. You will see the domain disappears in the top bar: enter image description here

You will also see the warning appear. Hitting "refresh" or starting a fresh test will correct the error again. I'm guessing the reason they do this is because when manually editing schema you are no longer, technically, reflecting the source from a domain.

Lithomarge answered 3/5, 2017 at 18:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.