英文:
WordPress Google Tag Manager issue on parent element
问题
我有一个使用GTM跟踪的WordPress网站,我使用WordPress插件来注入脚本。
事件和配置在Google标签管理器的预览模式下工作并触发。
我遇到的问题是,我使用Elementor而不是专业版,我有一个按钮,这是HTML代码:
<div data-id="e2d2099" data-element_type="widget" class="elementor-element elementor-element-edit-mode elementor-element-e2d2099 elementor-element--toggle-edit-tools elementor-widget elementor-widget-button elementor-align-left btn-animation-full-to-border btn-attention-scale-x ui-resizable elementor-element-editable" data-model-cid="c45" id="" data-widget_type="button.default" draggable="true">
<div class="elementor-element-overlay">
<ul class="elementor-editor-element-settings elementor-editor-widget-settings">
<li class="elementor-editor-element-setting elementor-editor-element-edit" title="Modifier Bouton">
<i class="eicon-edit" aria-hidden="true"></i>
<span class="elementor-screen-only">Modifier Bouton</span>
</li>
</ul>
</div>
<div class="elementor-widget-container">
<div class="elementor-button-wrapper">
<a href="#nos-offres" class="elementor-button-link elementor-button elementor-size-xs" role="button" id="ga-works-with-us">
<span class="elementor-button-content-wrapper">
<span class="elementor-button-text">Travailler avec nous</span>
</span>
</a>
</div>
</div>
<div class="ui-resizable-handle ui-resizable-e" style="z-index: 90;"></div>
</div>
在Elementor中,我在ID按钮内添加了 ga-works-with-us
,您可以在<a>标签上看到它。
但是,ID从不与我的触发器匹配,在调试视图(GTM)中,我可以看到类是 "elementor-button-text"
,如果我点击某处,我会看到 "elementor-element elementor-element-4787000 e-con-boxed e-con"
。
那么,如何正确设置我的事件并在每次单击此按钮时触发它呢?
我是JavaScript开发人员,所以我可以添加一些代码,但我更喜欢避免这样做并以正确的方式处理。
英文:
I have a wordpress website with GTM tracking, i use the wordpress plugins to inject the script.
The event & config works and triggered in the preview mode on google tag manager.
The issue i have, i use elementor and not the pro version, i have a button, there is the HTML:
<div data-id="e2d2099" data-element_type="widget" class="elementor-element elementor-element-edit-mode elementor-element-e2d2099 elementor-element--toggle-edit-tools elementor-widget elementor-widget-button elementor-align-left btn-animation-full-to-border btn-attention-scale-x ui-resizable elementor-element-editable" data-model-cid="c45" id="" data-widget_type="button.default" draggable="true">
<div class="elementor-element-overlay">
<ul class="elementor-editor-element-settings elementor-editor-widget-settings">
<li class="elementor-editor-element-setting elementor-editor-element-edit" title="Modifier Bouton">
<i class="eicon-edit" aria-hidden="true"></i>
<span class="elementor-screen-only">Modifier Bouton</span>
</li>
</ul>
</div>
<div class="elementor-widget-container">
<div class="elementor-button-wrapper">
<a href="#nos-offres" class="elementor-button-link elementor-button elementor-size-xs" role="button" id="ga-works-with-us">
<span class="elementor-button-content-wrapper">
<span class="elementor-button-text">Travailler avec nous</span>
</span>
</a>
</div>
</div>
<div class="ui-resizable-handle ui-resizable-e" style="z-index: 90;"></div>
</div>
On elementor inside the ID button i add ga-works-with-us
, you can see it on the balise <a>.
But, the id never match my trigger, on the debug view (GTM) i can see the class is "elementor-button-text"
, want if i click somewhere i have "elementor-element elementor-element-4787000 e-con-boxed e-con"
.
So, who can i do correctly have my event setup and trigger every time this button is clicked?
I'm JS developer so i can add some code, but i prefer to avoid it and do it the correct way.
答案1
得分: 0
我已找到触发所有子元素的方法,感谢这个人。
您需要进入GTM中的触发器部分,选择触发器类型为“点击 - 所有元素”,然后在下面选择“某些点击”,在接下来的三个输入框中,您需要首先选择(或添加):
- 点击元素
- 匹配 CSS 选择器
- #parentId, #parentId *(在我的情况下是
#ga-works-with-us, #ga-works-with-us *
)
完成!这样,您需要在父元素上添加ID,所有父元素或所有子元素都将被触发
英文:
I have found the way to trigger all child on a parent, thanks to this guy
You need to go inside the trigger section in GTM, choose the trigger type "Click - All element", below chosse "Some Clicks", in the three folowing input you need in first to select (or add):
- Click Element
- macthes CSS selector
- #parentId, #parentId * (in my case
#ga-works-with-us, #ga-works-with-us *
)
Done! With this you need to add the ID on the parent element, on all event on the parent or all child will be trigger
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论