Friday 17 April 2009

Using WhosOn in your Blogspot Blog.

I've decided to add tracking & chat to my blog here, partially as an excercise in how to do it and also for vanity purposes... although the small number of human visitors is always a disappointment!


In the WhosOn client, generate the tracking code. It will look like this:

<script type='text/javascript' src='http://{your-gateway}/include.js?domain={your-domain}'></script><script type='text/javascript' >if(typeof sWOTrackPage=='function')sWOTrackPage();</script>


Add an HTML/Javascript Gadget to the bottom of your blog Layout, and paste this code into it.


Then, you can add another Gadget to show the chat link - I put a new HTML/Javascript Gadget on the left hand side, and put in:

<a id='whoson_chat_link'></a>


The WhosOn code dynamically replaces this link with the correct image (online / offline).


If you only want to track, then you can generate the tracking only code through the client - you don't need to put the anchor in the left if you do this.

Wednesday 15 April 2009

WhosOn V5 - Scripts


WhosOn Version 5 (http://www.whoson.com/v5whatsnew.aspx) has some great new features for users who want more advanced chat distribution among their agents.

We've used a VBScript compatible engine, which allows the script to access the data about the visitor (IP, Geo-Location, #Visits etc) and any pre-chat survey information that has been filled in, and use this to route the chat to the correct operator, send some automatic text, or cancel / block the chatter.

This means dynamic rules can be used to find existing customers, and pass through to the right sales person based on a database query, or just get the lead to the correct person immediately, rather than having to do a manual transfer after the event.

I'm working with some of our customers to provide the custom logic for what they need - here is the first example I have worked on:



Sub Main()
    ' commands start here
    CancelChatRequest = False
    Dim ticket As String
    Dim tr As String
    Dim p As Integer

    tr = ThisChatSession.PreChatSurvey

    p = InStr(1, LCase(tr), "ticket")
    If p > 0 Then
        p = InStr(p, tr, "") + 7
        ticket = Left(Mid(tr, p), InStr(p, tr, "") - p)
        AddToLog("Ticket: "  & ticket)

        Dim conn As New ADODB.Connection
        Dim adors As New ADODB.Recordset

        conn.ConnectionString = "DSN=Tickets;"
        conn.Open

        Set adors.ActiveConnection = conn

        With adors
            .Open("SELECT * FROM Tickets WHERE TicketNo = '" & ticket & "'")
            If Not .EOF Then
                Dim op As String
                op = LCase(.Fields("Operator"))
                ' check if operator is online
                For p = 0 To OperatorsConnectedCount - 1
                    If op = LCase(Operator(p).Name) And Operator(p).CurrentStatus <>
                        ' if operator is online or busy, send this chat to them
                        SendChatRequestToOperators = op
                        SendMessageToVisitor = "You are being connected to the assigned user for this issue - " & op
                        AddToLog("Script: Operator for issue online: " & op)
                        p = OperatorsConnectedCount
                    End If
                Next p

                If Not Len(SendChatRequestToOperators) > 0 Then
                    SendMessageToVisitor = "The operator (" & op & ") assigned to this issue is not online - transfering to Support"
                    AddToLog("Script: Operator for issue not online: " & op)
                    SendChatRequestToDepartments = "Support"
                End If
            Else
                SendMessageToVisitor = "The ticket number was not found - transfering to Support"
                AddToLog("Script: The ticket number was not found")
                SendChatRequestToDepartments = "Support"
            End If
            .Close
        End With

        Set adors = Nothing
        conn.Close
        Set conn = Nothing
    Else
        SendChatRequestToDepartments = "Support"
    End If

End Sub