Following a previous post for Google Analytics server side ecommerce tracking , I have now written a new and improved version of the C# functions to send ecommerce order data to Google Analytics server-side using Google’s Measurement Protocol.
Documentation for the Measurement Protocol are available on https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide
The new version of the code has fixed an issue where the items purchased were not being saved in Google Analytics and only the order overview was being saved and has been created as a class to allow it to be easily accessed in your code.
The new functions split the data into the ecommerce transaction and then the items purchased which are sent individually.
The functions are in a class called GoogleMeasurementProtocol.cs and this can be referenced with:
GoogleMeasurementProtocol gmp = new GoogleMeasurementProtocol();
Next we create the ecommerce transaction tracking submission:
"Paypal Payment Complete"
Next we loop over the items ordered and send each one to Google Analytics.
foreach (DataRow row in DataTable)
You can download the code from GitHub at https://github.com/briandorey/EcommerceGoogleAnalyticsMeasurementProtocol