Question

Iam trying to get event tracking to work on our site, the code looks like this

(Simplified)

<!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>

The page tracking is working flawless and visits is showing up in realtime view, when i click the mail link i get

Uncaught ReferenceError: _gaq is not defined

All help is appreciated.

Thanks in advance.

Link to the site is http://www.madsvinet.dk

Was it helpful?

Solution

You are mixing up Classic and Universal Google Analytics.

I think your

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

Should be

ga('send', 'event', 'Booking', 'email', 1);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top