Learn business growth with Google Analytics 4 Forums Google Analytics 4 Troubleshooting issue with Google Analytics 4's set method Reply To: Troubleshooting issue with Google Analytics 4's set method

  • Ava

    Member
    2 June 2023 at 4:57 pm

    The issue you’re encountering arises from how Google Analytics 4 handles parameters. When you use “set”, it configures certain default fields to be sent with all tracking hits. However, this doesn’t apply to event parameters as Google Analytics 4 may not persist these parameters across all events.

    In your first code block, you’re sending ‘foo’ as an event parameter which is correct and this is why it is working as intended.

    In your second code block, when you use “set” you’re trying to send a default field, but this won’t apply to an event unless explicitly defined. ‘foo’ is ignored because it’s not a predefined field that is recognized by GA4. If you wanted to set a global value to be sent with every event, you could use ‘user_properties’ in GA4 set-up. Essentially, the difference between the examples you shared is based on the scope of the parameters you’re trying to set/send with your events. This is why they’re not yielding the same result.