2016-11-22 203 views
0

最新值我从谷歌标签管理器这条线,有没有办法让元素在GTM

function(){ 
try{ 
    return document.getElementById('prodid').value; 
}catch(e){ 
    return 0; 
} 
} 

的问题是,有没有办法让PRODID的onClick的最新值?一个产品页面中的产品有差异。所以我需要得到最后一次点击差异/产品的最后产品。目前,在检查从谷歌标签管理器获取的ID没有更新。即时通讯使用Chrome扩展在检查

enter image description here

enter image description here

function(){ 
    var ce = {{Click Element}}; 
    // Now you can use ce and scrape for information on the page related to the element that was last clicked. If jQuery is loaded then it may be easier to get what you need. 

    // Totally fake example 
    var prodId = $('ce').closest('#prodid').text(); 
    return prodId; 
} 

回答

0

内置Click Element变量总是指被点击,并通过检测点击听众,最后一个元素。您可以随时编写一个自定义JavaScript变量,使用该变量,甚至在需要DOM抓取信息时对其进行操作。

function(){ 
    var ce = {{Click Element}}; 
    // Now you can use ce and scrape for information on the page related to the element that was last clicked. If jQuery is loaded then it may be easier to get what you need. 

    // Totally fake example 
    var prodId = $('ce').closest('#prodid').text(); 
    return prodId; 
} 
+0

如何声明{{单击元素}}?我只是试着复制粘贴。我向我扔了这个错误:未知变量'单击元素'在另一个变量中找到。编辑变量并删除对未知变量的引用。 – Clem

+0

'{{Click Element}}'是您可能需要启用的内置GTM变量。转到变量,然后单击红色的配置按钮,然后选中“单击元素”。 – nyuen

+0

谢谢。但标签助手显示的值不会改变。 – Clem

相关问题