Google Analytics: How to send a 'PageView' through an asmx WebService?
<p>This is a function I took from this link: <a href="https://gist.github.com/0liver/11229128" rel="nofollow">https://gist.github.com/0liver/11229128</a></p>

<pre><code>namespace something
{
    /// &lt;summary&gt;
    /// Summary description for GA
    /// &lt;/summary&gt;
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [ScriptService]
    public class GA : System.Web.Services.WebService
    {
        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public object TrackEvent(string _tid, string _cid, string _t, string _cn, string _cs, string _cm, string _ua, string _uip, string _dl, string _ul, string _sr)
        {
            var request = (HttpWebRequest)WebRequest.Create("http://www.google-analytics.com/collect");

            request.Timeout = 600000;

            request.Method = "POST";

            // the request body we want to send
            var postData = new Dictionary&lt;string, string&gt;
                           {
                                { "v", "1" },
                                { "tid", _tid },
                                { "cid", _cid },
                                { "t", _t },
                                { "cn", _cn },
                                { "cs", _cs },
                                { "cm", _cm },
                                { "ua", _ua },
                                { "uip", _uip },
                                { "dl", _dl },
                                { "ul", _ul },
                                { "sr", _sr },
                           };

            var postDataString = postData
                .Aggregate("", (data, next) =&gt; string.Format("{0}&amp;{1}={2}", data, next.Key,
                                                             HttpUtility.UrlEncode(next.Value)))
                .TrimEnd('&amp;');

            // set the Content-Length header to the correct value
            request.ContentLength = Encoding.UTF8.GetByteCount(postDataString);

            // write the request body to the request
            using (var writer = new StreamWriter(request.GetRequestStream()))
            {
                writer.Write(postDataString);
            }

            try
            {
                var webResponse = (HttpWebResponse)request.GetResponse();
                if (webResponse.StatusCode != HttpStatusCode.OK)
                {
                    throw new HttpException((int)webResponse.StatusCode,
                                            "Google Analytics tracking did not return OK 200");
                }

                request.KeepAlive = false;
                webResponse.Close();

                return "something";
            }
            catch (Exception ex)
            {
                return "something";
            }
        }
    }
}
</code></pre>

<p>The issue I get when trying to execute it:</p>

<pre><code>System.Net.WebException: Unable to connect to the remote server ---&gt; System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 64.233.190.139:80
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket&amp; socket, IPAddress&amp; address, ConnectSocketState state, IAsyncResult asyncResult, Exception&amp; exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetRequestStream(TransportContext&amp; context)
   at System.Net.HttpWebRequest.GetRequestStream()
   at Something.Services.GA.TrackEvent(String _tid, String _cid, String _t, String _cn, String _cs, String _cm, String _ua, String _uip, String _dl, String _ul, String _sr) in [path]
</code></pre>

<p>Can anyone help me please? (Sorry for my english)</p>