【问题标题】:Filtering click element event with matching css selector to an object使用与对象匹配的 css 选择器过滤单击元素事件
【发布时间】:2017-04-25 06:53:21
【问题描述】:

我遇到了问题,似乎无法让 GTM 专门注册该事件。

这是当有人点击它时我需要注册的元素的 HTML 外观。

<div class="targetDiv option option-hoverable">
    <div class="shape">
      <svg width="140" height="140" viewBox="0 0 140 140" xmlns="http://www.w3.org/2000/svg" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
        <title>Shape + Shape + Shape</title>
            <desc>Created with Sketch.</desc>
              <g transform="translate(0 0)" sketch:type="MSShapeGroup" fill="none">
                <circle id="Shape" fill="#CFDF80" cx="40" cy="84.434" r="40"></circle>
                <circle id="Shape" fill="#FDE9E8" cx="80" cy="40" r="40"></circle>
                <circle fill="#E2506E" cx="100" cy="100" r="40"></circle>
              </g>
      </svg>
    </div>

                <h3>Product Title</h3>
                <div class="actions">
                <a class="button button-subtle button-toggle" data-colors="tender" data-toggled="Select" href="">Select</a>
                </div> 
</div>

我无法在外部 DIV 单击上注册单击,它会在按钮单击或形状上单击时注册。我需要它在具有类 targetDiv 的 DIV 上注册。

我从其他地方得到了正确的点击触发器,所以收听不是问题。

现在触发器是这样设置的:

触发器类型 - 点击 - 所有元素

触发器会在某些点击时触发。

条件是:

点击元素 -> 匹配 CSS 选择器 -> targetDiv

【问题讨论】:

    标签: google-tag-manager


    【解决方案1】:

    这个

    Click Element -> matches CSS selector -> targetDiv
    

    想要匹配一个 &lt;targetDiv&gt; 元素,该元素不存在于您的 html 代码中。

    尝试在类名前写一个点,因为这样可以为一个类编写一个 CSS 选择器:

    Click Element -> matches CSS selector -> .targetDiv
    

    【讨论】:

      猜你喜欢
      • 2010-09-09
      • 2015-09-12
      • 2011-05-23
      • 2016-03-03
      • 2018-02-06
      • 2010-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多