本文介绍了c#测量协议事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将电子商务交易发送给Google Analytics。我已经尝试了所有我能想到的工作,但我总是得到一个GIF89a响应。任何人都可以帮我解决这个问题吗?

 使用(var wb = new WebClient())
{
var data = new NameValueCollection();
data [v] =1;
data [tid] =UA-XXXXXXXX-1;
data [cid] = Guid.NewGuid()。ToString();
data [t] =交易;
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);
}


解决方案



要发送命中到Measurement Protocol验证服务器,使用endpoint / debug / collect而不是/ collect



请参阅:


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);
        }
解决方案

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

这篇关于c#测量协议事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 02:16