Support » Networking WordPress » How to track multisite with Google analytics ?

  • Hi all,

    When I want to make a multi-lingual site, I use to set up a multisite install of wordpress.

    In this case, I have two languages so two domains : and

    The same theme is applied on both sites.

    Now I’d like to track each site (as individual sites) on google analytics.

    Can I handle this situation by adding manually some GA code, or do I have to install some wordpress plugin (which i’d prefer to avoid if possible) ?

    Thank you a lot !

Viewing 5 replies - 1 through 5 (of 5 total)
  • Option 1)
    If you are going to manually add the GA code to the theme’s header (or footer) then it should be active in both sites since they use the same theme.
    Pros: you only have to do this once and it will be set up for both sites.
    Cons: If you ever have to change the GA code you have to edit the theme again.
    Unless you make a child theme, an update will most likely erase your changes

    Option 2)
    If you use a plugin then you would probably have to change the settings of the plugin on both sites.
    Pros: This will be much easier to change in the future and you won’t have to worry about theme updates
    Cons: You’ll have to fill in the settings on both sites (really not that big of a deal

    The end result will be the same.

    Moderator Ipstenu (Mika Epstein)


    🏳️‍🌈 Halfelf Rogue & Plugin Review Team Rep

    Option 3)

    Make an mu-plugin file for it instead and have it auto-activated for all sites 🙂 Then you could just hard code in the tracking for all of them.

    +1 for option #3 good call

    Hey, thanks for your answers.

    I will only have 2 running sites on this MU wordpress, so it’s not a big deal to edit things manually. (even I would prefer over a plugin).

    My problem is that the theme is the same on both sites, so if I put the GA code in the footer.php, how will it make the difference between the .fr and the .com ?

    Cause I don’t want the stats to be merged into one report, I’d like one stat report per site.

    So for now, i’ve created two distinct sites in GA (.fr & .com) and for each site GA generates some code. Here is the .fr code (and I have the same for the .com, with different account number)

    <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-35330002-1']);
      (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);

    Should it be the .fr or the .com page that render, how is it supposed to tell GA which report to feed ?

    So maybe a better question would be : What is the right way in GA to deal with 2 sites on MU that share a common theme…and get 2 reports in GA !

    Thx again !

    Moderator Ipstenu (Mika Epstein)


    🏳️‍🌈 Halfelf Rogue & Plugin Review Team Rep

    If y don’t want a merged report, then you have to set it up per site.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to track multisite with Google analytics ?’ is closed to new replies.