【问题标题】:How do I track a conversion in Google Analytics Based on Form Submission?如何根据表单提交在 Google Analytics(分析)中跟踪转化?
【发布时间】:2015-05-28 07:51:25
【问题描述】:

我在我的网站的单个登录页面上有一个表单。我在我的网站上使用 Google Analytics。提交表单后,我想以某种方式在 Google Analytics 中跟踪它,作为转换(或其他一些统计数据)。

有没有人做过类似的事情?我知道有自定义事件,例如视频点击/等,但我想查看表单提交,或者如何为表单提交设置自定义事件。

【问题讨论】:

    标签: javascript jquery forms google-analytics


    【解决方案1】:

    要跟踪表单提交,您可能需要查看Event Tracking

    如果你使用的是 jQuery,你可能会有类似的东西:

    <form action="thank-you.html" method="POST">
       <!-- Some inputs -->
       <!-- ... -->
    
       <input type="submit" value="Send" />
    </form>
    

    然后您可以使用以下方式跟踪表单交互:

    (function ($) {
       $('form').on('submit', function (event) {
          // Temporarily prevent submission of the form:
          event.preventDefault();
    
          // Keep a reference to the form:
          var form = $(this);
    
          ga('send', 'event', {
             'eventCategory': 'Form',    // Event Category (Required).
             'eventAction': 'Submit',    // Event Action (Required).
             'eventLabel': 'Form Title', // Event Label (Optional).
             'hitCallback': function () {
                // Once the Event has been sent to Google Analytics, submit the form:
                form.submit();
             }
          });
       });
    })(jQuery)
    

    然后,您可以将此事件用作 Google Analytics 中的目标,以获取有关表单提交的具体见解:https://support.google.com/analytics/answer/1012040?hl=en

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-17
      • 2016-09-11
      • 1970-01-01
      • 2023-01-22
      • 2014-04-25
      • 2023-04-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多