I need to know the correct way to send events to GA4 via API, so that GA4 can receive source, medium and campaign for these events.
Here's the context: a user submits a contact form on a website, and thus enters our database. When the form is sent, we also record that user's source, medium and campaign.
Commercial work is carried out on this user and, if he accepts to purchase our service, he goes to a second database. It's like the stages of a CRM sales funnel, for example.
GA4 already receives an event every time the form is submitted on the website, which is tracked in real time. Online, so to speak. Our desire is to start registering with GA4 every time a user agrees to purchase our service, and GA4 needs to receive that user's attribution data. This way, we will be able to see the beginning and end of a conversion path within GA4 itself.
I'm using https://ga-dev-tools.google/ga4/event-builder to facilitate the development of the JSON structure, and then I will apply this JSON to my API query system.
I managed to get the structure below:
{"client_id":"teste123tracking456","non_personalized_ads":false,"user_properties":{"source":{"value":"xxxx"},"medium":{"value":"yyyyy"},"campaign":{"value":"zzzzz"}},"events":[{"name":"teste_tracking_29_12_2023","params":{"value":123,"currency":"BRL"}}]}
I sent this data through the Event Builder itself, and GA4 identified the event in Real Time, but did not link the origin, media and campaign to it. I need help putting together a correct structure.