I have a question about referencing a JSON-LD schema.org markup in another JSON-LD schema.org markup. I have a page with a main event which is located at http://event.com/ and here's the JSON-LD markup for it.
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Event",
"name": "MainEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
}
</script>
Main event has multiple sub events located at for example http://event.com/sub-event-1/ and here's the JSON-LD markup for that:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Event",
"name": "SubEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
}
</script>
What I'm trying to do is mark up the subevent as part of the main event. Is it possible to create a reference from the main event to sub event? Something like this:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Event",
"name": "SubEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
superEvent {
"url": "http://event.com/"
}
}
</script>
If it's possible, what's the correct markup for reference. I can't find any information about it.
Or is it required to embed the MainEvent in every single SubEvent like this:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Event",
"name": "SubEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
},
"superEvent": {
"#type": "Event",
"name": "MainEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
}
}
</script>
You can identify a node by giving it a URI, specified in the #id keyword. This URI can be used to reference that node.
See the section "Node Identifiers" in the JSON-LD spec.
So your main event could get the URI http://example.com/2016-04-21#main-event:
<script type="application/ld+json">
{
"#id": "http://example.com/2016-04-21#main-event",
"#context": "http://schema.org",
"#type": "Event",
"name": "MainEvent",
"startDate": "2016-04-21T12:00"
}
</script>
and you could give this URI as the value for the sub event’s superEvent property:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Event",
"name": "SubEvent",
"startDate": "2016-04-21T12:00",
"superEvent": { "#id": "http://example.com/2016-04-21#main-event" }
}
</script>
(You could of course give your sub event an #id, too. This would allow you and others to identify/reference this sub event.)
What you are looking for a node identifiers (see http://www.w3.org/TR/json-ld/#node-identifiers). You assign each entity a unique identifier in the form of a URL and use it in references:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#id": "http://event.com/#mainEvent",
"#type": "Event",
"name": "MainEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
}
</script>
Above you see I gave the event an #id. I appended a fragment (#mainEvent) because http://event.com/ would typically identify the page itself. You can then reference the event as follows:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Event",
"name": "SubEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
superEvent {
"#id": "http://event.com/#mainEvent"
}
}
</script>
Embedding as shown in your example works as well. In that case, you won't need the identifiers as it is clear what references what.
Related
I've been trying to figure out a way to add how many likes were received to a product using structured data. Is what I have below correct? Or would the second example be more correct?
Is my usage of ["Product","InteractionCounter"] for the type correct in the first example?
I'm trying to have the google show a likes counter much like the aggregateRating property of Product.
I'm also not sure what the url in offers is supposed to point to or if it's necessary. Any ideas?
<script type="application/ld+json">
{
"#context": "https://schema.org",
"#type": ["Product","InteractionCounter"],
"name": "CC-1",
"description": "Wedding Cake",
"interactionType":{
"#type":"LikeAction",
"name": "Likes",
"description": "Likes Received"
},
"interactionService": {
"#type":"WebSite",
"url": "https://example.com/index.php?page=gallery"
},
"userInteractionCount": 55
}
</script>
OR
<script type="application/ld+json">
{
"#context": "https://schema.org",
"#type": "Product",
"name": "CC-1",
"description": "Wedding Cake",
"additionalProperty": {
"#type": "PropertyValue",
"name": "Likes",
"description": "Likes Received",
"value": 55
}
}
</script>
This is what I have right now:
<script type="application/ld+json">
{
"#context": "https://schema.org",
"#type": ["Product","InteractionCounter"],
"name": "CC-1",
"description": "Wedding Cake with bla bla bla",
"category": "Wedding Cakes",
"brand": {
"#type": "Brand",
"logo": "https://example.com/images/logo.png",
"slogan": "Cakes Are Nice"
},
"offers": {
"#type": "Offer",
"url": "https://example.com/anvil",
"priceCurrency": "CAD",
"price": "119.99"
},
"image": "https://example.com/collection/wedding_cakes/mid_def/CC-1",
"interactionType":{
"#type":"LikeAction",
"name": "Likes",
"description": "Likes Received"
},
"interactionService": {
"#type":"WebSite",
"url": "https://mimozas.com/index.php?page=gallery"
},
"userInteractionCount": "55 PLACEHOLDER"
}
If the product is the subject of content, then it makes sense to indicate likes as part of the type Product. My suggestion for you:
{"#context":"https://schema.org",
"#type":"Product",
"name":"CC-1",
"description":"Wedding Cake",
"subjectOf":{
"#type": "InteractionCounter",
"interactionType":{
"#type":"LikeAction",
"name":"Likes",
"description":"Likes Received"
},
"interactionService":{
"#type":"WebSite",
"url":"https://example.com/index.php?page=gallery"
},
"userInteractionCount":"55"
}
}
And be careful about inverted commas.
My addition after expanding the question.
I'm trying to have the google show a likes counter much like the
aggregateRating property of Product.
Google has no direct support for the type InteractionCounter - read more Explore the search gallery. However, in the rich test results of my suggestion, there are no errors or warning messages from Google:
Probably needs experimentation.
I am trying to add a custom label 0 shopping attribute to my Json schema but I don't get the this new attribute on my products.
I tried:
<script type="application/ld+json">
{
"#context": "https://schema.org/",
"#type": "Product",
"name": "Auvers - Van Gogh",
"sku":"artworkid[2316]-product[canvas]",
"mpn":"artworkid[2316]-product[canvas]",
"tags": [{
"custom_label_0": "Fine Art"
}
],
And also:
<script type="application/ld+json">
{
"#context": "https://schema.org/",
"#type": "Product",
"name": "Auvers - Van Gogh",
"sku":"artworkid[2316]-product[canvas]",
"mpn":"artworkid[2316]-product[canvas]",
"customLabel0": "Fine Art",
How to set this attribute with the structured data?
I didn't find any infos from the custom label support from Google:
https://support.google.com/merchants/answer/6324473?hl=en#zippy=%2Cexample-values
Is this valid? I need an opportunity to join diffrent script blocks on one page to a valid object.
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Product",
"#id": "#111",
"description": "Test description",
"name": "My Product"
}
</script>
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Product",
"#id": "#111",
"aggregateRating": {
"#type": "AggregateRating",
"ratingValue": "3.5",
"reviewCount": "11"
}
}
</script>
why should these scripts be joined? They describe the same product and are partly redundant.
But if you are looking for possibility to join scripts by id - yes, it exists. I.e. you have two scripts: first - product and its rating, second - organization offering this product. In this case the joining would look like:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Organization",
"makesOffer": {
"#type": "Offer",
"itemOffered": {
"#type": "Product",
"#id": "https://www.example.com#111"
}
}
}
</script>
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Product",
"id": "https://www.example.com#111",
"aggregateRating": {
"#type": "AggregateRating",
"ratingValue": "3.5",
"reviewCount": "11"
}
}
</script>
I often do that when the review system adds its own markup separately to the product markup. It works fine.
You can test it in the Structured Data Testing Tool. It should merge the two into one.
I'm trying to wrap my head around this and I've read through several tutorials including schema.org documentation and Googles structured data guides and I can't find a clear answer on this. It's intuitive how to do this with microdata but not so much using JSON-LD. Let's say I have a website that is a local business and I offer products for sale. How would I combine both the LocalBusiness and Products into the same JSON-LD block of code? They are separate objects as far as my understanding.
Would the code look more like this...
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "LocalBusiness",
"name": "My Business"
}
{
"#context": "http://schema.org",
"#type": "Product",
"name": "My Proudct"
}
</script>
or in separate script tags like this...
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "LocalBusiness",
"name": "My Business"
}
</script>
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Product",
"name": "My Proudct"
}
</script>
or something else altogether?
I have a question about referencing a JSON-LD schema.org markup in another JSON-LD schema.org markup. I have a page with a main event which is located at http://event.com/ and here's the JSON-LD markup for it.
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Event",
"name": "MainEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
}
</script>
Main event has multiple sub events located at for example http://event.com/sub-event-1/ and here's the JSON-LD markup for that:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Event",
"name": "SubEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
}
</script>
What I'm trying to do is mark up the subevent as part of the main event. Is it possible to create a reference from the main event to sub event? Something like this:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Event",
"name": "SubEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
superEvent {
"url": "http://event.com/"
}
}
</script>
If it's possible, what's the correct markup for reference. I can't find any information about it.
Or is it required to embed the MainEvent in every single SubEvent like this:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Event",
"name": "SubEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
},
"superEvent": {
"#type": "Event",
"name": "MainEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
}
}
</script>
You can identify a node by giving it a URI, specified in the #id keyword. This URI can be used to reference that node.
See the section "Node Identifiers" in the JSON-LD spec.
So your main event could get the URI http://example.com/2016-04-21#main-event:
<script type="application/ld+json">
{
"#id": "http://example.com/2016-04-21#main-event",
"#context": "http://schema.org",
"#type": "Event",
"name": "MainEvent",
"startDate": "2016-04-21T12:00"
}
</script>
and you could give this URI as the value for the sub event’s superEvent property:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Event",
"name": "SubEvent",
"startDate": "2016-04-21T12:00",
"superEvent": { "#id": "http://example.com/2016-04-21#main-event" }
}
</script>
(You could of course give your sub event an #id, too. This would allow you and others to identify/reference this sub event.)
What you are looking for a node identifiers (see http://www.w3.org/TR/json-ld/#node-identifiers). You assign each entity a unique identifier in the form of a URL and use it in references:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#id": "http://event.com/#mainEvent",
"#type": "Event",
"name": "MainEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
}
</script>
Above you see I gave the event an #id. I appended a fragment (#mainEvent) because http://event.com/ would typically identify the page itself. You can then reference the event as follows:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Event",
"name": "SubEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
superEvent {
"#id": "http://event.com/#mainEvent"
}
}
</script>
Embedding as shown in your example works as well. In that case, you won't need the identifiers as it is clear what references what.