Reputation: 31
Google Analytics 4 changes some things like Events and introduces new concepts like User Properties. The Measurement Protocol API does not appear to have parameters to support the new Events or User Properties. Does it actually support Google Analytics 4 and if so, how do we submit the new information to that API? If it doesn't, how soon will the new Google Analytics 4 properties be supported in the Measurement Protocol API?
Upvotes: 3
Views: 3683
Reputation: 4161
I feel weird simply linking to documentation as an answer, but per the question of "Does it actually support Google Analytics 4" and "how do we submit the new information to that API", I feel this is the best way to answer.
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: {},
}]
})
});
Upvotes: 3
Reputation: 14199
The link to the documentation you indicated refers to the measurement protocol v1, adopted by Universal Analytics.
The new GA4 property (App + Web) works with a new version of the measurement protocol, v2. It is a new feature that has already been announced by Google and will be launched over the next few weeks.
We still have to have some patience :)
Upvotes: 2