gpt4 book ai didi

google-analytics - 使用 Google Tag Manager 和 Google Analytics 跟踪提交的表单值

转载 作者:行者123 更新时间:2023-12-03 15:48:31 30 4
gpt4 key购买 nike

我正在使用 Google 跟踪代码管理器来处理 Google Analytics。我的网站上有一个表单,其中有一个提交按钮,我已经通过 Google 跟踪代码管理器成功地为其设置了点击监听器。

有了这个点击监听器,我想跟踪点击监听器触发时表单中出现的输入值,然后能够根据这些值对 Google Analytics 中的事件进行排序。我查看了 Google Analytics 维度和指标,但它们似乎无法按照我希望的方式存储表单值。

有人知道解决这个问题的最佳方法吗?我想我可能无法理解维度和指标的真正用途...是否有其他一些 Google Analytics(分析)工具可以更轻松地完成任务?

最佳答案

看看这个discussion在 Google 跟踪代码管理器社区上。

这里是它的正义:

  1. 创建一个新的自定义 JavaScript 宏
  2. 假设您正在使用自动事件:

    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 帖子编写的。不想居功。

关于google-analytics - 使用 Google Tag Manager 和 Google Analytics 跟踪提交的表单值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22362023/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com