JSON-LD
JSON-LD is a markup method that renders data using the Linked Data (LD) objects.
Alert
If you embed micro markup using a plugin, you’ll probably need to modify it. To do this, contact the plugin developer or another professional with development skills.
Markup principles
Data in JSON-LD format is described by a set of comma-separated key-value pairs. The format provides reserved keys to define the description context or link the objects in different ways. For example, @context
defines the object vocabulary (in this case — Schema.org), while @type
defines the type of the entity described. For the full list of reserved keys, see JSON-LD documentation.
The entity is described in curly brackets { } within the <script>
tag with the attribute type="application/ld+json"
or type="ld+json"
. Indicate that the Schema.org vocabulary is used for markup — "@context":"http://schema.org"
. Use the @type
key to specify the Schema.org class defining the entity described. Mark up the properties of the entity: use the properties of the specified Schema.org class as keys.
To mark up multiple entities on a page, you can use:
For each node of the graph, specify @id
— a link to the page section containing the described entity.
The example below describes two news articles "@type":"NewsArticle"
. The article identifier ( @id
key), publication date (datePublished
key), and the article authors (author
key) are specified as an array of two elements. To describe authors, we use nested entities of the Person
class.
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@graph" : [
{
"@type": "NewsArticle",
"@id": "https://www.example-news.com/life/weather/moscow#cao",
"datePublished": "2018-12-11T08:56:49Z",
"author": [{"@type": "Person", "name": "John Smith"},
{"@type": "Person", "name": "Dylan Brown"}]
},
{
"@type": "NewsArticle",
"@id": "https://www.example-news.com/life/weather/moscow#zao",
"datePublished": "2018-12-11T09:56:49Z",
"author": [{"@type": "Person", "name": "John Smith"},
{"@type": "Person", "name": "Jack Jackson"}]
}
]
}
</script>
For each entity, specify @id
— a link to the section of the page containing the described entity.
The example below describes two news articles "@type":"NewsArticle"
. The article identifier ( @id
key), publication date (datePublished
key), and the article authors (author
key) are specified as an array of two elements. To describe authors, we use nested entities of the Person
class.
<script type="application/ld+json">
[{
"@context": "http://schema.org",
"@type": "NewsArticle",
"@id": "https://www.example-news.com/life/weather/moscow#cao",
"datePublished": "2018-12-11T08:56:49Z",
"author": [{"@type": "Person", "name": "John Smith"},
{"@type": "Person", "name": "Dylan Brown"}]
},
{
"@context": "http://schema.org",
"@type": "NewsArticle",
"@id": "https://www.example-news.com/life/weather/moscow#zao",
"datePublished": "2018-12-11T09:56:49Z",
"author": [{"@type": "Person", "name": "John Smith"},
{"@type": "Person", "name": "Jack Jackson"}]
}
]
</script>
Read more about JSON-LD.
What content can I mark up
Yandex Metrica supports markup for the following content:
- Article, news article, or blog post (
Article
,NewsArticle
orBlogPosting
) - Movie description (
Movie
) - Review or feedback (
Review
) Recipe
- Questions and answers (
Question
orQAPage
)
Other types of content will not be included in Yandex Metrica reports even with the correct markup.
How to mark up materials
Add markup to your content following the rules below to make sure that it’s processed correctly by Yandex Metrica. To get more complete statistics, we recommend that you mark up all the content elements, but only three are required: identifier, headline, and text.
If you already use JSON-LD, see if the markup on your website meets these requirements. The code examples in the terms aren’t the only correct markup option.
Markup can be added to the site automatically — for example, using WordPress plugins. Before use, make sure that the selected plugin allows you to pass all the necessary markup elements to the page code.
Alert
If there are several content units on a single page, mark each of them separately so that statistics are collected correctly.
Specify the following content elements (mandatory elements are marked with an asterisk):
ID*
-
The identifier is specified using the reserved
@id
key. It lets Yandex Metrica distinguish between different content. The ID isn’t shown in reports. Examples of identifiers are a content link or an arbitrary unique value."@id": "https://www.example-news.com/life/weather/moscow#cao"
If the
@id
key is not found, the system tries to find it in the nested entities within themainEntity
ormainEntityOfPage
keys.<script type="application/ld+json"> { "@context": "http://schema.org", "@type": "NewsArticle", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://www.example-news.com/life/weather/moscow#cao" } } </script>
@id
can be used to calculate full scrolls and full reads. If used as an ID:- The article URL is specified, Yandex.Metrica detects the fragment after the # (
#fragment
). Then Yandex.Metrica searches for the HTML element in the article containing this fragment (id="fragment"
attribute). If the fragment is found, indicators are calculated. The Article URL is also processed. - If a random value is picked and
head
contains a JSON-LD code, then the indicators are calculated according to the contents of thebody
. If thebody
code is located inside another HTML element, then the parent element for the markup is used for calculations. This is why data in the report may not be entirely accurate. Calculations are also performed this way if the Article URL ends with a # and no fragments follow it.
- The article URL is specified, Yandex.Metrica detects the fragment after the # (
Title*
-
The headline is shown in Yandex Metrica reports. It can be specified in the
headline
oralternativeHeadline
keys. If both keys are found, their values are separated by a space. For example, if the headlines are marked up like this:"headline": "Moscow breaks the 1922 temperature record", "alternativeHeadline": "Temperature in November exceeds 12 °C"
In the report, the article is called “Moscow breaks the 1922 temperature record Temperature in November exceeds 12 °C”.
If none of the above keys are found, the value of the
name
oritemReviewed
key is used as the headline (for theReview
class).
Text*
-
The text must be contained in the
text
key. The text defines the number of characters. This is necessary to determine the volume of materials and calculate the metrics of scroll depth and read depth."text": "On Wednesday, November 6, Moscow broke the temperature record registered in 1922. The air temperature was plus 12.1 degrees Celsius, according to the Fobos center."
If the
text
key is not found, the following content is taken as text:-
Contents of the anchored element from the
url
or@id
key value."@context": "https://schema.org", "@type": "Article", "url": "https://www.example-news.com/life/weather/moscow#cao"
-
Content of the node embedding the entity described (if it is something other than
<head>
). -
Content of the
<body>
page in all other cases.
When calculating the text size, the tag characters are ignored.
Note
You can get complete statistics for the content with text longer than 500 characters.
-
-
The author is specified using the
author
key. If there are several authors, list them in the array."author": [ {"@type": "Person", "name": "John Smith"}, {"@type": "Person", "name": "Dylan Brown"} ]
If the key was not found, the system will try to find it in the nested entities in the
mainEntity
ormainEntityOfPage
keys.<script type="application/ld+json"> { "@context": "http://schema.org", "@type": "NewsArticle", "@id": "12345", "mainEntityOfPage": { "@type": "WebPage", "author": {"@type": "Person", "name": "John Smith"} } } </script>
With this data, you can view statistics for individual authors.
Subject
-
You can mark up keywords or hashtags as topics. Specify topics in the
about
key:"about": [ {"@type": "Event", "name": "Heat"}, {"@type": "Event", "name": "Moscow"} ]
Type (
@type
) is optional or specify any type that is supported by the standard.If the
name
key isn't found, the system will try to find the values in thealternateName
key.
Dates of publication and revision
-
The publication and modification dates are indicated in the
datePublished
anddateModified
keys. Dates are written in ISO 8601 format."datePublished": "2018-12-11T08:56:49Z", "dateModified": "2018-11-06T09:26:10+04:00"
Category
-
A heading is a section of a website dedicated to a specific topic. To mark up a category, use the
BreadcrumbList
key. It describes a chain of linked web pages (“breadcrumbs”), which usually ends with the current content. WithinBreadcrumbList
, in theitemListElement
key, several entities ofListItem
type should be defined which describe the current category and broader ones.Category nesting can be defined by the
position
key. For example, the “Life” category may contain nested categories like “Weather” and “Incidents”. If"position":"1"
, content is at the upper level (“Life”), if"position":"2"
, it's at the second level (“Weather”).The content category is the value of the
name
key with the highestposition
value.Note
At the moment, the statistics shows two levels of category nesting.
{ "@context": "http://schema.org", "@type": "BreadcrumbList", "itemListElement": [ { "@type": "ListItem", "position": 1, "item":{ "@id": "//example-news.ru/life", "name": "Life"} }, { "@type": "ListItem", "position": 2, "item":{ "@id": "//example-news.ru/life/weather", "name": "Weather"} }] }
content URL
-
The content URL must be included into the
url
key. We recommend inserting a URL fragment after a #. The indicators will be calculated based on the content the URL fragment points to. Learn more"url": "https://www.example-news.com/life/weather/moscow#сao"
If the markup is correct and the tag is properly enabled, statistics on the content will soon start to be collected in Yandex Metrica.
Markup example
Below you can see an example of news markup.
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@graph": [
{
"@type":"BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"item": {
"@id": "//example-news.ru/life",
"name": "Life"
}
},
{
"@type": "ListItem",
"position": 2,
"item": {
"@id": "//example-news.ru/life/weather",
"name": "Weather"
}
}
]
},
{
"@type": "NewsArticle",
"@id": "https://www.example-news.com/life/weather/moscow#cao",
"headline": "Moscow breaks the 1922 temperature record",
"alternativeHeadline": "Temperature in November exceeds 12 °C",
"datePublished": "2018-12-11T08:56:49Z",
"dateModified": "2018-11-06T09:26:10+04:00",
"text": "On Wednesday, November 6, Moscow broke the temperature record registered
in 1922. The air temperature was plus 12.1 degrees Celsius,
according to the Fobos center.",
"author": [
{"@type": "Person", "name": "John Smith"},
{"@type": "Person", "name": "Dylan Brown"}
],
"about": {
"@type": "Event",
"name": "Moscow"
},
"url": "https://www.example-news.com/life/weather/moscow#cao"
}
]
}
</script>
Learn more
Useful links |
Online training |
itemprop |
Property description |
The |
|
|
ID The ID lets Yandex Metrica distinguish between different content. The ID isn’t shown in reports.
|
|
ID This property is used if the
|
type: |
Title You can specify the headline using the
In the report, the article is called “Moscow breaks the 1922 temperature record Temperature in November exceeds 12 °C”. If none of the above properties is found, the value of the |
type: |
Title You can specify the headline using the
In the report, the article is called “Moscow breaks the 1922 temperature record Temperature in November exceeds 12 °C”. If none of the above properties is found, the value of the |
type: |
Article text The number of characters in the text is determined. This is necessary to determine the volume of material. Only the contents of nested tags is considered text. The characters in the actual tags aren’t taken into account. We recommend that you mark up the text of materials so that it doesn’t include what is unnecessary: ad banners, comment blocks, etc., otherwise the volume of materials and statistics indicators may be calculated incorrectly.
If the If none of the properties are found, the contents of the tag marked Note You can get complete statistics for the content with text longer than 500 characters. |
type: or or |
Author To specify the author, we use the
The value can also be taken from:
With this data, you can view statistics for individual authors in Yandex Metrica. |
type: |
Subject You can mark up keywords or hashtags as topics. To do this, define the
|
type: |
Date of publication The dates of publication
or in the
|
|
Change date The dates of publication
or in the
|
|
|
type: or or |
Category A heading is a section of a website dedicated to a specific topic. To mark up a category, use the The nesting of categories is set using the The heading of materials will be the value of the Note At the moment, the statistics shows two levels of category nesting.
|
Other |
|
Canonical reference The content URL is specified using the
If the The found value can be used when generating the content ID. |
Property description
ID
The ID lets Yandex Metrica distinguish between different content. The ID isn’t shown in reports.
<meta itemprop="identifier" content="12345">
Property description
Title
You can specify the headline using the headline
or alternativeHeadline
property. The headline will appear in Yandex Metrica reports. If both properties are set, their values are written with a space. For example, if the headlines are marked up like this:
<h1 itemprop="headline">Moscow breaks the 1922 temperature record</h1>
<h2 itemprop="alternativeHeadline">Temperature in November exceeds 12 °C</h2>
In the report, the article is called “Moscow breaks the 1922 temperature record Temperature in November exceeds 12 °C”.
If none of the above properties is found, the value of the name
property is used as the headline.
Property description
Title
You can specify the headline using the headline
or alternativeHeadline
property. The headline will appear in Yandex Metrica reports. If both properties are set, their values are written with a space. For example, if the headlines are marked up like this:
<h1 itemprop="headline">Moscow breaks the 1922 temperature record</h1>
<h2 itemprop="alternativeHeadline">Temperature in November exceeds 12 °C</h2>
In the report, the article is called “Moscow breaks the 1922 temperature record Temperature in November exceeds 12 °C”.
If none of the above properties is found, the value of the name
property is used as the headline.
Property description
Date of publication
The dates of publication datePublished
and revision dateModified
are written in ISO 8601 format.
html <meta itemprop="datePublished" content="2018-12-11T08:56:49Z" />
or in the datetime
attribute of the time
tag
<time itemprop="dateModified" datetime="2018-12-11T07:30:00Z">07:30, December 11, 2018 </time>
Property description
Change date
The dates of publication datePublished
and revision dateModified
are written in ISO 8601 format.
html <meta itemprop="datePublished" content="2018-12-11T08:56:49Z" />
or in the datetime
attribute of the time
tag
<time itemprop="dateModified" datetime="2018-12-11T07:30:00Z">07:30, December 11, 2018 </time>
Property description
Category
A heading is a section of a website dedicated to a specific topic. To mark up a category, use the BreadcrumbList
class. It describes a chain of linked web pages (“breadcrumbs”), which usually ends with the current content. Within the BreadcrumbList
, define multiple items of the ListItem
type, which are marked up by the itemListElement
property and describe the current and broader headings.
The nesting of categories is set using the position
property of the ListItem
class. For example, the “Life” category may contain nested categories like “Weather” and “Incidents”. If position = '1'
, materials are at the upper level (“Life”), if position = '2'
— they are at the second level (“Weather”).
The heading of materials will be the value of the name
property of the ListItem
entity with the largest position
value.
Note
At the moment, the statistics shows two levels of category nesting.
<ol itemscope itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="//example-news.ru/life">
<span itemprop="name">Life</span></a>
<meta itemprop="position" content="1" />
</li>
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="//example-news.ru/life/weather">
<span itemprop="name">Weather</span></a>
<meta itemprop="position" content="2" />
</li>
</ol>
Property description
Author
To specify the author, we use the author
property. If there are multiple authors, specify them in different tags.
html <div itemprop="author">John Smith</div>
The value can also be taken from:
-
The
name
property of thePerson
class.<div itemprop="author" itemscope itemtype="http://schema.org/Person"> <span itemprop="name">John Smith</span> </div>
-
The attribute of the
href
link.<link itemprop='author' href="/example/authors/ivan_ivanov.html"/>
With this data, you can view statistics for individual authors in Yandex Metrica.
Property description
Subject
You can mark up keywords or hashtags as topics. To do this, define the about
property for each topic. You can use the value from the name
property of any class:
<div itemprop="about">Heat</div>
<div itemprop="about" itemscope itemtype="https://schema.org/Thing">
<span itemprop="name">Moscow</span>
</div>
Property description
Canonical reference
The content URL is specified using the url
property.
<a itemprop="url" href="https://www.example-news.com/life/weather/moscow">example-news.com</a>
If the url
property is not found, the system searches for a canonical link. This link is used to indicate the main content, if the current page duplicates a site page. Canonical links are marked with a special rel="canonical"
attribute. For example, if the content is a duplicate of the page http://www.example-news.com/page
, it contains <link rel="canonical" href="http://www.example-news.com/page"/>
. The value of the href
attribute of the canonical link is used as the material's URL.
The found value can be used when generating the content ID.