c# measurement protocol transaction

女生的网名这么多〃 提交于 2019-12-11 16:35:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!