Learn business growth with Google Analytics 4 Forums Google Analytics 4 Trouble Implementing GA4 Custom Event with Measurement Protocol Data

  • Trouble Implementing GA4 Custom Event with Measurement Protocol Data

    Posted by Bella on 18 May 2022 at 5:22 am

    Hey everyone,

    I’m knee-deep in setting up a custom event on GA4 (Admin > Events > Create an Event) that triggers whenever someone makes a purchase.

    I’ve been firing a “purchase” event using the measurement protocol, here’s what that object looks like:

    {
      "client_id": {{clint_id}},
      "user_id": {{user_id}},
      "events": [
        {
          "name": "purchase",
          "params": {
            "value": {{value}},
            "user_plan":{{plan}},
            "currency": "USD",
            "transaction_id": {{transaction-id}},
            "items": [
              {
                "item_id": {{item-id}},
                "item_name": {{item-name}}
              }
            ]
          }
        }
      ]
    }
    

    This bit seems to be going off without a hitch – I can see the event in GA4 in real time and in other reports.

    The hiccup comes when I try to create a custom event for a specific scenario – say, if user_plan equals “testing_plan”. I crafted a new event as follows:

    parameter = event_name
    value = purchase 
    parameter = user_plan 
    value contains testing_plan
    

    And… zilch. It’s like the event has dropped off the face of the earth. I rummaged through the documentation and couldn’t find anything that could be of help.

    Weird bit is that if I send the purchase event using gtag, the custom event actually works! And GA chatbot suggested changing event_name to “en”, but that does nada too.

    If anyone has any leads – or even wild guesses – on what’s happening, feel free to share away!

    Gabriel replied 1 year, 4 months ago 3 Members · 2 Replies
  • 2 Replies
  • Jesse

    Member
    16 March 2023 at 2:28 pm

    The problem you’re having seems to be tied to how Google Analytics 4 processes events and parameters coming through its Measurement Protocol API. Apparently, custom parameters specified in these events are not instantly accessible for custom event creation, hence your event with the “user_plan” equals “testing_plan” condition isn’t triggering. In contrast, when events are sent via gtag, the parameters are recognized immediately, explaining why your custom event works in this scenario. This is not explicitly stated in the documentation, which might be why you are facing confusion. Until Google addresses this, a workaround could be to keep using gtag for these events if possible.

  • Gabriel

    Member
    30 April 2023 at 1:57 am

    It appears that the issue lies in the interactions between the measurement protocol and GA4, particularly when it comes to creating custom events based on parameters given in the measurement protocol. It might be that these custom parameters aren’t being recognized as they should be. Custom parameters often need to be specified in the GA4 settings in order to ensure they’re being read properly. Make sure your ‘user_plan’ parameter has been registered in GA4 admin settings, in the custom definitions section. It’s also worth noting that custom parameters and events can take up to 24 hours to start appearing in your reports. So, even if everything is set up correctly, you may just need to wait. Also, it’s useful to validate events and parameters with DebugView or a third-party tool. If the issue persists, reaching out to GA technical support may be necessary so they can dig into the issue further.

Log in to reply.