Skip to content

Instantly share code, notes, and snippets.

@qhoxie
Created September 22, 2012 22:21
Show Gist options
  • Save qhoxie/3768026 to your computer and use it in GitHub Desktop.
Save qhoxie/3768026 to your computer and use it in GitHub Desktop.
window.Swiftype = window.Swiftype || {};
Swiftype.root_url = Swiftype.root_url || 'https://api.swiftype.com';
Swiftype.pingUrl = function (endpoint, callback) {
var img = new Image();
img.onload = img.onerror = callback;
img.src = endpoint;
setTimeout(callback, 350);
return false;
};
Swiftype.pingSearchResultClick = function (engineKey, docId, callback) {
var params = {
t: new Date().getTime(),
engine_key: engineKey,
doc_id: docId,
q: Swiftype.currentQuery
};
var url = Swiftype.root_url + '/api/v1/public/analytics/pc?' + $.param(params);
Swiftype.pingUrl(url, callback);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment