简体   繁体   English

使用Google跟踪代码管理器和Google Analytics(分析)跟踪提交的表单值

[英]Tracking Submitted Form Values with Google Tag Manager and Google Analytics

I am using Google Tag Manager to handle Google Analytics. 我正在使用Google跟踪代码管理器来处理Google Analytics(分析)。 There is a form on my website that has a submit button which I've successfully set up a click listener for through Google Tag Manager. 我的网站上有一个带有提交按钮的表单,我已经通过Google跟踪代码管理器成功设置了一个点击侦听器。

With this click listener I would like to track what input values where present in the form at the time the click listener fires, then be able to sort events in Google Analytics based on these values. 借助此点击侦听器,我想跟踪点击侦听器触发时表单中存在的输入值,然后能够根据这些值对Google Analytics(分析)中的事件进行排序。 I've looked into Google Analytics Dimensions and Metrics but these don't seem to be able to store form values the way I would like them to. 我研究了Google Analytics(分析)维度和指标,但是这些似乎无法以我希望的方式存储表单值。

Does anyone know the best way to go about this? 有谁知道最好的方法吗? I think I might be having trouble understanding what Dimensions and Metrics are really supposed to be used for... Is there some other Google Analytics tool that would accomplish more easily? 我想我可能很难理解什么维度和指标应真正用于......是否还有其他一些Google Analytics(分析)工具可以更轻松地完成?

Take a look at this discussion on Google Tag Manager Community. 查看有关Google跟踪代码管理器社区的讨论

Here is the just of it: 这是正义的:

  1. Create a new Custom JavaScript Macro 创建一个新的自定义JavaScript宏
  2. Assuming you're using auto events: 假设您正在使用自动事件:

     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; } 

All this code was written by Brian Kuhn via the Google Plus post I reference above. 所有这些代码都是Brian Kuhn通过我在上面引用的Google Plus帖子编写的。 Not trying to take credit. 不试图获得荣誉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google跟踪代码管理器和Google Analytics(分析)跟踪 - Google Tag Manager and Google Analytics tracking Google跟踪代码管理器中的Google Analytics事件跟踪 - Google Analytics Event Tracking in Google Tag Manager 移动跟踪Google Analytics(分析)和Google Tag Manager - Mobile tracking google analytics and google tag manager 通过标签管理器跟踪谷歌分析电子商务中的折扣值 - Discount values in google analytics ecommerce tracking via tag manager 使用Google Tag Manager电子商务跟踪到Analytics(分析) - Tracking with Google Tag Manager Ecommerce to Analytics 如何获取Google跟踪代码管理器事件跟踪以发送到Google Analytics(分析)? - How to get Google Tag Manager Event Tracking to send to Google Analytics? 使用Google跟踪代码管理器时保持Google Analytics(分析)跟踪 - Keep google analytics tracking while using google tag manager 通过Google跟踪代码管理器的Google Analytics(分析)未跟踪根网址/ - Google Analytics via Google Tag Manager not tracking root url / 跟踪Google Analytics(分析)中的JavaScript错误,但不使用Google跟踪代码管理器 - Tracking javascript errors in Google Analytics but WITHOUT Google Tag Manager 使用 Google Tag Manager 和 Google Analytics 跟踪产品查看次数 - Product view count tracking with Google Tag Manager and Google Analytics
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM