JSON-LD
JSON-LD 是一种使用 Linked Data (LD) 对象呈现数据的标记方法。
注意
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.
标记原则
JSON-LD 格式的数据由一组用逗号分隔的键值对描述。 该格式提供保留键,用于定义描述上下文或以不同方式链接对象。 例如,@context 定义对象词汇表(本例中为 Schema.org),而 @type 定义所描述实体的类型。 有关保留键的完整列表,请参阅 JSON-LD 文档。
实体在指定了 type="application/ld+json" 或 type="ld+json" 属性的 <script> 计数器内的花括号 { } 中予以描述。 指明将 Schema.org 词汇表用于标记 — "@context":"http://schema.org"。 使用 @type 键指定定义所描述实体的 Schema.org 类。 标记实体的属性:使用指定 Schema.org 类的属性作为键。
要标记页面上的多个实体,您可以使用:
对于图形的每个节点,指定 @id — 指向包含所描述实体的页面部分的链接。
下方示例描述了两篇新闻文章 "@type":"NewsArticle"。 文章标识符(@id 键)、发布日期(datePublished 键)和文章作者(author 键)被指定为两个元素的数组。 为了描述作者,我们使用 Person 类的嵌套实体。
<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>
对于每个实体,指定 @id — 指向包含所描述实体的页面部分的链接。
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>
我可以标记什么内容
Yandex Metrica 支持以下内容的标记:
- 文章、新闻文章或博客帖子(
Article、NewsArticle或BlogPosting) - 电影描述 (
Movie) - 审核或反馈 (
Review) Recipe- 问答(
Question或QAPage)
即便标记正确,其他类型的内容也不会包含在 Yandex Metrica 报表中。
如何标记材料
按照下方规则为内容添加标记,以确保 Yandex Metrica 能够正确处理。 为获取更完整的统计数据,我们建议您标记所有内容元素,但其中只有三个是必须标记的:标识符、标题和文本。
如果您已使用 JSON-LD,请检查您网站上的标记是否满足这些要求。 条款中的代码示例并非唯一正确的标记选项。
标记可以自动添加到网站中 — 例如,使用 WordPress 插件。 在使用前,请确保所选插件允许您将所有必要的标记元素传递到页面代码中。
注意
如果单个页面上有多个内容单元,请分别标记每个内容单元,以确保正确收集统计数据。
指定以下内容元素(强制性元素用星号标记):
ID*
-
标识符使用保留的
@id键进行指定。 它使 Yandex Metrica 能够区分不同的内容。 ID 不会显示在报表中。 标识符的示例包括内容链接或任意唯一值。"@id": "https://www.example-news.com/life/weather/moscow#cao"如果未找到
@id键,系统会尝试在mainEntity或mainEntityOfPage键内的嵌套实体中进行查找。<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可用于计算完整滚动和完整阅读。 如果用作 ID:- 文章 URL 已指定,Yandex Metrica 会检测 # 后的片段 (
#fragment)。 然后,Yandex Metrica 会在文章中查找包含此片段(id="fragment"属性)的 HTML 元素。 如果找到片段,则会计算指示器。 Article URL 也会被处理。 - 如果选择一个随机值,并且
head包含 JSON-LD 代码,指示器将根据body的内容进行计算。 如果body代码位于另一个 HTML 元素内部,计算时将使用标记的父元素。 这便是报表中的数据可能不完全准确的原因。 如果 Article URL 以 # 结尾且后面没有片段,计算也会以这种方式执行。
- 文章 URL 已指定,Yandex Metrica 会检测 # 后的片段 (
Title*
-
标题显示在 Yandex Metrica 报表中。 它可以在
headline或alternativeHeadline键中指定。 如果找到了这两个键,它们的值将用空格分隔。 例如,如果标题按如下标记:"headline": "Moscow breaks the 1922 temperature record", "alternativeHeadline": "Temperature in November exceeds 12 °C"在报表中,文章的标题为 “Moscow breaks the 1922 temperature record Temperature in November exceeds 12 °C”。
如果上述键均未找到,则使用
name或itemReviewed键的值作为标题(适用于Review类)。
Text*
-
文本必须包含在
text键中。 文本定义了字符的数量。 这是确定材料体量和计算滚动深度与阅读深度指标的必要条件。"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."如果未找到
text键,则以下内容将被视为文本:-
来自
url或@id键值的锚点元素内容。"@context": "https://schema.org", "@type": "Article", "url": "https://www.example-news.com/life/weather/moscow#cao" -
嵌入所描述实体的节点的内容(如果不是
<head>)。 -
所有其他案例中的
<body>页面内容。
在计算文本大小时,计数器字符将被忽略。
备注
您可以获取文本长度超过 500 个字符的内容的完整统计数据。
-
-
作者使用
author键进行指定。 如果有多个作者,请在数组中列出。"author": [ {"@type": "Person", "name": "John Smith"}, {"@type": "Person", "name": "Dylan Brown"} ]如果未找到该键,系统会尝试在
mainEntity或mainEntityOfPage键中的嵌套实体中进行查找。<script type="application/ld+json"> { "@context": "http://schema.org", "@type": "NewsArticle", "@id": "12345", "mainEntityOfPage": { "@type": "WebPage", "author": {"@type": "Person", "name": "John Smith"} } } </script>有了这些数据,您便可以查看单个作者的统计数据。
Subject
-
您可以将关键词或标签标记为主题。 在
about键中指定主题:"about": [ {"@type": "Event", "name": "Heat"}, {"@type": "Event", "name": "Moscow"} ]类型 (
@type) 是可选类型,或者指定标准支持的任何类型。如果未找到
name键,系统将尝试在alternateName键中进行查找。
Dates of publication and revision
-
发布和修改日期在
datePublished和dateModified键中予以指示。 日期以 ISO 8601 格式书写。"datePublished": "2018-12-11T08:56:49Z", "dateModified": "2018-11-06T09:26:10+04:00"
Category
-
标题是网站中专门针对特定主题的部分。 要标记类别,请使用
BreadcrumbList键。 它描述了一系列链接的网页(即“面包屑导航”),通常以当前内容结尾。 在BreadcrumbList内的itemListElement键中,应定义几个ListItem类型的实体,用于描述当前类别和更广泛的类别。类别嵌套可以通过
position键进行定义。 例如,“Life”类别可能包含嵌套类别,如“Weather”和“Incidents”。 如果"position":"1",则内容处于最高级别(“Life”),如果"position":"2",则内容处于第二级别(“Weather”)。内容类别是具有最高
position值的name键的值。备注
目前,统计数据显示有两级类别嵌套。
{ "@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
-
内容 URL 必须包含在
url键中。 我们建议在 # 后插入一个 URL 片段。 指标器将根据 URL 片段指向的内容进行计算。"url": "https://www.example-news.com/life/weather/moscow#cao"
如果标记正确且计数器已正确启用,Yandex Metrica 将很快开始收集内容统计数据。
标记示例
在下面您可以看到 news 标记的示例。
<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>
了解详情
|
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 备注 You can get complete statistics for the content with text longer than 500 characters. |
|
type: or or |
Author You can mark up keywords or hashtags as topics. To do this, define the
|
|
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 备注 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.
备注
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
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
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.