Google Analytics

Integration and use of Google Analytics

Google Analytics is the enterprise-class web analytics solution that gives you rich insights into your website traffic and marketing effectiveness. Powerful, flexible and easy-to-use features now let you see and analyze your traffic data in an entirely new way. With Google Analytics, you're more prepared to write better-targeted ads, strengthen your marketing initiatives and create higher converting websites.

 

 

 

Google analytics integration

To integrate Google Analytics into your application proceed to https://www.google.com/analytics.
Login using your google account and get a tracking code. This tracking code is an unique number by which Google can track the visits to your website.

This tracking code is supplied within a piece of javascript you have to add on the pages of your appication. In the following example the tracking code is UA-19936097-1

 

<script async src="https://www.googletagmanager.com/gtag/js?id=UA-19936097-1"></script>
<script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', 'UA-19936097-1');
</script>

 

The easiest way to add this tracking code snippet to each page of your application is to add it to your surrounding page. But be careful: every page will be visible for google this way. So if you want to separate contents for anonymous and logged on users you should do something like:

 

#if ($session.isUserLoggedOn())
    ## NO GOOGLE TAG
#else
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-19936097-1"></script>
    <script>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());
        gtag('config', 'UA-19936097-1');
    </script>
#end