Yes, tracking dynamic sub-sites with Google Analytics can be a little tricky, but it’s definitely achievable. Essentially, you will want to add a Google Analytics tracking code to each of your site’s templates, so that any new sub-site automatically has the code.
You can use a Google Analytics plugin like MonsterInsights or Google Site Kit that supports WordPress Multisite. These plugins will automatically add the tracking code to each new site created. Both plugins support network-wide settings so you don’t have to configure each site individually.
Another strategy is to use a single Google Analytics account with different ‘Views’ for each website. In this strategy, each sub-site would filter traffic to that specific sub-domain. However, this method will be manual and the new sites need to be added to the Google Analytics account and the relevant filters need to be set.
While Google Analytics API can be very powerful, it’s possibly overkill for what you need. Its steep learning curve makes it not the most viable option, unless you’re comfortable with coding and plan to perform advanced data manipulations.
The key here is automation. Any solutions that automatically apply the Google Analytics code to new sub-sites when they’re created are the way to go. Also, make sure that your solution separates data sufficiently, so you can analyze each sub-site individually. Experiment with different methods and see which one suits your workflow the best.