0

I am working with Firebase Analytics to track custom data in my Android app. Specifically, I want to store source and campaign_id values inside the collected_traffic_source.manual_source and collected_traffic_source.manual_campaign_id fields.

However, I'm facing the following issues:

  1. No Built-in Method: I haven't found any built-in method like setUserId() or setUserProperties() that directly supports storing values in collected_traffic_source.

  2. Using logEvent Method: To work around this, I tried using the logEvent method to store the data, as shown below:

Bundle bundle = new Bundle();
bundle.putString("collected_traffic_source.manual_source", source);
firebaseAnalytics.logEvent(eventName, bundle);

The data gets stored, but it ends up in the event_params instead of the desired collected_traffic_source fields.

How can I correctly store the source and campaign_id values in collected_traffic_source.manual_source and collected_traffic_source.manual_campaign_id? Is there a specific method or approach to achieve this?

1 Answer 1

0

There is automatic Firebase SDK event firebase_campaign being logged when app is opened with campaign parameters. As it is automatic event, it is not possible to log the event from the code base because the event name is reserved. I would recommend to do following:

  • Event firebase_campaign is not shown in Google Analytics 4 console. You need to enable BigQuery export to explore the event.
  • Simulate behaviour and open the mobile app with campaign parameters. Then start exploring your hits in BigQeury export under Event name firebase_campaign. You can use SQL query like this:

SELECT
  TIMESTAMP_MICROS(event_timestamp) AS event_datetime,
  COALESCE(device.operating_system || " - ", "") || COALESCE(device.operating_system_version, "") AS OS,
  COALESCE(app_info.id || " - ", "") || COALESCE(app_info.version, "") AS APP_INFO,
  COALESCE(device.mobile_brand_name || " - ", "") || COALESCE(device.mobile_model_name, "") AS DEVICE_INFO,
  COALESCE(geo.region || " - ", "") || COALESCE(geo.city, "") AS GEO_INFO,
  user_pseudo_id, -- Your App Instance Id
  event_name,
  event_params,
  collected_traffic_source
FROM
  `<replace with your GCP project id>.<replace with your dataset name>.events_intraday_*`
WHERE true
  AND _TABLE_SUFFIX = FORMAT_DATE("%Y%m%d", CURRENT_DATE()) -- today
  AND event_name = "firebase_campaign" 
ORDER BY
  event_datetime DESC

Not the answer you're looking for? Browse other questions tagged or ask your own question.