justRadojko
justRadojko

Reputation: 257

Google analytics for localhost site

I've deployed website that is running on server on local network and I would like to track traffic with Google analytics.

Following code, that was generated by google analytics, is placed in pages that I would like to track

<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-XXXX-Y', { 'cookieDomain': 'none'});        
    ga('send', 'pageview');

</script>

This line of code was modified according to this topic.

    ga('create', 'UA-XXXX-Y', { 'cookieDomain': 'none'});

When I visit my admin page on Google analytics site it says under Status that Tracking is not installed.

Page was visited from several computers but it seems that page view info is not getting to Google servers.

Am I missing something?

Upvotes: 2

Views: 3652

Answers (2)

justRadojko
justRadojko

Reputation: 257

At the end it seemed that inserted code was enough. It just required some time for google servers to get and process the information.

Upvotes: 0

dvdsmpsn
dvdsmpsn

Reputation: 2869

Another way around would be to add a FQDN to your local /etc/hosts file, e.g.

127.0.0.1 localhost.dev

Point your browser to http://localhost.dev/ instead.

Upvotes: 1

Related Questions