Reputation: 75
I am using the enhanced ecommerce plugin for Google Analytics in my store.
I am using analytics.js to send transaction information in the checkout success page.
After completing the transaction, I want to update some custom metrics associated with products in the transaction which are not available in the checkout success page.
I was wondering if it is possible to do this via the measurement protocol and if so how?
Thanks
Upvotes: 4
Views: 1204
Reputation: 179
My answer is a year old, but i think i should update an answer. Updating item is possible, but there would a side effect to it. If you call your script again, this will update the transaction in google enhanced eCommerce.
For e.g if a customer has purchased a red shirt from your e-commerce site, and the customer called you that he want green shirt also, you add green shirt to his item to the customer order from the admin control panel side, now you want to update the google analytics, do following code.
ga("create", "UA-XXXXX-Y");
ga("require", "ec");
ga("ec:addProduct", {
"id": "bc823",
"name": "Fuelworks T-Shirt",
"price": "92.00",
"brand": "Fuelworks",
"category": "T-Shirts",
"variant": "green",
"dimension1": "M",
"position": 0,
"quantity": 1
});
ga("ec:setAction", "purchase", {
"id": "d811e9a6-82d5-4145-8f59-9f040cc18fdd", // keep this same to the customer order id.
"affiliation": "Online Store",
"revenue": 194, //calculate net total revenue i.e. only new product added revenue
"tax": 0,//calculate net total tax i.e. only new product added tax
"shipping": 5 // //calculate net total shipping i.e. only new product added shipping
});
ga("send", "pageview")
$194 revenue will be added to your google eCommerce transaction. $5 shipping cost will be added in your google eCommerce transaction.
Now lets talk about side effect, if you update your transaction a day after the original transaction date, google will also update your transaction date. Google enhanced e-commerce script does not support any purchase date parameter, which they should.
Upvotes: 0
Reputation: 32760
You can ad custom dimensions via the data import feature (https://support.google.com/analytics/answer/6014867?hl=en), and even that is applied to incoming data (not retroactively) but I am not aware of a way to import metrics. You certainly cannot do it via the measurment protocol, since this only records new interactions, it does not change existing ones.
The only thing that I know that changes existing data is doing refunds, but I think about the only metric you can change with that is transaction totals.
Upvotes: 0
Reputation: 116918
It is not possible to update data that has already been sent to Google Analytics.
The measurement protocol works exactly as analytics.js does as a matter of fact analytics.js uses the measurement protocol. It is only used to send information to Google analytics.
Upvotes: 1