HawkSearch Event - V1 Click Tracking
Hawksearch has three environments available: Development dev.hawksearch.net), Test – test.hawksearch.net  and Production dashboard-na.hawksearch.com. When performing integration, each engine can be accessed by using these domains. For each of the three environments the value for 'url_value' would be different. Please confirm the URL values with the HawkSearch team during implementation.
One of the first steps to populate click tracking report, would be loading the JavaScript file provided by Hawksearch and to initialize the Hawk URLs on the listing page
Â
Â
<script type="text/javascript">
//<![CDATA[
(function (HawkSearch, undefined) {
HawkSearch.BaseUrl = url_value;
HawkSearch.TrackingUrl = url_value;
if ("https:" == document.location.protocol) {
HawkSearch.BaseUrl = HawkSearch.BaseUrl.replace("http://", "https://");
HawkSearch.TrackingUrl = HawkSearch.TrackingUrl.replace("http://", "https://");
}
}(window.HawkSearch = window.HawkSearch || {}));
var hawkJSScriptDoc = document.createElement("script");
hawkJSScriptDoc.async = true;
hawkJSScriptDoc.src = HawkSearch.TrackingUrl + '/includes/hawksearch.js?v1.01';
var hawkJSTag = document.getElementsByTagName('script')[0];
hawkJSTag.parentNode.insertBefore(hawkJSScriptDoc, hawkJSTag);
var hawkCSSScriptDoc = document.createElement("link");
hawkCSSScriptDoc.setAttribute("rel", "stylesheet");
hawkCSSScriptDoc.setAttribute("type", "text/css");
hawkCSSScriptDoc.setAttribute("href", HawkSearch.TrackingUrl + '/includes/hawksearch.css');
document.head.appendChild(hawkCSSScriptDoc);
//]]>
</script>
Â
Â
If the listing page is completely formatted by HawkSearch then the following on click event would be added to the anchor elements for each of the items.
Â
Â
If the site is not using HTML formatted by HawkSearch, then you will require to add the following on click event on each of the item links for products on the listing page.
<a onclick="return HawkSearch.link(event,'61816065-4fa5-4bf2-9604-f76e664f9334',1,’123456789',0);">
Item Name
</a>
Â
The parameters used in the above code snippet are
Parameter 1: passes the event to the function. For click tracking, this value is usually event.
Parameter 2: This is the TrackingId that is passed back in the search response from HawkSearch
<TrackingId>61816065-4fa5-4bf2-9604-f76e664f9334</TrackingId>
Parameter 3: this is the index of the item in the search results.
Parameter 4: this is the uniqueId  of the item.(this may not necessarily be the product Id)
Parameter 5: is always 0 (zero)
Â
Once the above mentioned tracking code has been added, you can test the click tracking event by
Searching for a term
Once items have been listed from the search open up the developer tools for the browser
This can be done either by right clicking on the page and selecting inspect or clicking F12
Chrome
Â
Â
Firefox
Â
Â
Once the developer tools has been opened up, click on the network tab to view the network requests/response
Â
Click on any of the products item links on which we have added the click tracking code mentioned previously in the document. On successful tracking the network tabs would show a request to link.aspx with a response status of 302 as shown below.
Â
If you are not able to see the link.aspx request under network tab make sure that the product listing doesn’t have multiple item links and if they do have multiple item links then the click tracking code is added to each of the links . For example it may happen that a page will have same item link url added on the page for the item image and the item name, then it is required that the click tracking code is added on both item image and item name.
If the network tab does display the link.aspx request and the item is not redirecting to the product page please make sure there are no error messages on the browser console
Â