Google Analytics & Multi-Site (sub-directories)

6 replies
  • WEB DESIGN
  • |
I'm setting up a multi-ste using sub-directories and will be using Google Analytics to track some data. I'm interested in knowing if I only need to create one Analytics Profile to track the entire site and past the code on the main site?

www(dot)mysite(dot)com/

or if I have to create multiple profiles for each sub-directory site and insert the code on every sub-directory?

www(dot)mysite(dot)com/subdirectory/
#analytics #google #multisite #subdirectories
  • Profile picture of the author developdaly
    You only need one profile, and I would create a tiny little plugin to put in the "mu-plugins" directory (mu stands for Must Use). That will force all sites on the network to use the GA script.

    Since it's a subdirectory Google just thinks the other network sites are pages off of your main site. However, you could also create additional profiles to filter out traffic from a single site -- as long as you don't have too many, this is pretty nice.

    Here's the plugin code you could use:

    Code:
    add_action( 'wp_footer', 'my_analytics' );
    function my_analytics() {
    ?>
    
    <!-- YOUR ANALYTICS SCRIPT HERE -->
    
    <?php
    }
    {{ DiscussionBoard.errors[5971819].message }}
  • Profile picture of the author Istvan Horvath
    The problem with the solution given above is that the OP will never bee able to properly track WHICH one of the 54 sites created is visited... if they all have the same GA script installed.
    Signature

    {{ DiscussionBoard.errors[5974074].message }}
    • Profile picture of the author andymisiu
      Originally Posted by Istvan Horvath View Post

      The problem with the solution given above is that the OP will never bee able to properly track WHICH one of the 54 sites created is visited... if they all have the same GA script installed.
      Well, to his defense... he probably doesn't know the whole story. I should have elaborated on the use needed.

      So, given your response... should I create a new google analytics profile for each baseball team being used as a subdirectory?
      {{ DiscussionBoard.errors[5974114].message }}
    • Profile picture of the author developdaly
      Originally Posted by Istvan Horvath View Post

      The problem with the solution given above is that the OP will never bee able to properly track WHICH one of the 54 sites created is visited... if they all have the same GA script installed.
      Not true. Since every site is a subdirectory it will simply be an additional path on the reports.

      A single profile would like like this:

      /
      /about
      /sub-site-1/
      /sub-site-1/about

      ... including the directory of the sub-site, so that you could drill down into the directory to see stats for the specific site.
      {{ DiscussionBoard.errors[5974953].message }}
  • Profile picture of the author Istvan Horvath
    If you go manually... then, rpobably, yes.

    You may want to look at this plugin:
    WordPress › Google Analytics Multisite Async « WordPress Plugins
    (made specially for multisite)
    Signature

    {{ DiscussionBoard.errors[5974235].message }}
    • Profile picture of the author andymisiu
      Originally Posted by Istvan Horvath View Post

      If you go manually... then, rpobably, yes.

      You may want to look at this plugin:
      WordPress › Google Analytics Multisite Async « WordPress Plugins
      (made specially for multisite)
      Looks interesting, I'll have to check it out. Thanks for your replies! what a project I have a brewing. It's crazy getting everything lined up, but it's serving it's purpose...... to learn.
      {{ DiscussionBoard.errors[5974919].message }}

Trending Topics