问题
I need to send ECommerce transactions to Google Analytics. I've tried just about everything I can think of to get it to work, but I always get a GIF89a response. Can anyone help me troubleshoot this?
using (var wb = new WebClient())
{
var data = new NameValueCollection();
data["v"] = "1";
data["tid"] = "UA-XXXXXXXX-1";
data["cid"] = Guid.NewGuid().ToString();
data["t"] = "transaction";
data["ti"] = "12345";
data["tr"] = "125.00";
data["ts"] = "25.00";
data["tt"] = "10.00";
data["cu"] = "ZAR";
data["an"] = "dkFosTest";
//var url = @"http://www.google-analytics.com/collect";
var url = @"https://ssl.google-analytics.com/collect";
var response = wb.UploadValues(url, data);
var stringResponse = System.Text.Encoding.UTF8.GetString(response);
}
回答1:
Have a look at validating hits.
To send hits to the Measurement Protocol Validation Server use the endpoint /debug/collect instead of /collect
See: https://developers.google.com/analytics/devguides/collection/protocol/v1/validating-hits
来源:https://stackoverflow.com/questions/25399819/c-sharp-measurement-protocol-transaction