First of all, I admit I may be missing something here, but this issue annoys me big time, and I’m sure some people will feel the same.
So, what’s the deal? Well, I’ve been using Google Analytics for WordPress for quite a lot of time now in many installations, some of which are multisites. I love this plugin and all its functionality, and I wouldn’t change it for another one in most of the sites I run. But every time I download and install it in a multisite environment, I keep seeing a notice which reads “Google Analytics is not active. You must select which Analytics Profile to track before it can work”.
Some of you may say “why don’t you just set your Analytics Profile and stop whining?”. Well, I’d wish it was that easy. And that’s because, for some of this multisite installations, the main site is just an internal hub that will be hidden from the public, and doesn’t need to have an analytics profile set up.
I think it’s OK to have the warning in the main site admin, since that’s still a single site on it’s own, but I don’t really think that it’s OK to have the same warning on the network admin side, because the setting that it’s missing belongs to the single site, it’s not a sitewide setting.
So, How to Fix It?
Fortunately, there are a couple of ways to leave this problem behind. The first one consists in modifying the code of the plugin as I’ve done in this pull request to the project’s repository in Github. This works, but I really don’t recommend to do it if you plan to upgrade to plugin to a future version sometime. If my pull request gets accepted sometime (I would not expect it, tough), the problem will be solved, and this post won’t be needed anymore.
Another way, quite cleaner, since you don’t have to modify the plugin itself, is taking advantage of our beloved hook system to remove the filter that triggers the warning. Here’s a Gist with the code I used to accomplish this:
Just add that to a MU plugin, and you’re done.
As I said at the beginning of this post, I’m not really sure if I’m missing something important here that justifies the warning to appear in the network admin too. Perhaps this is done the way it is because of some decision of the developers behind the plugin, so I don’t dare to say it’s a bug or a limitation, and that’s why I would not expect my pull request to be accepted. I only considered this as a problem because it annoys me by breaking my own frame of mind about how I like to organize things, and talked about the issue here since I think some people could find this helpful.