示例#1
0
        public async Task CollectVisitAsync(AnalyticsVisit data)
        {
            using (var client = new HttpClient())
            {
                HttpContent content = new FormUrlEncodedContent(
                    new Dictionary<string, string>
                    {
                        { "v", "1" }, // protocol version,
                        { "tid", _googleAnalyticsId }, // site identifier
                        { "cid", data.UserId }, // user identifier
                        { "uip", data.IpAddress }, // user IP address
                        { "dr", data.Referrer }, // user referrer
                        { "dp", data.Path }, // document path
                        { "t", "pageview" }, // type
                    });

                await client.PostAsync(_collectUrl, content).ConfigureAwait(false);
            }
        }
示例#2
0
        public async Task CollectVisitAsync(AnalyticsVisit data)
        {
            using (var client = new HttpClient())
            {
                HttpContent content = new FormUrlEncodedContent(
                    new Dictionary <string, string>
                {
                    { "v", "1" },                  // protocol version,
                    { "tid", _googleAnalyticsId }, // site identifier
                    { "cid", data.UserId },        // user identifier
                    { "uip", data.IpAddress },     // user IP address
                    { "dr", data.Referrer },       // user referrer
                    { "dp", data.Path },           // document path
                    { "t", "pageview" },           // type
                });

                await client.PostAsync(_collectUrl, content).ConfigureAwait(false);
            }
        }