Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/392.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Google Analytics在事件跟踪功能方面存在问题_Javascript_Google Analytics - Fatal编程技术网

Javascript Google Analytics在事件跟踪功能方面存在问题

Javascript Google Analytics在事件跟踪功能方面存在问题,javascript,google-analytics,Javascript,Google Analytics,我想要实现的页面有一个表单。一旦用户点击表单上的提交按钮,就可以在Google Analytics中跟踪记录。 我在我的页面上添加了谷歌分析代码。但是,它不会触发事件跟踪功能 该页面的代码如下所示: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Keepsake Florals</title> <!--li

我想要实现的页面有一个表单。一旦用户点击表单上的提交按钮,就可以在Google Analytics中跟踪记录。 我在我的页面上添加了谷歌分析代码。但是,它不会触发事件跟踪功能

该页面的代码如下所示:

    <!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Keepsake Florals</title>
    <!--link to external css file-->

<link rel="stylesheet" type="text/css" href="keepsakeflorals.css"/>
<link rel="stylesheet" type="text/css" href="ksform.css" />
<link rel="shortcut icon" href="favicon.ico" />
   <script src="scripts/jquery-1.11.3.min.js"></script>




      <script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-87810245-1', 'auto');
  ga('send', 'pageview');

</script>
      <script>

$('#contact-form').on('submit', function(event) {
  // Prevent the browser's default form submission action.
  event.preventDefault();

  ga('send', 'event', {
    eventCategory: 'Contact',
    eventAction: 'Information Request',
    eventLabel: 'Contact Form',
    hitCallback: function() {
      $('contact-form').trigger('submit');
    }
  });
});

      </script>



</head>
<body>

<div id="box">
<h1><a href="index.html" title="click here to return home"> KEEPSAKE FLORALS </a> </h1>
</div>

<div>
<nav id="mainnav"> 
<a href="index.html"> Home</a> |
<a href="aboutus.html"> About Us  </a> |
<a href="flowers.html"> Flowers </a> |
<a href="order.html"> Order </a> |
<a href="review.html"> Review </a> |
</nav>
</div>



<form action="thankyou.html" id="contact-form">

  <fieldset id="contactinfo">
  <legend> <span> Contact Information </span> </legend>
    <label> 
    Name
    <input type="text" name="name" id="nameinput" placeholder="First and last name"  />
    </label>
      <label>
      Email
      <input type="email" name="email" id="emailinput" placeholder="address@example.com" />
      </label>
      <label>
      Phone
      <input type="text" name="phone" id="phoneinput" placeholder="phone number" />
      </label>

     </fieldset>

        <fieldset id="orderflower">
          <legend> <span> Flowers to order </span> </legend> 
          <label for="mother" >
             <input type="radio" name="flower" id="mother" value="mother" checked="checked"  />
             Mother's day flower 
             </label>
                 <label for="father">
                         <input type="radio" name="flower" id="father" value="father" />
                        Fathers day flower
             </label>
                     <label for="otheroccasion">
                    <input type="radio" name="flower" id="occasion" value="occasion"  />
                    Other occasion flower
                            </label>

             <label for="valentinesday">
                 <input type="radio" name="flower" id="vday" value="vday" />
                  Valentine's Day
                  </label>

             <label for="others">
                <input type="radio" name="flower" id="others" value="others"  />
                  Others

                  <input type="text" name="other" id="otherinput">
                  </label>    
              </fieldset>
          <fieldset id="delivery">
          <legend> <span> How to contact you ? </span> </legend>
          <label for "question">
              <input type="radio" name="flower" id="phone"  />
                 Via my handphone number
                 </label>
                  <label for "question">
              <input type="radio" name="flower" id="email"  />
                 Via my email
                 </label>

          </fieldset>
          <fieldset id="helpneeded" >

          <legend> <span> Any help needed? </span> </legend> 
          <textarea id="helpneeded" name="helpneeded" rows="4" cols="20"> </textarea>
          </fieldset>

           <input type="submit" id="submit" value="Validate and Submit" onclick=”ga('send', 'event', 'form', 'submit', 'order sent', 10);”/>
</form>
</body>

</html>

您在此行中使用了不正确的字符:

<input type="submit" id="submit" value="Validate and Submit" onclick=”ga('send', 'event', 'form', 'submit', 'order sent', 10);”/>
请按照DalmTo的建议将“更改为:

<input type="submit" id="submit" value="Validate and Submit" onclick="ga('send', 'event', 'form', 'submit', 'order sent', 10);"/>

您是否尝试过修复“并将其更改为此”有时会使浏览器感到困惑。啊,ole智能引号与直接引号之间的矛盾…@xhinvis欢迎您。如果这解决了您的问题,那么您可能希望接受它作为正确答案,并通知未来的观众问题已经解决。