使用analytics.js进行事件跟踪

时间:2014-01-14 14:07:12

标签: javascript event-tracking

我试图让事件跟踪在我们的网站上运行,代码看起来像这样

(简体)

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <link href="madsvinet.css" rel="stylesheet" type="text/css">
    <script src=
    "http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js" type=
    "text/javascript"></script>
    <script src="jquery.masonry.min.js" type="text/javascript"></script>
    <script src="js/slimbox2.js" type="text/javascript"></script>
    <link href='http://fonts.googleapis.com/css?family=Cousine:400,700' rel=
    'stylesheet' type='text/css'>
    <link href="css/slimbox2.css" rel="stylesheet" type="text/css">
    <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-47006031-1', 'madsvinet.dk');
    ga('send', 'pageview');

    </script>
</head>

<body>
    <script>
$(function(){     $('#container').masonry({      itemSelector: '.box'    });  });
    </script>

    <div id="container">
        <div class="box">
            <h2>Booking</h2>
            <p><!-- DinnerBooking Booking Box Start -->
             <script src="http://js.i.dinnerbooking.eu/onlinebooking.js" type=
            "text/javascript"></script> <a      href="http://madsvinet.b.dinnerbooking.com/onlinebooking/205/2"
            onclick="return openDBWindow(this.href);" title=
            "Book dit bord online">Book dit bord online »</a> 
            <!-- DinnerBooking Booking Box End --></p>

            <p>Skal du have bord til 7 eller flere så skriv en 

            <a onclick=
            "_gaq.push(['_trackEvent', 'Booking', 'Email', '1']);" href=
            "mailto:booking@madsvinet.dk">mail</a> til
            booking@madsvinet.dk.<br>

        </div>

页面跟踪工作完美无缺,当我点击邮件链接时,实时视图中会出现访问

Uncaught ReferenceError: _gaq is not defined

感谢所有帮助。

提前致谢。

该网站的链接是http://www.madsvinet.dk

1 个答案:

答案 0 :(得分:0)

您正在混淆ClassicUniversal Google Analytics。

我认为你的

_gaq.push(['_trackEvent', 'Booking', 'Email', '1']);

应该是

ga('send', 'event', 'Booking', 'email', 1);