JSON / LD Breadcrumbs和Google跟踪代码管理器

时间:2022-10-15 15:14:45

I am trying to create a breadcrumb JSON-LD tag which can fire dynamically using Google Tag Manager.

我正在尝试创建一个可以使用Google跟踪代码管理器动态触发的面包屑JSON-LD标记。

I know the elements which I’d need to get to fire dynamically and these are listed below. The code on my page already had a non SCHEMA/JSON based tag which isn’t pulling into Google.

我知道我需要动态触发的元素,下面列出了这些元素。我页面上的代码已经有一个非基于SCHEMA / JSON的标记,而不是谷歌。

It’s been created using a simple ul li function and I wanted to see if there is a custom JS variable that could be used to say for Position 1 take the first li item and dynamically pull this back in GTM.

它是使用一个简单的ul li函数创建的,我想看看是否有一个自定义的JS变量,可以用来表示第一个li项目并在GTM中动态拉回来。

    <script type="application/ld+json">
{
 "@context": "http://schema.org",
 "@type": "BreadcrumbList",
 "itemListElement":
 [
  {
   "@type": "ListItem",
   "position": 1,
   "item":
   {
    "@id": "https://example.com/dresses", - Dynamic 
    "name": "Dresses"- Dynamic
    }
  },
  {
   "@type": "ListItem",
  "position": 2,
  "item":
   {
     "@id": "",- Dynamic
     "name": "Real Dresses"- Dynamic
   }
  }
 ]
}
</script>

1 个解决方案

#1


0  

You may want to create a custom variable within GTM that uses a CSS selector to get the bit you need from the page and then use it within the JSON-LD tag - can't say anything more specific without knowing the structure of your HTML. You can see something similar done here Dynamic JSON-LD with GTM and hopefully you can adapt it to suit your needs.

您可能希望在GTM中创建一个自定义变量,该变量使用CSS选择器从页面获取所需的位,然后在JSON-LD标记中使用它 - 在不知道HTML结构的情况下不能说更具体的内容。你可以在这里看到与GTM动态JSON-LD类似的东西,希望你可以根据自己的需要进行调整。

#1


0  

You may want to create a custom variable within GTM that uses a CSS selector to get the bit you need from the page and then use it within the JSON-LD tag - can't say anything more specific without knowing the structure of your HTML. You can see something similar done here Dynamic JSON-LD with GTM and hopefully you can adapt it to suit your needs.

您可能希望在GTM中创建一个自定义变量,该变量使用CSS选择器从页面获取所需的位,然后在JSON-LD标记中使用它 - 在不知道HTML结构的情况下不能说更具体的内容。你可以在这里看到与GTM动态JSON-LD类似的东西,希望你可以根据自己的需要进行调整。