Вопрос

Can 'Clicky Web Analytics' be utilized in a C# WinForms environment?

The only thing I can spot is a HTML code snippet for websites.

They also accept HTTP requests, but I believe they are just for polling data, not for pushing new events/stats to Clicky.

I realize it is probably called 'Clicky Web Analytics' for a reason (i.e. only website/web app based stat tracking), but I could really use a C# solution right about now.

Это было полезно?

Решение

Here is how to track custom events from C# to your clicky site:

    private static void TrackStatWithClicky(string eventValue)
    {
        // Prepare HTTP request
        WebRequest request = WebRequest.Create
       (
           "http://in.getclicky.com/in.php?" +
           "site_id=" + ClickySiteID +  //click site id , found in preferences
           "&sitekey_admin=" + ClickySiteAdminKey + //clicky site admin key, found in preferences
           "&ip_address=" + GetLocalIPAddressString() + //ip address of the user - used for mapping action trails
           "&type=custom" +
           "&href=" + eventValue.Replace(" ", "_") + //string that contains whatever event you want to track/log
           "&title=APPNAME Action" +
           "&type=click"
       );

        request.Method = "GET";

        // Get response
        WebResponse response = request.GetResponse();
        response.Close();
    }

    public static string GetLocalIPAddressString()
    {
        if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
        {
            return "";
        }

        IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());

        return host.AddressList.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork).ToString();
    }

Some of the information here was usefull in figuring it out: https://clicky.com/help/custom/manual#internal

Другие советы

They appear to have an API for Manual data logging. Specifically, they mention Logging internal events:

Logging data from an internal script

Clicky lets you log data from an internal script, such as PHP, ASP, Perl, etc. Other services don't offer this feature because they don't document their incoming "API", and they only verify incoming data from the referrer. Clicky is different.

It seems to be really made for your backend webserver scripts to also contribute user data, but I'm pretty sure you could make the web API calls from whatever language you'd like, including a WinForms script. Not really what it's made for, but hey, why not? Just issue a GET request with the URL-encoded parameters:

How to talk to our tracking servers

The page you want to talk to is at http://in.getclicky.com/in.php. This is the same script that our tracking code talks to. You just need to send the right parameters, and we'll log it.

So you'll need to port their example PHP Script to C# and you'll be good to go.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top