Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Google Analytics – not reporting visits :(

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #147835
    leongaban
    Participant

    Hey guys, so I uploaded our site to alpha here: http://neytiri.whoat.net/ at the start of this week, and have had friends visit the site.

    However I only see 1 visit on the 19th, and nothing for the rest of the week. Google also is saying that it is receiving data, could there be some sort of major delay going on?

    Our code below, oh and my Stackoverflow for points :)

    //GOOGLE ANALYTICS
    
    
    //==================== WHOAT.analytics = (function ($, w, undefined) { 'use strict';
    
    //initial google setup
    var _gaq = _gaq || [];
    _gaq.lang = 'en';
    _gaq.push(['_setAccount', 'UA-xxxxx-x']);
    _gaq.push(['_setDomainName', 'whoat.net']);
    _gaq.push(['_setAllowLinker', false]);
    _gaq.push(['_gat._anonymizeIp']);
    _gaq.push(['_trackPageview']);
    
    // console.log('inside Analytics');
    console.log(_gaq);
    
    function init() {
        (function () {
            var ga = document.createElement('script'); ga.type = 'text/javascript';
            var s = document.getElementsByTagName('script')[0];
            ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            s.parentNode.insertBefore(ga, s);
    
            console.log(ga);
        }());
    }
    
    //TRACK PAGE VIEWS
    var trackPageView = function (url) {
        //get the url from the pathname if it wasn't passed in
        if (url === null || url === undefined) {
            url = w.location.pathname;
        }
        //if an id is part of the url, replace the id with 'details'
        url = url.replace(new RegExp(/\/[0-9]+$/), '/details');
        _gaq.push(['_trackPageview', url]);
    
        console.log('analytics trackPageView: '+url);
    };
    
    //TRACK SEARCH EVENT
    var trackSearchEvent = function (searchTerm) {
        var url = w.location.pathname;
        url = url.replace(new RegExp(/\/[0-9]+$/), '/details');
        _gaq.push(['_trackEvent', 'search', searchTerm, 'url for search is ' + url]);
    
        console.log('analytics trackSearchEvent: '+searchTerm);
    };
    
    //TRACK VIDEO EVENT
    var trackVideoEvent = function (event, videoID, time) {
        var label;
        if (time !== null && time !== undefined) {
            label = 'video id is ' + videoID + " and time is " + time;
        } else {
            label = 'video id is ' + videoID;
        }
    
        _gaq.push(['_trackEvent', 'video', event, label]);
    };
    
    //track the page just landed on
    trackPageView();
    
    return {
        trackPageView: trackPageView,
        trackSearchEvent : trackSearchEvent,
        trackVideoEvent : trackVideoEvent,
        init : init
    };
    
    
    }(jQuery, window));
    
    $(document).ready(function () { WHOAT.analytics.init(); }); // document ready
    
    #147981
    leongaban
    Participant

    I needed to move the var _gaq = _gaq || [];
    and all the _gaq variables outside of the closure. So above the //GOOGLE ANALYTICS
    Works perfectly now :)

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Other’ is closed to new topics and replies.