You can also use ClickAndChat.com to implement server-side visitor tracking using ASPX, ASP, PHP or any other code that executes at the server. The advantages of using server-side tracking as opposed to client-side tracking using javascript are as follows:
- Fastest possible visitor tracking and page loads. Pages will show in ClickAndChat.com even before the visitor has seen them!
- No requirement for javascript or images to be enabled on the visitor's browser.
- Ability to track spiders and other automated bots.
- Ability to serve custom content based on operator availability and visitor GEO-IP.
- No requirement for the ClickAndChat.com Gateway to be running on a public IP address.
- Ability to track SSL pages without the requirement to assign an SSL certificate to the ClickAndChat.com Gateway.
- No firewall or security issues for the visitor, since the page is tracked at the server.
If your web site is built using ASPX, ASP or PHP then server-side tracking is the recommended method of tracking visitors with ClickAndChat.com.
How It Works
Your server-side code makes a HTTP request to the ClickAndChat.com Gateway for the file 'stat.xml'. Since the request happens server-side there wont be any firewall issues. The request contains details of the visitor and page. The ClickAndChat.com Gateway returns some XML containing current operator status and optional visitor GEO-IP data. Your server-side code can then use this XML data to serve custom content (like a Click To Chat link).
Example HTTP Request:
The following HTTP request to the ClickAndChat.comGateway will return an XML file:
http://gateway.domain.com/stat.xml?domain=www.mysite.com&auth=
authentication&ip=123.123.123.123&p=page.htm&r=http://www.referrer.com
With all server-side calls to the Gateway you must pass the 'auth' parameter. This must be set to the Authentication string as set in your ClickAndChat.com settings. This is an added security measure. The 'ip' parameter must be set to the IP address of the visitor. The 'p' parameter must be set to the page name they are viewing. The 'r' parameter can be set to an optional referrer.
Query String Parameters
The following querystrings can be passed via the stat.xml request:
domain/d |
Domain name of the site in ClickAndChat.com |
dept/t |
Department name (optional) |
p |
Page name (if no page is specified the 'home page' as defined in site settings is assumed) |
auth |
ClickAndChat.com Server Authentication string as defined in ClickAndChat.com settings - Remote Access section |
ip |
IP address of visitor |
r |
Referrer (optional) |
u |
User name (optional - if specified this value is used to track the visitor in addition to the IP address) |
v |
Revenue of visit (optional) |
c |
Cost of visit (optional) |
s |
HTTP status (optiona0 - allows you to pass page errors (404's etc) to ClickAndChat.com to show as exceptions |
n |
Visitor contact information (Name|Company|Email|Telephone) (optional) |
The ClickAndChat.com Gateway will then send the visitor information to the ClickAndChat.com Server and return a XML file, in the format:
<?xml version="1.0" encoding="UTF-8" ?>
<domain>
<online>2</online>
<name>www.test.com</name>
<message>One moment - we will be with you shortly.</message>
<operators>
<operator>
<name>Mark</name>
<status>0</status>
<dept>Technical Support</dept>
</operator>
<operator>
<name>Simone</name>
<status>0</status>
<dept>Sales</dept>
</operator>
</operators>
</domain>
The <online> tag will contain the number of operators currently online. You can use this to serve your on/off line chat link/graphic. The <message> tag contains the default 'available' message as defined by the site properties in ClickAndChat.com.
The <operators> tag contains a repeating section for each <operator> showing their <name>, <status> and <department>
Requesting GEO-IP Data
If you request 'geoip.xml' instead of 'stat.xml' in the HTTP request to the Gateway, then the ClickAndChat.com Gateway will also include GEO-IP data for the IP address passed in the 'ip' parameter in the returned XML.
The following tags are returned in addition to the above:
<visitor>
<ip>64.233.167.99</ip>
<country>United States</country>
<region>CA</region>
<city>Mountain View</city>
<organization>Google</organization>
<lattitude>37.4192</lattitude>
<longitude>-122.0574</longitude>
</visitor>
You could then use this data in your server-side code to serve different content based on the visitor's location.
License Note: You are licensed to use the GEO-IP data in this way only for your own site. You cannot use the ClickAndChat.com Gateway to serve GEO-IP data for other users or sites.
Using The ASPX Class
We have a Visual Studio 2005 (Visual Basic) Class that encapsulates the HTTP call to the ClickAndChat.com Gateway and extracts the data returned. If you wish to use this, please contact us.
To use the class, add it to your Visual Studio (or Visual Web Developer) project. Then in the Page_Load event of each page you want to monitor, add the following code:
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
DIM TSL As New clsTracker
Try
TSL.GatewayIP = "gateway.test.com" ' set this to the IP address of the ClickAndChat.com Gateway
TSL.GatewayPort = 80
' set to the Gateway port (80 is the default)
TSL.Domain = "www.mysite.com"
' monitored site in ClickAndChat.com
TSL.AuthenticationString = "myauth"
' set to your ClickAndChat.com authentication string
TSL.VisitPage = Page
' assign the 'Page' object to the 'VisitPage' property
TSL.ReturnGEOIP = True
' set to True if you want GEO-IP data returned
TSL.ServeInvite = True
' set to True if you want the 'invite' javascript served to the page
' send page view info to ClickAndChat.com
If TSL.SendPageInfo = True Then
' page info has been sent to ClickAndChat.com
' the class returns operator status an GEO-IP data in the 'Response' property
If TSL.Response.OperatorsOnLine > 0 Then
' here we set our 'available' content
lblChat.Text = "Click To Chat'
Else
' set the 'not available' content
lblChat.Text = "Leave A Message"
End If
If TSL.Response.VisitorCountry.Length > 0 Then
lblGeoIP = "Welcome From <br /><b>" & TSL.Response.VisitorCountry
End If
End If
Catch
End Try
End Sub
That's it! The 'SendPageInfo' method of the Class creates the HTTP object and sends it to the ClickAndChat.com Gateway. Data is then returned in the Response properties. You simply set the 'VisitPage' property to the current instance of the Page object.
The number of available operators is then returned in the Response.OperatorsOnLine property. You can then use this to hide or show your 'Click To Chat' content on your page.
You can also call the SendPageInfo method in response to other events (if you want to track button clicks, form submissions etc). The class also adds the 'invite' javascript function to the page response, if you set the ServeInvite property to True.
Passing Visitor Contact Information
You can pass visitor contact information (name, company, email & telephone) via the class. This will then show against the visitor in ClickAndChat.com and be recorded in the database. This is useful when you capture form submissions. Simply set the class properties VisitorName, VisitorCompany, VisitorEmail,VisitorTelephone prior to calling the SendPageInfo method.
Passing Cost & Revenue
Set the class properties VisitCost and VisitRevenue to numeric values prior to calling the SendPageInfo method to pass cost and/or revenue to ClickAndChat.com to be recorded against the visit.
Using The Class On Master Pages
For ASPX based web sites created with Visual Studio 2005 or Visual Web Developer, the easiest way to add server side tracking is to use Master Pages. You then add the code to the Page_Load event of the master page.
Firing Custom Javascript When Invites Are Sent
The class has a property called 'OnInvite'. This can be set to the name of a client-side Javascript function that will called when an Invite is sent to the visitor. This can be used to replace the standard invite response of displaying a moving graphic. You can then implement your own custom invite response. For example:
server-side:
PSL.OnInvite = 'MyInvite'
client-side:
<script>
function MyInvite()
{
Alert("Hello. This is an invite from ClickAndChat.com!");
}
</script>