1

I have a custom metric in Google Analytics. I'm inserting it using Google Analytics Measurement Protocol.

When I make a request to Google Analytics, is there a way to replace the existing value of the metric instead of adding new value to it?

Let's say that the current value of that metric is cm1=100. When I send the value 500 via Measurement protocol, I want cm1 to equal 500, not 500+100=600. How do I do that?

I'm currently using this kind of URL to insert custom metrics:

https://www.google-analytics.com/collect?v=1&ni=1&tid={tracking_id}&cid={cid}&t=event&ec={category}&ea={action}&el={label}&cm1=500

DaImTo
  • 72,534
  • 21
  • 122
  • 346
Sergey
  • 39,828
  • 24
  • 80
  • 122

2 Answers2

2

No there is not a way to do that. The reason being is that the scope of custom metrics is defined either hit level or product level.

https://support.google.com/analytics/answer/2709828?hl=en

Joe Law
  • 255
  • 3
  • 11
2

The Google Analytics Measurement protocol is used for inserting data into Google Analytics, the javascript snipet that websites use also uses the measurement protocol, as does the IOS and Android SDKs.

Once data is inserted into Google Analytics there is no way to change the data that was inserted. For example when you are using ecommerce and a user adds an item to there shopping car the item is inserted into Google Analytics if the user then removes it you need to credit the users record that is done by adding the same item again only with a - value This doesn't remove either item it just nulls them out kind of.

Think of the measurement protocol as inserting a row into a database you insert an event with custom metric 1 having a value of 500 then in 5 minutes you insert another row with custom metric 1 having a value of 200 you now have two rows one where custom metric is 500 and another where its 200. There is no way to update data that has already been inserted into Google Analytics. Google Analytics data does not change once it has been inserted and processing is complete.

DaImTo
  • 72,534
  • 21
  • 122
  • 346