Structured data not working right with CSS selectors (adding slashes in links and other problems). How do I fix this? - html

I work for a website with 10000+ products and I decided to input the structured data dynamically via CSS selectors in GTM because doing it manually would be too time consuming. It all worked fine, but then I ran into some problems.
Firstly, the structured data added slashes to links that lead to a 404, like so:
"url": "https:\/\/example.com\/shop\/category\/subcategory\/product"
Secondly, the prices in my country are separated with a comma, and not a dot, so the rich results test returns an error. Is there a way to change this?
Full schema here.
<script type="application/ld+json"> {
"#context": "https://www.schema.org",
"#type": "product",
"sku": "{{sku}}",
"image": ["{{carousel-item active}}"],
"name": "{{product-title}}",
"description": "{{product-description}}",
"category": "{{category}}",
"brand": {
"#type": "brand",
"name": "BRAND",
"logo": "https://example.com/images/logo.png"
},
"offers": {
"#type": "Offer",
"itemCondition": "http://schema.org/NewCondition",
"availability": "http://schema.org/InStock",
"price": "{{price}}",
"priceValidUntil": "2021-11-11",
"priceCurrency": "HRK",
"url": "{{Page URL}}",
"shippingDetails": {
"#type": "OfferShippingDetails",
"shippingRate": {
"#type": "MonetaryAmount",
"value": "25",
"currency": "HRK"
},
"shippingDestination": {
"#type": "DefinedRegion",
"addressCountry": "HR"
},
"deliveryTime": {
"#type": "ShippingDeliveryTime",
"transitTime": {
"#type": "QuantitativeValue",
"minValue": "3",
"maxValue": "5"
},
"cutOffTime": "17:00-08:00",
"businessDays": {
"#type": "OpeningHoursSpecification",
"dayOfWeek": [
"https://schema.org/Monday",
"https://schema.org/Tuesday",
"https://schema.org/Wednesday",
"https://schema.org/Thursday",
"https://schema.org/Friday" ]
}
}
}
}
}
}
</script>
I am very new to this, so please be gentle.
P.S. All other parts of schema work fine.

Related

Does Google regard #type": "AggregateOffer" and "#type": "Offer" as duplication?

A site is flagging up (Google Search Console) Unparsable structured data- Duplicate unique property.
It is highlighting #type": "AggregateOffer" but there is only one instance of #type": "AggregateOffer" on any page.
As well as #type": "AggregateOffer" there is "#type": "Offer" on each affected page.
Does Google regard #type": "AggregateOffer" and "#type": "Offer" as duplication?
"offers": {
"#type": "Offer",
"seller": {
"#type": "Organization",
"name": "Not real name"
},
"#type": "AggregateOffer",
"highPrice":714.32,
"lowPrice":449.12,
"priceCurrency": "GBP",
"availability": "https://schema.org/InStock"
I have reworked the above code and my schema now validates:
<script type="application/ld+json">
{
"#context": "https://schema.org",
"#type": "Product",
"productID": "47",
"url": "https://www.webeg.uk/cpscpsprep/acatalog/Engagement-Ring-47.html",
"image": "s-Engagement.jpg",
"description":"A stunning diamond ring for the future bride....",
"itemCondition":"New",
"name": "Engagement Ring",
"offers": {
"#type": "AggregateOffer",
"highPrice":410.00,
"lowPrice":390.00,
"priceCurrency": "GBP",
"availability": "https://schema.org/InStock",
"seller": {
"#type": "Organization",
"name": "Sample Company"
}
}
}
</script>
https://validator.schema.org/#url=https%3A%2F%2Fwww.webeg.uk%2Fcpscpsprep%2Facatalog%2FEngagement-Ring-47.html
So it seems the answer is that Google does not like #type": "AggregateOffer" and "#type": "Offer" in the same schema snippet!
Thank you.

What is wrong with my BlogPosting code? "Missing '}' or object member name."

I've been working on this BlogPosting schema, and I run it through the Google testing tool and I keep seeing an error message at the very end:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "BlogPosting",
"mainentityofpage": "https://www.northcountrylaw.com",
"headline": "14 Ways Json Can Improve Your SEO",
"alternativeHeadline": "and the women who love them",
"image": "http://example.com/image.jpg",
"award": "Best article ever written",
"editor": "John Doe",
"genre": "search engine optimization",
"keywords": "seo sales b2b",
"wordcount": "1120",
"Publisher": {
"#type": "Organization",
"name": "Cat's Meow",
"logo": {
"#type": "ImageObject",
"name": "Cats cats cats",
"width": "1024",
"height": "1024",
"url": "https://www.greatcats.png"
}
},
"url": "http://www.example.com",
"datePublished": "2015-09-20",
"dateCreated": "2015-09-20",
"dateModified": "2015-09-20",
"description": "We love to do stuff to help people and stuff",
"articleBody": "You can paste your entire post in here, and yes it can get really really long.",
"author": {
"#type": "Person",
"name": "kitten boots"
},
</script>
JSON-LD errors
You have four {, but only three }.
You have a , after the last }, but nothing follows.
So, you have to remove the comma and close the author:
"author": {
"#type": "Person",
"name": "kitten boots"
}
}
Schema.org errors
Schema.org terms are case-sensitive. It has to be:
publisher instead of Publisher
mainEntityOfPage instead of mainentityofpage
wordCount instead of wordcount

JSON-LD to normal JSON

I'm trying to insert a JSON-LD file into my CouchDB. The only problem I have is that when I insert my JSON-LD file, the resulting CouchDB is meaningless because the IDs aren't linked together.
An example of what my JSON-LD file looks like:
"contributor": [
{
"#id": "_:N6e57c55b35b74782ada714fdc6d66bf1"
},
{
"#id": "_:N810e115dfb3348579a7b826a7548095b"
}
And another part:
{
"#id": "_:N6e57c55b35b74782ada714fdc6d66bf1",
"#type": "Person",
"label": "Isely, Duane, 1918-"
},
{
"#id": "_:N810e115dfb3348579a7b826a7548095b",
"#type": "Person",
"label": "Cronquist, Arthur"
}
Now the IDs in "contributor" are linking to the two fields of the second part, which is describing person. I would like to know how to link them (the correct way), so I would get something like this:
"contributor": [
{
"#type": "Person",
"label": "Isely, Duane, 1918-"
},
{
"#type": "Person",
"label": "Cronquist, Arthur"
}
You could use a JSON-LD processor to (re)create nicer JSON for your DB. A good possibility to prescribe the structure of JSON-LD documents is to define a frame.
Quote from spec:
JSON-LD Framing allows developers to query by example and force a specific tree layout to a JSON-LD document.
Example:
Assuming your document looks like
{
"#context": {
"contributor": {
"#type": "#id",
"#id": "http://purl.org/dc/terms/contributor",
"#container": "#list"
},
"label": {
"#id": "http://www.w3.org/2004/02/skos/core#prefLabel"
}
},
"#graph": [
{
"#type": "MainResource",
"#id": "_:foo",
"contributor": [
{
"#id": "_:N6e57c55b35b74782ada714fdc6d66bf1"
},
{
"#id": "_:N810e115dfb3348579a7b826a7548095b"
}
]
},
{
"#id": "_:N6e57c55b35b74782ada714fdc6d66bf1",
"#type": "Person",
"label": "Isely, Duane, 1918-"
},
{
"#id": "_:N810e115dfb3348579a7b826a7548095b",
"#type": "Person",
"label": "Cronquist, Arthur"
}
]
}
Add a JSON-LD Frame like
{
"#context": {
"contributor": {
"#type": "#id",
"#id": "http://purl.org/dc/terms/contributor",
"#container": "#list"
},
"label": {
"#id": "http://www.w3.org/2004/02/skos/core#prefLabel"
}
},
"#type": "MainResource",
"#embed": "always"
}
Throw it to a JSON-LD processor of your choice and you will get something like
{
"#context": {
"contributor": {
"#type": "#id",
"#id": "http://purl.org/dc/terms/contributor",
"#container": "#list"
},
"label": {
"#id": "http://www.w3.org/2004/02/skos/core#prefLabel"
}
},
"#graph": [
{
"#id": "_:b0",
"#type": "http://json-ld.org/playground/MainResource",
"contributor": [
{
"#id": "_:b1",
"#type": "http://json-ld.org/playground/Person",
"label": "Isely, Duane, 1918-"
},
{
"#id": "_:b2",
"#type": "http://json-ld.org/playground/Person",
"label": "Cronquist, Arthur"
}
]
}
]
}
Here is the complete example in json-ld.org/playground
Unfortunately framing is not equaly well supported. So the result depends on the JSON-LD processor you're using.
You can elaborate further by removing "#" signs from your data. Simply add the following to your context:
"type" : "#type",
"id" :"#id"
Also, you can add shortenings for types to your context document
"MainResource": "http://json-ld.org/playground/MainResource"
See example in json-ld.org/playground
For full code java example with rdf4j look here: How to convert RDF to pretty nested JSON using java rdf4j .

Multiple JSON-LD tag groups in one page

Can I use multiple JSON-LD groups (using Schema.org) in the same page?
If I can't, how to combine them together? I'm not so familiar with the syntax.
Group 1:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "LocalBusiness",
"address": {
"#type": "PostalAddress",
"streetAddress": "3102 Highway 98",
"addressRegion": "FL",
"addressLocality": "Mexico Beach",
"postalCode": "45252",
"addressCountry": "US",
},
"geo": {
"#type": "GeoCoordinates",
"latitude": "40.75",
"longitude": "73.98"
},
"name": "Beachwalk Beachwear & Giftware",
"telephone": "850-648-4200",
"email": "admin#example.com",
"faxNumber": "860-562-4250",
}
</script>
Group 2:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Organization",
"url": "http://example.com",
"name": "My Domain Title",
"logo": "http://example.com/wp-content/uploads/2015/08/abc.jpg",
"contactPoint": [
{
"#type": "ContactPoint",
"telephone": "0192-39192130",
"contactType": "customer service"
},
{
"#type": "ContactPoint",
"telephone": "0182-239120398",
"contactType": "customer service"
}
],
"sameAs": [
"http://facebook.com/myfbaccount",
"http://twitter.com/mytwitteraccount"
]
}
</script>
You can either have multiple script blocks on your page or combine it in a single block. The easiest way to combine them into a single block is to use the #graph keyword as follows:
<script type="application/ld+json">
{
"#graph": [
{ ... your first JSON-LD block ... },
{ ... your second JSON-LD block ... }
]
}
</script>
According to the spec (https://www.w3.org/TR/json-ld/#h3_advanced-context-usage) the usage of several contexts is possible with a simple list of contexts:
[
{
"#context": "http://example.org/contexts/person.jsonld",
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/",
"depiction": "http://twitter.com/account/profile_image/manusporny"
},
{
"#context": "http://example.org/contexts/place.jsonld",
"name": "The Empire State Building",
"description": "The Empire State Building is a 102-story landmark in New York City.",
"geo": {
"latitude": "40.75",
"longitude": "73.98"
}
}
]

Email Markup Tester

Google's email Markup Tester always fails with the error
"INVALID_OBJECT: orderStatus,http://schema.org/OrderStatusType"
I have tried with all there samples located on this page:
https://developers.google.com/gmail/markup/reference/order
Do we think its just a question of waiting for them to fix it?
example json:
<html>
<body>
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Order",
"merchant": {
"#type": "Organization",
"name": "Amazon.com"
},
"orderNumber": "123-4567890-1234567",
"priceCurrency": "USD",
"price": "29.99",
"acceptedOffer": {
"#type": "Offer",
"itemOffered": {
"#type": "Product",
"name": "Google Chromecast"
},
"price": "29.99",
"priceCurrency": "USD",
"eligibleQuantity": {
"#type": "QuantitativeValue",
"value": "1"
}
},
"url": "https://www.amazon.ca/gp/css/summary/edit.html/orderID=123-4567890-1234567"
}
</script>
</body>
</html>
I had the same issue and fixed validation by adding:
"orderStatus" : "OrderDelivered",
I noticed using the following didn't work (even though it is how the Google Example in the documentation has it ):
"orderStatus": "http://schema.org/OrderStatus/OrderDelivered",
The problem is that Google is insisting that you provide a valid statusOrder key. The the following validates:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Order",
"merchant": {
"#type": "Organization",
"name": "Amazon.com"
},
"orderNumber": "123-4567890-1234567",
"priceCurrency": "USD",
"price": "29.99",
"acceptedOffer": {
"#type": "Offer",
"itemOffered": {
"#type": "Product",
"name": "Google Chromecast"
},
"price": "29.99",
"priceCurrency": "USD",
"eligibleQuantity": {
"#type": "QuantitativeValue",
"value": "1"
}
},
"orderStatus" : "OrderDelivered",
"url": "https://www.amazon.ca/gp/css/summary/edit.html/orderID=123-4567890-1234567"
}
</script>