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.
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
Thread Starter
MaxB
(@sulliwane)
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']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
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 !
If y don’t want a merged report, then you have to set it up per site.