• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.4 Google Analytics Setup


Well-known member
I am busy setting this up and have placed the required code into my XF ACP. Now I will be using the analyticstracking.php option but am not sure where this file should sit in my forum folders?


XenForo developer
Staff member
What option is that? If you're wanting to do anything more advanced with analytics, you likely can't use the default system -- you can just put your code in the google_analytics template though.


XenForo developer
Staff member
Well I'm not clear what you're trying to do exactly.

In general, I'm mostly just saying that if you're wanting to do anything with GA that is more than just adding your ID via the control panel, you'll need to edit the template. Normally, you'd be replacing the whole thing with the new code you got (presumably from the GA site).


Well-known member
Ok that is what I wanted to know, I remove this and replace it with my GA code

<xen:if is="{$xenOptions.googleAnalyticsWebPropertyId}"><script>

    var _gaq = [['_setAccount', '{$xenOptions.googleAnalyticsWebPropertyId}'], ['_trackPageview']];
    !function(d, t)
        var g = d.createElement(t),
            s = d.getElementsByTagName(t)[0];   
        g.async = true;
        g.src = ('https:' == d.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        s.parentNode.insertBefore(g, s);
    (document, 'script');

    </script><xen:comment><!--Adapted from http://mathiasbynens.be/notes/async-analytics-snippet--></xen:comment></xen:if>