4

Hi I am implementing Google Analytics App+Web new property and trying to send data from the backend to Google Analytics property. I could not find reference/documentation for sending hits to the App+Web property. In the measurement protocol documentation only list the protocol version v=1 while I assume the App+Web should be using v=2.

Does anyone know where I can find the documentation?

Thanks.

  • 1
    You can find some information about new measurement protocol (v2) here: https://www.thyngster.com/technical-overview-of-new-appweb-properties/ Remember that APP+WEB is currently in beta and it’s likely adding new parameters in the upcoming months to cover all the current Google Analytics functionality / data points. – Michele Pisani Oct 22 '19 at 20:12

1 Answers1

1

Now that the App + Web property has evolved into Google Analytics 4, the Measurement Protocol is also updating to v2, but it is back into Alpha stage.

I answered a similar question earlier, so I'll provide that here as well:

Here is the Documentation specifically for the Measurement Protocol for GA4

As you can see it is back into an Alpha stage, so the answer to "how soon will the new Google Analytics 4 properties be supported in the Measurement Protocol API" is however long it takes Google to move from Alpha to Beta and then to stable release– I would plan for quite a while.

To include some code, here is a snippet from that documentation of one way to submit an event. That being said, just like the Measurement Protocol v1 there will undoubtably be countless ways to send data to the new API.

const measurement_id = `G-XXXXXXXXXX`;
const api_secret = `<secret_value>`;

fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${measurement_id}&api_secret=${api_secret}`, {
  method: "POST",
  body: JSON.stringify({
    client_id: 'XXXXXXXXXX.YYYYYYYYYY',
    events: [{
      name: 'tutorial_begin',
      params: {},
    }]
  })
});
GreatBlakes
  • 3,971
  • 4
  • 20
  • 28
  • This doesn't seem to be the endpoint that gtag.js uses or that is discussed here: https://www.thyngster.com/app-web-google-analytics-measurement-protocol-version-2 I also couldn't find any way to create the `api_secret` mentioned in the docs. – wilsonpage Oct 20 '20 at 08:59
  • Very interesting– it's funny, but in my experience I actually tend to trust community tutorials until Google's documentation is out of alpha/beta.It is also interesting to see that secret token in the documentation– either they are planning on integrating it with the Google Developer Console, or that is part of their development environment. I think it's just too early to tell on a lot of this stuff for v2– but if people in the community are finding methods that work I do trust them– until Google makes a change (which is extremely likely and frequently expected during the alpha phase). – GreatBlakes Oct 21 '20 at 12:27
  • Also from my initial research that I've been doing on GA4, they are treating it separate from gtag (even though the functions are the same in the JS implementation), so it would not surprise me if the endpoints remain different. – GreatBlakes Oct 21 '20 at 12:29
  • I'm now seeing the ability to create an api_secret via Admin > Data Streams > Your Stream > Additional Settings > Measurement Protocol API Secrets. I created a secret, sent (validated) API requests via /mp/collect endpoint, but not seeing any events arriving in my Real-Time dashboard. – wilsonpage Oct 28 '20 at 09:33
  • You have to send events that are to existing client_ids so that may be why you don't see your hits. – MarkeD Feb 17 '21 at 17:10