Here is a quick integration code of AFS click web service. These following two functions must be loaded into pages in which they have to be called. For that there are several solutions:
- Integrating this code into your files that are compressed and obfuscated
* @param clickPath must be the path at which the click web service can be reached.
* "/click" will be appended to this parameter Example: http://xxx.afs-antidot.net/
* @param serviceId AFS Service id
* @param status AFS Service status
* @param target Clicked URL
* @param label Label
* @param sessionId Optional, AFS Search session id
* @param userId Optional, AFS Search user id
function notifyClick(clickPath, serviceId, status, target, label, sessionId, userId)
var url = clickPath + 'click?afs%3Aservice=' + serviceId + '&afs%3Astatus=' +
status + '&afs%3Atarget=' + encodeURI(target) + '&afs%3Alabel=' +
encodeURI(label) + '&afs%3Aaction=log';
url += '&afs%3AsessionId=' + encodeURI(sessionId);
url += '&afs%3AuserId=' + encodeURI(userId);
* Executes an HTTP GET method to the given URL. It supports requesting any host name
* (uses a work around for the Same Origin Policy). This method is not able to return
* the response body.
* @param url The target URL
var iframe = document.createElement('iframe');
iframe.style.display = 'none';
There are two functions. The first one is the one to call, the second one is just for implementation purposes.
This function supports cross domain requesting, it requires to know the following values:
- AFS service ID and AFS service status
- Click web service host. For instance http://project-name.afs-antidot.net
- Click web service path. If click is at the web server's root, value is /
- Click target: URL of the search result that is going to be clicked
- Click label: Title of the search result
Two additional parameters are optional: AFS sessionId and userId. They enable AFS click to track search sessions (see Identification of search sessions and unique visitors). Their values are generated by AFS web services.