Google Analytics


Well-known member

How do I install Google Analytics I put the code from "Reports" into the "Statistics and Metrics", then if I goto this page, image below. Did I set it up right, I'm new on this Analytics stuff. :confused:

The reason i'm wondering is its got 0 visitors and everything else is 0 or is it cause I only registered 20mins ago?


Active member
In the screenshot above you are looking at stats for March 12. Today is March 13. If you just installed it today, then there will be no data for yesterday.

And also, as Brogan said, it takes a while for the stats to be updated. Sometimes you have to wait a few hours for new data to be added. It's not real-time.


Well-known member
just a followup question

i already added the my Google Analytics Web Property ID in
ACP -> Options -> Statistic and Metrics:

now do i have to put also the code gave by google
in the php files of xf?

if yes where specifically what file?


Ryan Kent

Well-known member
I am setting up Google Analytics for my site. About a month ago I added the GA id into the ACP during my initial set up. A couple follow up questions:

- by adding the info in the ACP then XF automatically sends google the correct info for all pages within the site?

- if so, does that include extra pages we create with add-ons such as our portal page? wiki pages? etc?

- Google suggests we enter a code snippet at the end of every page and I just want to ensure I don't need to do such.

- Also, I am not clear what the "Default Page" is for my site. I know it is my portal page, but I don't know if it is index.html or ? Google asks "The Default page is the webpage to which your server defaults when no page on the domain is specified. For example, if the "index.html" page is loaded from your server when a user enters "", "index.html" is considered to be the Default page."


XenForo moderator
Staff member
Just enter the code in the ACP, it is automatically inserted into every page due to a template include in the PAGE_CONTAINER template.

The default page is the page which is loaded when you browse to your domain -

Turn off friendly URLs and you will see the actual URL of the portal page - I don't have it installed so don't know what it is.

Sadik B

Well-known member
For those who are not sure if GA is working for you or not, just view the page source and you should have Google's analytic code on there.

It would be something like this, with your Analytics ID.

<script type="text/javascript">
    var _gaq = [['_setAccount', 'UA-10855523-4'], ['_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') + '';
        s.parentNode.insertBefore(g, s);
    (document, 'script');


I have setup the Google Analytics code on my page, however it seems the XenForo is not setup for the tracking of subdomain format?
Is it planned in future releases to change to support GA subdomains? or is it possible to edit the code that is being generated?

This is what google generated for use with subdomains:
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
  _gaq.push(['_setDomainName', '']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);