[英]Tracking Submitted Form Values with Google Tag Manager and Google Analytics
我正在使用Google跟蹤代碼管理器來處理Google Analytics(分析)。 我的網站上有一個帶有提交按鈕的表單,我已經通過Google跟蹤代碼管理器成功設置了一個點擊偵聽器。
借助此點擊偵聽器,我想跟蹤點擊偵聽器觸發時表單中存在的輸入值,然后能夠根據這些值對Google Analytics(分析)中的事件進行排序。 我研究了Google Analytics(分析)維度和指標,但是這些似乎無法以我希望的方式存儲表單值。
有誰知道最好的方法嗎? 我想我可能很難理解什么維度和指標應真正用於......是否還有其他一些Google Analytics(分析)工具可以更輕松地完成?
查看有關Google跟蹤代碼管理器社區的討論 。
這是正義的:
假設您正在使用自動事件:
function() { // Assuming that {{element}} is the form you want. // This should be the case if you're using Auto Events. var form = {{element}}; // Assuming there's only one <select> in the form. var select = form.getElementsByTagName('select')[0]; var results = []; for (var i=0; i<select.options.length; i++) { // Assuming you want the value attributes of the selected. // You could also use .text here instead of .value. if (select.options[i].selected) results.push(select.options[i].value); } // Assuming you want an array of the selected values. // If you want a CSV string, return results.join() instead. return results; }
所有這些代碼都是Brian Kuhn通過我在上面引用的Google Plus帖子編寫的。 不試圖獲得榮譽。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.