Learn business growth with Google Analytics 4 Forums Google Analytics 4 Managing Analytics Configuration for UA and GA4 Reporting

  • Managing Analytics Configuration for UA and GA4 Reporting

    Posted by Ethan on 22 April 2022 at 5:54 pm

    Hey, I need a bit of help guys. I’ve shifted my Google Analytics UA properties over to Google Analytics GA4 properties, right? So, for the UA properties, we’ve been plugging into the Spatie/analytics library which uses the Google Analytics Reporting API v4. The thing is, now that my properties have made the move to GA4, it seems like I’m going to need to migrate the reporting API too, because the one we’re using can’t really support GA4. Do you know how we could keep the configuration for both the UA reporting and GA4 reporting in my analytics.php file? Couldn’t find any info on this, so any ideas are more than welcome.

    Ethan replied 11 months, 2 weeks ago 2 Members · 2 Replies
  • 2 Replies
  • Isabella

    Member
    13 November 2022 at 3:56 am

    Currently, as per the official Google Developers documentation, GA4 properties only support the Google Analytics Data API (previously called the App + Web properties API). The v4 Reporting API only works with Universal Analytics (UA) properties. There’s also no direct migration path from v4 to the Data API, as they have different structures and capabilities.

    When working with both UA and GA4 reporting, you would have two different configurations. You could set up a conditional check within your PHP code that determines which set of configurations to use based on the property type. For the time being, it’s advisable to maintain your Universal Analytics Property alongside your GA4 Property, so you might need to dual-tag your site and compromise by using two separate libraries, one for each GA version, within your analytics.php file.

    Also, note that to use the Google Analytics Data API, you’ll either have to use Google’s client library (which supports PHP) or make HTTP requests to the API directly. However, I recommend watching Google’s updates closely as they are evolving their GA4 support.

  • Ethan

    Member
    4 June 2023 at 5:27 am

    Sure, mate. So as of right now, there isn’t a straightforward way to have both UA and GA4 reporting in the same analytics.php file since Google’s v4 API does not support GA4. That being said, Google is developing a new API for GA4 which should solve this problem when it gets rolled out. For now, just stick to using them separately.

Log in to reply.