1

I am using measurement protocol 4 to track desktop application-features. I have sent the event to Google analytic 4 account with measurement ID and API_secret and received to GA4 account.

Request info

POST /mp/collect?api_secret=xxxxxxxxxxxxxxxxxxxxxx&measurement_id=G-xxxxxxxxxx HTTP/1.1
HOST: www.google-analytics.com
Content-Type: application/json

Payload

{
  "client_id": "XXXXXXXXXXXXXXXX",
  "user_properties": {
    "Language": {
      "value": "en-us"
    }
  },
  "events": [
    {
      "name": "license",
      "params": {
        "LicenseType": "Trial",
        "Expiration": "20 OCT 2022"
      }
    }
  ]
}

We have sending payload same using "WPF" and "C#" in my desktop app with below codes.

private void SendRequest(string payloadJson)
{
    try
    {
        string url = string.Format(@"https://www.google-analytics.com/mp/collect?measurement_id={0}&api_secret={1}", mesurement_id, api_secret);
        HttpWebRequest httpWebRequest = WebRequest.Create(url) as HttpWebRequest;
        if (httpWebRequest != null)
        {
            httpWebRequest.Method = "POST";
            var requestBody = Encoding.UTF8.GetBytes(payloadJson);
            httpWebRequest.ContentType = "application/json";
            using (var requestStream = httpWebRequest.GetRequestStream())
            {
                requestStream.Write(requestBody, 0, requestBody.Length);
            }
            using (var response = (HttpWebResponse)httpWebRequest.GetResponse())
            {
                if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.NoContent)
                    throw new Exception(String.Format("Server error (HTTP {0}: {1}).", response.StatusCode, response.StatusDescription));
            }
        }
    }
    catch (Exception ex)
    {
    }
}

With above code, I am received event to my google analytic 4 account for above payload. I have observed that Demographic section is empty by sending payload as above method.

Note: sending event to google analytic 3 (Universal Account) using measurement protocol 3 demographics is fill base on received event hit.

I have enabled the google signal to fill the Demographics as per received event. But still details not fill by sending event (I have tried after 48hrs).

Kindly someone help to resolve demographic by sending event.

James Z
  • 12,209
  • 10
  • 24
  • 44
Hussain
  • 11
  • 3
  • Hi Hussain, have you figure out more in the meantime? I ended up on this page because my independent attempt ended up with the exactly same result. I believe though that what we observe is by design of this version of Measurement Protocol. Intuitively I start searching on auto-reported (reserved) events user_engagement or first_visit but before burning a lot of research time I thought I also ask here. There does not seem to be much documentation about how to achieve Demographics info being monitored. – Jan Zeman Feb 02 '22 at 08:36
  • I am seeing the same thing. Based on my testing, there are two options; A) it's caused by [data thresholding](https://support.google.com/analytics/answer/9383630), or B) it's not supported with the Measurement Protocol for GA4. In my case I'm capturing a Client ID from gtag, so Google should already have the data I suppose. I haven't had the chance to test things in a high volume environment yet to see if it appears when the reports are not thresholded. Anyway, maybe these clues help someone. – ba0708 Jun 15 '22 at 08:25
  • Isn't that one of the caveats of just using Measurement Protocol? It doesn't trigger the Geographic Location in any way. Reference https://developers.google.com/analytics/devguides/collection/protocol/ga4#geographic_information – Aditya Patil Feb 06 '23 at 22:38

0 Answers0