I'm looking for best practice solutions for Google Analytics for a site which has many (1000s) of subdomains as part of a WP multisite network. Each subdomain is independent of each other (i.e. there is no click-through traffic from one to another). Since, Google Analytics only allows a maximum of 50 properties, what is the best way to set this up using Google Analytics and Google Tag Manager.

Ultimately, I'd like to be able to share statistics from each subdomain with their respective "owners" as well.

  • Are all of the subdomains accessed at an actual subdomain URL? That is, site1.example.com, site2.example.com, and so on, with no custom domains.
    – Reve
    Commented Aug 7, 2020 at 18:54
  • @Reve - right now they are all accessed as subdomains, however a small number of them may be accessed as custom domains in future.
    – zighead
    Commented Aug 10, 2020 at 2:47

1 Answer 1


Your best approach will depend on your data needs.

At one end of the spectrum you could send all data to a single GA Property and View and use a filter to prepend the hostname so you can distinguish the different subdomains. Then you can use segmentation or filtration to scope in to only a single one. [If they were all going to be accessed at a subdomain address, you could prepend just the subdomain, but prepending the entire hostname will future-proof you against custom domains.] See my answer to a near-duplicate question for details.

You want to make sure to have an unfiltered View, and in this case probably a View that has your prepending filter but no others and no URL query parameter removal. Keeping an unfiltered set of data is best practice because it is invaluable for troubleshooting your tracking setup.

However! You have substantially more sites than the asker of that other question, and that changes the considerations. This may still be a good solution for you, but it will depend on the kinds of data you want to retrieve.

This one-View approach will allow you to get accurate, site-specific data for anything that can be accessed in the reports under Behavior > Site Content. This would include most popular pages, total pageviews, most popular landing pages, and even total sessions (via the Landing Pages report). The data would come from table filtration of standard reports.

If you want additional session or user data, events, onsite search tracking, Enhanced Ecommerce tracking, or more in-depth analysis, you will require a segment or secondary dimension to scope your data in to a single site. That will trigger data sampling, and its effects will be profound on combined analytics for thousands of websites.

When sampling is triggered, any date range that includes more than 500,000 sessions will be sampled: a random selection of 500,000 sessions will be chosen and data from that sample will be scaled up to approximate the data for the whole collection. Sampled data is more accurate for more common events; the more rare an event is, the more likely sampling is to miscount it greatly. Since each site will be only a small fraction of the whole, every kind of hit per site would fall into this latter category.

So suppose you want the kinds of data that trigger sampling. Then what?

The most accurate data and most flexibility would come from everything going to its own Property. That's clearly cumbersome to the point of impossibility for this many sites, so let's look for something in between.

The best compromise idea I've had is to split sites up according to their names (by which I mean subdomain/custom domain). If you have the list of names, you could split it into 50 equal pieces alphabetically and then approximate that split by the first 2 or 3 letters. That is, if you were splitting

  • accuracy
  • aerobics
  • amazement
  • amazon
  • analytics
  • astroturf

in 2 pieces, you would split either between al and am or between am and an. Each of these pieces will correspond to a Property in your GA account.

If you are using Google Tag Manager, which I highly recommend anyway, you can create Constant variables for each Property's ID, and a Custom JavaScript variable to return the correct ID variable based on the Page Hostname. Use that variable as the ID in your settings variable, and all of your tracking tags can be shared across all sites.

(I recommend this stack of variables because double-checking that your {{GA ID - aa-am}} variable has the correct value and your {{GA ID - Dynamic}} variable is returning {{GA ID - aa-am}} for the correctly matching sites is a lot easier and more error-proof than checking that the dynamic ID is directly returning the correct numerical value.)

On the Google Analytics end, you will still want to prepend the hostname via a filter, since multiple sites will still be in the same Views. You can, if desired, further subdivide your sites using Views. Since sampling is applied at the View level, this will reduce its effects even more.

Preserving two Views per Property to be the unfiltered and minimally filtered data views, you could carve up your lists into 23 sublists each and use View filters to send each sublist to its own dedicated view. The prepending filter will also go at the View level.

You could also do a variation of this with fewer subdivisions, though the more sites share a View, the larger the effect of sampling on extracting an individual site's data.

I like this approach as the middle ground because, although it requires significant setup work, it is one time only - future sites will slot into their appropriate places automatically. Tracking tags also only have to be set up once to apply to all sites, whether now or later. You get perhaps the best data accuracy possible within a single GA account, and since you can name the Properties and Views according to the segment of the alphabet they include, you can easily find the data for a specific site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.