Skip to content

Instantly share code, notes, and snippets.

@chrisvariety
Created June 4, 2013 16:56
Show Gist options
  • Save chrisvariety/5707591 to your computer and use it in GitHub Desktop.
Save chrisvariety/5707591 to your computer and use it in GitHub Desktop.
We have some public endpoints that are undocumented as you noticed. There are two of them, the first records Autocomplete Selections (in the dropdown) and the second records clicks on full-text search results (from the results page). The difference is very subtle since we try to keep the URLs short (/pas vs. /pc).
Autocomplete Selections:
/api/v1/public/analytics/pas
Full-text Clicks:
/api/v1/public/analytics/pc
There are a couple of ways to use these. The one that is leveraged by the JS libraries is a little more difficult since it requires use of the Swiftype internal document ID. The other way uses the document type's slug and the document's external_id. Here are example calls for that:
Autocomplete Selections:
GET "/api/v1/public/analytics/pas?t=1367445764715&engine_key=your_key&document_type_id=doc_type_slug&doc_id=external_id&prefix=chicke"
Full-text Clicks:
GET "/api/v1/public/analytics/pc?t=1367445971698& engine_key=your_key& document_type_id=doc_type_slug& doc_id=external_id&q=Chicken"
The parameters are mostly self-explanatory, but the "t" parameter is just a cache-busting timestamp since we recommend pinging these via an image. Our pingUrl function may be a useful in your implementation: https://github.com/swiftype/swiftype-autocomplete-jquery/blob/master/jquery.swiftype.autocomplete.js#L27-L36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment