Result Index for Click Logging

Oct 5, 2012 at 5:43 PM
Edited Oct 5, 2012 at 5:47 PM

Hello, I was able to implement a result index in order to implement click logging as mentioned in this Google documentation: Improving Search Results

I added the following in XMLParser.startElement(), in the switch(tag) case XMLTages.R, around line 159:

String indexNumber = attributes["N"] == null ? "-1" : attributes["N"].ToString();
// added index variable and setIndexNumber and getIndexNumber methods to Result obj
currResult.setIndexNumber(string.IsNullOrEmpty(indexNumber) ? -1 : Convert.ToInt32(indexNumber));

This allows for building a client side call when the user clicks a result:

aTitleLink.Attributes["onmousedown"] = string.Format("cl_clk('{0}', page_query, 'c', null, '{1}', page_start, page_site, null);",
Server.UrlEncode(Server.HtmlDecode(res.getUrl())), res.getIndexNumber().ToString());

Nov 13, 2012 at 4:55 AM

Thanks.  We'll look at incorporating this in.