Im missing something with the UTM information using GA4's Measurement protocol.
With the old Universal Analytics, this data only needed to be set through the url (utm_source=sourceValue&utm_medium=mediumValue&utm_campaign=campaignValue), and will be stored in the user_id session automatically, so when i was using Mesurement protocol calls from my backend i only needed to give the user_id and the UTM parameters will populate automatically.
But with GA4 I don't find any way to do my backend calls with this UTM data also sending client_id and user_id parameters.
I found ways to set UTM parameters using gtag but it doesen't work the same way using Measurement protocol... I also tried doing the call using get parameters https://www.google-analytics.com/mp/collect?cn=campaignValue&cs=campaignSource&cm=campaignMedium&measurement_id=${measurement_id}&api_secret=${api_secret} and post parameters it works fine with the params (cs cn cm), but im unable to find the campaign information in GA4 dashboards.
Anyone struggling with this?
Using
campaign_detailsevent to send campaign params: https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#campaign_details.Important:
session_idmust also be added to. It can be acquired from a GA cookie variable:_ga_<GA measurement_id>, the first large number. For example, GS1.1.1704773506.16.1.1704777354.0.0.0 // 1704773506 is what you need.This API function can extract it:
Example request body:
This video has more information about this: https://www.youtube.com/watch?v=r_eoeU2qUn0