0

这是我的问题:我在分析中放置了跟踪事件的代码,但事件没有发送到分析......所以我无法跟踪它们。

这里是代码(我使用通用分析)

<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','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-46738558-1', 'restaurant-mon-repos.fr');
  ga('send', 'pageview');

</script>

现在将代码插入我的页面。

请注意,我在不同的按钮上跟踪不同的事件以在页面上执行不同的操作。

$op .= '<ul class="cro_directionscal">
                    <li class="dir-label">' .  __('To:','localize')   . '</li>
                    <li><strong>' .   stripslashes($postaddr)  .     '</strong></li>
                    <li class="dir-label">' .  __('From:','localize')   . '</li>
                    <li><input id="from-input" type=text value=""/></li>
                     <li><input id="to-input" type=hidden value="' .   stripslashes($postaddr)  .     '"/></li>
                    <li><input id="driveclick" class="" onclick="Demo.getDirections();ga("send","event","Bouton","Clic","itineraire");" type=button value="' .  __('Calculate:','localize')   . '"/></li>
                </ul>
                <p>' . __('The driving directions are interactive. Click on any bold text for further explanation of the route.', 'localize' ) . '</p>
                <div id="dir-container"></div>';

另一个跟踪代码的第二部分:

 $op .= '<input type="submit" onClick="ga("send","event","bouton","clic","contact");" name="cro_form_sub" id="cro_form_sub" val="" .   __("Submit","localize") .  "">';

我不知道破折号是不是问题...

谢谢你们的帮助:)

4

1 回答 1

0

对于 OnClick 上具有 2 个函数的代码的第一部分,我刚刚剪切了 Google Analytics 的部分,然后我将它直接插入到 Demo.getDirections() 函数中并且它可以工作。

对于第二部分,我将 ga() 函数中的 (") 替换为 : (\') 转义的简单引号。它也可以工作!:)

于 2014-03-06T09:59:05.933 回答