Learn business growth with Google Analytics 4 Forums Google Analytics 4 Exploring the Transition from Google Universal Analytics to GA4 Event Tracking

  • Exploring the Transition from Google Universal Analytics to GA4 Event Tracking

    Posted by Ethan on 20 March 2023 at 4:58 pm

    We’re currently using the Measurement Protocol in Google Universal Analytics to parse our streaming server logs and post everything as events. But we’re now wondering how we can make this happen for GA4. For instance, here’s an example of a post we make with a PHP script using curl when someone tunes into one of our HD channels:

    v=1&tid=UA-123456789-1&cid=a76-b177-b238-b39d-634225a16b6e&ds=web&ua=AppleCoreMedia%2F1.0.0.19G71%20%28iPad;%20U;%20CPU%20OS%2015_6%20like%20Mac%20OS%20X;%20&ul=en-us&uip=1.2.3.4&cs=event&cn=station&cm=stream&ck=WXYZ%20HD3%20The%20Channel&t=event&ec=Stream&ea=Listen&el=WXYZ%20HD3%20The%20Channel&ev=10&cg1=Hour10&cg2=channel&cg3=Midday%20Weekdays%209am-1pm
    

    We usually find these Events under the Behavior section in Universal Analytics, sorted under the Event Category of Stream. I wrote the script using the Measurement Protocol parameter reference, which now surprisingly shows a link to GA4’s Measurement Protocol at the top of the page – but without a similar guide to parameters. As you can probably notice, we’ve mainly posted to categories, actions, labels, and even custom groups.

    Here’s another example where a listener tunes into a show that posts to campaign source/media events:

    v=1&tid=UA-123456789-1&cid=a97-b76-b210-b2d-634225a16b6e&ds=web&ua=Mozilla%2F5.0%20%28Windows%20NT%2010.0;%20Win64;%20x64%29%20AppleWebKit%2F537.36%20%28KH&ul=en-us&uip=1.2.3.4&cs=event&cn=station&cm=stream&ck=The%20Show&t=event&ec=Stream&ea=Listen&el=The%20Show&ev=10&cg1=Hour1&cg2=podcast&cg3=Midday%20Weekdays%209am-1pm
    

    Any kind soul out there who can point us in the right direction for converting these to GA4 events?

    Dakota replied 10 months, 4 weeks ago 3 Members · 2 Replies
  • 2 Replies
  • Rishi

    Member
    21 June 2023 at 2:09 pm

    Sure! When switching to GA4 from Universal Analytics, the events need to be translated uniformly. In the case of Universal Analytics, ‘action’ (ea) maps to ‘event_name’ in GA4. Similarly, ‘event_category’ (ec), ‘event_label’ (el) and ‘event_value’ (ev) from Universal Analytics change to parameters with the same names in GA4 along with their respective parameter values.

    For instance, if you had an event in GA4 that corresponded to ‘Listen’ in Universal Analytics, you’d structure it like:

    gtag('event', 'Listen', {   
    'event_category': 'Stream',   
    'event_label': 'The Show',   
    'event_value': '10' 
    });
    

    Here’s a handy Google help center article to understand this better.

  • Dakota

    Member
    2 July 2023 at 4:22 pm

    To convert your Universal Analytics events to GA4 events, you can use the GA4 Measurement Protocol API. This protocol works a bit differently from the previous one. In GA4, instead of events being categorized under Event Category, Action, and Label, data is sent as event name and parameters. The event name can be any string and you are allowed to send up to 25 additional parameters with each event, which can be values or nested parameters. For example, in your case, the ‘Stream’ category can likely be the event name and ‘Listen’ can be a parameter for that event. There should be similar restructuring for other parameters as well. It’s also important to note that some parameters are reserved for automatically collected events and you should avoid using these names for your custom event parameters. Ensure to check the GA4 documentation for more details.

Log in to reply.