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 forhttp://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>
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](https://i.stack.imgur.com/VzRis.png)
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.
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.
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.
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.
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.
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,
Now you will not see the error again.