API Documentation Archives - SearchStax Docs Documentation Thu, 26 Oct 2023 16:53:30 +0000 en-US hourly 1 https://wordpress.org/?v=6.4.2 https://www.searchstax.com/docs/wp-content/uploads/2023/10/cropped-favicon-32x32.png API Documentation Archives - SearchStax Docs 32 32 Overview https://www.searchstax.com/docs/searchstudio/discovery-apis-overview/ Mon, 22 May 2023 22:36:57 +0000 https://www.searchstax.com/docs/?post_type=searchstudio&p=15518 Discovery API Overview The Discovery API tab includes details for the Popular Searches API and the Related Searches API. Questions? Do not hesitate to contact the SearchStax Support Desk.

The post Overview appeared first on SearchStax Docs.

]]>
Discovery API Overview

The Discovery API tab includes details for the Popular Searches API and the Related Searches API.

Questions?

Do not hesitate to contact the SearchStax Support Desk.

The post Overview appeared first on SearchStax Docs.

]]>
Popular Searches API https://www.searchstax.com/docs/searchstudio/searchstax-studio-popular-searches-api/ Thu, 01 Sep 2022 17:11:44 +0000 https://www.searchstax.com/docs/?post_type=searchstudio&p=12521 Popular Searches API SearchStax Studio’s Popular Searches API retrieves the most Popular Searches recorded by the Studio App during the previous 30 days. This page describes how to retrieve a… Continue reading Popular Searches API

The post Popular Searches API appeared first on SearchStax Docs.

]]>
Popular Searches API

SearchStax Studio’s Popular Searches API retrieves the most Popular Searches recorded by the Studio App during the previous 30 days.

This page describes how to retrieve a Json document of popular-search strings for display on your search page.

The API can be accessed through any tool that assembles HTTP requests and dispatch them to a server. Among these would be the Python coreapi package, the Postman tool, and cURL. For Windows, use PowerShell 7.

Symbols enclosed in carets (< and >) such as <username> are metavariables. Substitute your local values when you encounter them in the examples.

Popular Search

This method returns a list of Popular Searches from a Search App. The pool of searches covers the most recent 30 days of search history.

GET <popular-searches-URL>?language=<code>&page=<n>&num_results=<n>

where <popular-searches-URL> is an endpoint from the Discovery API Tab of the App Settings screen. Language is an optional two-letter language code. Page is an optional page within the paginated result set. Num_results is an optional limit on the number of searches desired (1 through 20).

This method uses Discovery API Key authorization. The Discovery API key is displayed on the Discovery API Tab. It must be passed in the header of the request.

When invoked from Linux (Bash shell):

curl 'https://app.searchstax.com/api/v1/nn/popular-search/?language=en&num_results=10' -H 'Authorization: f17e2131927b055383669327b1dc95338a7bdd7d' 

The response is a JSON document containing a list of popular searches.

{
  "responseHeader": {
    "zkConnected": true,
    "status": 0,
    "QTime": 1
  },
  "response": {
    "numFound": 4,
    "start": 0,
    "numFoundExact": true,
    "docs": [
      {
        "query": "drupal integration",
        "count": 12
      },
      {
        "query": "solr",
        "count": 3
      },
      {
        "query": "sitecore",
        "count": 2
      },
      {
        "query": "test",
        "count": 2
      }
    ]
  }
}

The fields of each popular search have the following meanings:

  • query: The text of a popular search.
  • count: How many time the Search App has encountered this search.

The other fields are Solr internal values.

Questions?

Do not hesitate to contact the SearchStax Support Desk.

The post Popular Searches API appeared first on SearchStax Docs.

]]>
Overview https://www.searchstax.com/docs/searchstudio/analytics-api-overview/ Mon, 22 May 2023 22:25:59 +0000 https://www.searchstax.com/docs/?post_type=searchstudio&p=15513 Analytics API Overview SearchStax Studio Analytic APIs let you add analytic events to your search page: Questions? Do not hesitate to contact the SearchStax Support Desk.

The post Overview appeared first on SearchStax Docs.

]]>
Analytics API Overview

SearchStax Studio Analytic APIs let you add analytic events to your search page:

Questions?

Do not hesitate to contact the SearchStax Support Desk.

The post Overview appeared first on SearchStax Docs.

]]>
Tracking API (REST) https://www.searchstax.com/docs/searchstudio/searchstax-studio-analytics-rest-api/ Thu, 08 Jul 2021 22:25:44 +0000 https://www.searchstax.com/docs/?post_type=site_search&p=9272 Search Analytics REST API This page describes how to add SearchStax Studio Analytics Events to your search page. The Tracking API (Javascript) page describes how you can use a helper Javascript library to… Continue reading Tracking API (REST)

The post Tracking API (REST) appeared first on SearchStax Docs.

]]>
Search Analytics REST API

This page describes how to add SearchStax Studio Analytics Events to your search page. The Tracking API (Javascript) page describes how you can use a helper Javascript library to push Analytics events. This document describes how the same events can be pushed using just a REST API.

  

Analytics URL, Key and the REST Endpoint

On the Settings page of your Search App, the Analytics API tab contains the base URL for the API and the Analytics Key. The analytics key identifies the Search App.

The Analytics REST endpoint is <Analytics URL>/api/v2/track/.

Example: https://analytics-us.searchstax.com/api/v2/track/

Different events can be pushed to this endpoint as described in the sections below.

Events

An “event” is a user action on your search page, such as searching for a keyword or clicking on a search result. SearchStax supports the following event messages:

Each type of event has its own set of required properties, which are detailed below. The following are the common properties across all events:

Parameter Description Example
key:
required
string  
This is the unique analytics app key as shown in the “Analytics API” tab of your App within Studio App Management ‘IeDTTDD1ubJdfPMmu7MMxxVjUMdw6vo52BjPixxqwcQ’
session:
required
string  
The ID of the web session or mobile application session. If omitted, some analytics features cannot be fully reported. ‘qqMKt4fxhcud0T5c3UJ5spgug’
_vid:
required
string 
Unique Identifier to identify a visitor ‘d7cc372a-2be6-ee1e-26e8-0f903fa36e67’

session can be obtained using the following helper function:

getSession : function(name){
	var name = 'searchcookie';
	var session = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
	return session[2];
}

The “search” and “related-search” events are intended to be used in the following fashion:

  1. Your search page sends a query to the search API. The search results are returned. A track event fires to track the impressions from the search results.
  2. If using the related searches features, your search page sends a request to the related searches API to get related searches for the query. The related searches are returned. A trackRelatedSearch event fires to track the related searches that were returned
  3. If the user clicks on a document, a trackClick event fires to track which document was clicked on.
  4. If the user clicks on a related search, a trackRelatedSearchClick event fires to track which related search was clicked on.
   

Track Searches and Impressions

To track searches, create a data object as below, which specifies the event type as _search.

var searchObj = {
  "event": "_search",
  "properties": {
    "key": "imDMrs56aTaDJc6jihDejUkDZYj3Gm8riJHlR0V1S58",
    "query": "sitecore",
    "shownHits": 3,
    "totalHits": 12,
    "pageNo": 1,
    "latency": 6,
    "session": "r6ivpxkd3e294kJ299V0tVb1q",
    "impressions": [
      {
        "cDocId": "https://www.searchstax.com/solutions/sitecore-solr/",
        "cDocTitle": "Managed Solr Service for Sitecore | SearchStax",
        "position": 1
      },
      {
        "cDocId": "https://www.searchstax.com/blog/site-search-for-sitecore-video/",
        "cDocTitle": "SearchStudio for Sitecore - Video | The Search Experience Blog",
        "position": 2
      },
      {
        "cDocId": "https://www.searchstax.com/solutions/sitecore-azure-to-solr-migration/",
        "cDocTitle": "Migrate Azure Search to Solr for Sitecore | SearchStax",
        "position": 3
      }
    ],
    "_vid": "d7cc372a-2be6-ee1e-26e8-0f903fa36e67",
    "language": "en"
  }
}

Parameter Description Example
event:
required
string
Type of user action on the search page. ‘_search’
key:
required
string
Unique Analytics API Key ‘IeDTTDD1ubJdfPMmu7MMxxVjUMdw6vo52BjPixxqwcQ’
user:
optional
string
A token identifying the webpage user. This datum is stored but is not currently used. ‘smith123’
session:
required
string
The ID of the web session or mobile application session. ‘qqMKt4fxhcud0T5c3UJ5spgug’
query:
required
string
The query string from your search page, or q from the response document. ‘sitecore plugin’
shownHits:
optional
number
The number of hits shown in the response document. 10
totalHits:
optional
number
The number of hits in the index, from the response document.

Note: To track searches that returned no results, set totalHits to 0.

1890
latency:
optional
number
The number of milliseconds to execute a search. You define the semantics. (One possibility is to use Qtime from the response document). Without this value, Analytics will not calculate average latency. 150
pageNo:
optional
number
The page number of the displayed results, from the response document. 1
impressions:
optional
array
An array of dictionaries, each describing a search result “impression.”
It lets the Analytics App track the documents that were displayed to the user as search results, whether the user clicked on them or not
[
{'cDocId': 'aDocId1', 'cDocTitle': 'aDocTitle1', 'position': 1},
{'cDocId': 'aDocId2', 'cDocTitle': 'aDocTitle2', 'position': 2}, ..
]

where cDocId is the unique ID of the document and cDocTitle is the title that is displayed for the search result.
The position numbers should start with 1
_vid:
required
string
Unique Identifier for the visitor. d7cc372a-2be6-ee1e-26e8-0f903fa36e67
language:
optional
string
A two-letter language code. Defaults to the default language. “en”, “fr”, or “es”

Calling the Analytics REST endpoint (/track API)

To call the REST API and insert the event, the event objects should be encoded to Base64 and passed as the data. For example, for the above request, you can use online base64 encoders such as https://www.base64encode.org/ to encode the object and then call the API endpoint as follows:

curl -vL "https://analytics-us.searchstax.com/api/v2/track/?data=ewogICJldmVudCI6ICJfc2VhcmNoIiwKICAicHJvcGVydGllcyI6IHsKICAgICJrZXkiOiAiaW1ETXJzNTZhVGFESmM2amloRGVqVWtEWllqM0dtOHJpSkhsUjBWMVM1OCIsCiAgICAicXVlcnkiOiAic2l0ZWNvcmUiLAogICAgInNob3duSGl0cyI6IDMsCiAgICAidG90YWxIaXRzIjogMTIsCiAgICAicGFnZU5vIjogMSwKICAgICJsYXRlbmN5IjogNiwKICAgICJzZXNzaW9uIjogInI2aXZweGtkM2UyOTRrSjI5OVYwdFZiMXEiLAogICAgImltcHJlc3Npb25zIjogWwogICAgICB7CiAgICAgICAgImNEb2NJZCI6ICJodHRwczovL3d3dy5zZWFyY2hzdGF4LmNvbS9zb2x1dGlvbnMvc2l0ZWNvcmUtc29sci8iLAogICAgICAgICJjRG9jVGl0bGUiOiAiTWFuYWdlZCBTb2xyIFNlcnZpY2UgZm9yIFNpdGVjb3JlIHwgU2VhcmNoU3RheCIsCiAgICAgICAgInBvc2l0aW9uIjogMQogICAgICB9LAogICAgICB7CiAgICAgICAgImNEb2NJZCI6ICJodHRwczovL3d3dy5zZWFyY2hzdGF4LmNvbS9ibG9nL3NpdGUtc2VhcmNoLWZvci1zaXRlY29yZS12aWRlby8iLAogICAgICAgICJjRG9jVGl0bGUiOiAiU2l0ZSBTZWFyY2ggZm9yIFNpdGVjb3JlIC0gVmlkZW8gfCBUaGUgU2VhcmNoIEV4cGVyaWVuY2UgQmxvZyIsCiAgICAgICAgInBvc2l0aW9uIjogMgogICAgICB9LAogICAgICB7CiAgICAgICAgImNEb2NJZCI6ICJodHRwczovL3d3dy5zZWFyY2hzdGF4LmNvbS9zaXRlY29yZS1henVyZS10by1zb2xyLW1pZ3JhdGlvbi8iLAogICAgICAgICJjRG9jVGl0bGUiOiAiTWlncmF0ZSBBenVyZSBTZWFyY2ggdG8gU29sciBmb3IgU2l0ZWNvcmUgfCBTZWFyY2hTdGF4IiwKICAgICAgICAicG9zaXRpb24iOiAzCiAgICAgIH0KICAgIF0sCiAgICAiX3ZpZCI6ICJkN2NjMzcyYS0yYmU2LWVlMWUtMjZlOC0wZjkwM2ZhMzZlNjciCiAgfQp9"

The above method returns an HTTP status code of 201/204 if the event was successfully added.

DATA = base64encode(searchObj)
curl -v "https://analytics-us.searchstax.com/api/v2/track/?data=$DATA"

To track related searches, create a data object as below, which specifies the event type as _relatedsearch.

var relatedSearchObj = {
  "event":"_relatedsearch",
  "properties":{
    "session":"JKaqFFK088vyrTkIBwBeWDyhQ",
    "key":"IeDTTDD1ubJdfPMmu7MMxxVjUMdw6vo52BjPixxqwcQ",
    "query":"solr",
    "shownHits":2,
    "pageNo": 1,
    "impressions":[
      {"relatedSearch":"managed solr",
      "position":1},
      {"relatedSearch":"solr 7",
      "position":2}
    ],
    "_vid":"d7cc372a-2be6-ee1e-26e8-0f903fa36e67",
    "language": "en"
}}

Parameter Description Example
event:
required
string
Type of user action on the search page. ‘_relatedsearch’
key:
required
string
Unique Analytics API Key ‘4Qp1Sv9MnALbAGbixW9ZaWrHxpbfwm6i’
user:
optional
string
A token identifying the webpage user. This datum is stored but is not currently used. ‘smith123’
session:
required
string
The ID of the web session or mobile application session. ‘XDJFNS355FGDFVVDFG’
query:
required
string
The query string from your search page, or q from the response document. ‘sitecore plugin’
shownHits:
optional
number
The number of hits shown in the response document. 10
latency:
optional
number
The number of milliseconds to execute a search. You define the semantics. (One possibility is to use Qtime from the response document). Without this value, Analytics will not calculate average latency. 150
impressions:
optional
array
An array of dictionaries, each describing a related search “impression.”
It lets the Analytics App track the related searches that were displayed to the user as search results, whether the user clicked on them or not
[
{'relatedSearch': 'an example related search', 'position': 1},
{'relatedSearch': 'another example related search', 'position': 2}, ..
]
where relatedSearch is the related search query. The position numbers should start with 1
_vid:
required
string
Unique Identifier for the visitor. d7cc372a-2be6-ee1e-26e8-0f903fa36e67
language:
optional
string
A two-letter language code. Defaults to the default language. “en”, “fr”, or “es”

Calling the Analytics REST endpoint (/track API)

To call the REST API and insert the event, the event objects should be encoded to Base64 and passed as the data. For example, for the above request, you can use online base64 encoders such as https://www.base64encode.org/ to encode the object and then call the API endpoint as follows:

curl -vL "https://analytics-us.searchstax.com/api/v2/track/?data=ewogICJldmVudCI6Il9yZWxhdGVkc2VhcmNoIiwKICAicHJvcGVydGllcyI6ewogICAgInNlc3Npb24iOiJKS2FxRkZLMDg4dnlyVGtJQndCZVdEeWhRIiwKICAgICJrZXkiOiJJZURUVEREMXViSmRmUE1tdTdNTXh4VmpVTWR3NnZvNTJCalBpeHhxd2NRIiwKICAgICJxdWVyeSI6InNvbHIiLAogICAgInNob3duSGl0cyI6MiwKICAgICJwYWdlTm8iOiAxLAogICAgImltcHJlc3Npb25zIjpbCiAgICAgIHsicmVsYXRlZFNlYXJjaCI6Im1hbmFnZWQgc29sciIsCiAgICAgICJwb3NpdGlvbiI6MX0sCiAgICAgIHsicmVsYXRlZFNlYXJjaCI6InNvbHIgNyIsCiAgICAgICJwb3NpdGlvbiI6Mn0KICAgIF0sCiAgICAiX3ZpZCI6ImQ3Y2MzNzJhLTJiZTYtZWUxZS0yNmU4LTBmOTAzZmEzNmU2NyIsCn19"

The above method returns an HTTP status code of 201/204 if the event was successfully added.

DATA = base64encode(searchObj)
curl -v "https://analytics-us.searchstax.com/api/v2/track/?data=$DATA"

Track Search Clicks

To start generating data around click-through events, search quality and relevance, have /track send _searchclick event to the Analytics App.

var searchClickObj = {
  "event": "_searchclick",
  "properties": {
    "key": "imDMrs56aTaDJc6jihDejUkDZYj3Gm8riJHlR0V1S58",
    "query": "sitecore",
    "shownHits": 12,
    "totalHits": 143,
    "pageNo": 1,
    "latency": 6,
    "session": "jtVM0lqSBMEfmBDYBHaUjodIL",
    "cDocId": "https://www.searchstax.com/blog/site-search-for-sitecore-video/",
    "cDocTitle": "SearchStudio for Sitecore - Video | The Search Experience Blog",
    "position": 2,
    "_vid": "d7cc372a-2be6-ee1e-26e8-0f903fa36e67",
    "language": "en"
  }
}

Parameter Description Example
event:
required
string
Type of user action on search page. ‘_searchclick’
key:
required
string
Unique Analytics API Key ‘IeDTTDD1ubJdfPMmu7MMxxVjUMdw6vo52BjPixxqwcQ’
user:
optional
string
A token identifying the webpage user. This datum is stored but is not currently used. ‘smith123’
session:
required
string
The ID of the web session or mobile application session. ‘qqMKt4fxhcud0T5c3UJ5spgug’
query:
required
string
The query string from your search page, or q from the response document. ‘sitecore’
cDocId:
required
string
The document ID from the response document. ‘https://www.searchstax.com/blog/site-search-for-sitecore-video/’
cDocTitle
required
string
The document title from the response document. Note: In some applications, the document title may change. Analytics can be calculated as long as cDocID remains constant. ‘SearchStax Studio for Sitecore – Video | The Search Experience Blog’
position:
required
number
Absolute position of the document in the full list of results. If we’re showing ten items per page, the first result on the 5th page is position in position 41. First item on the first page has position as 1 2
pageNo:
optional
number
The page number of the displayed results, from the response document. 1
pageUrl:
optional
string
The URL of the page that is sending the tracking request ‘https://searchstudio.searchstax.com/search’
shownHits:
optional
number
The number of hits shown in the response document. 10
totalHits:
optional
number
The number of hits in the index, from the response document. 1890
_vid:
required
string
Unique Identifier for the visitor. d7cc372a-2be6-ee1e-26e8-0f903fa36e67
language:
optional
string
A two-letter language code. Defaults to the default language. “en”, “fr”, or “es”

To call the REST API and insert the event, the event object should be encoded to Base64 and passed as the data, just like for the _search event

DATA = base64encode(searchClickObj)
curl -v "https://analytics-us.searchstax.com/api/v2/track/?data=$DATA"

The above method returns an HTTP status code of 201/204 if the event was successfully added.

To start generating data around click-through events, search quality and relevance, have /track send _relatedsearchclick event to the Analytics App.

{"event":"_relatedsearchclick","properties":{"session":"JKaqFFK088vyrTkIBwBeWDyhQ","key":"tACKiVHqhd22wS3AEE3EYmKwbriokhs04Yja6uoAaXk","query":"solr","relatedSearch":"managed solr","pageNo":1,"shownHits":1,"totalHits":1,"_vid":"0b7fef5a-2deb-2e4e-15d3-5c8e4a19d58c","tt":1645231821464,"pageUrl":"https%3A%2F%2Fsearchstudio.searchstax.co%2Fapps%2Fyivdt5dND9n3WqjZOD5ZKIgbvzdz5lBH7gsVPRg6sAY%2Fsearch.html%3FsearchStudioQuery%3Dsolr%26style%3Dfalse%26facets%3D%26sort%3D%26start%3D0"}}
var searchClickObj = {
  "event": "_relatedsearchclick",
  "properties": {
    "key": "imDMrs56aTaDJc6jihDejUkDZYj3Gm8riJHlR0V1S58",
    "query": "sitecore",
    "shownHits": 12,
    "totalHits": 143,
    "pageNo": 1,
    "latency": 6,
    "session": "jtVM0lqSBMEfmBDYBHaUjodIL",
    "relatedSearch": "Sitecore 7",
    "position": 2,
    "_vid": "d7cc372a-2be6-ee1e-26e8-0f903fa36e67",
    "language": "en"
  }
}

Parameter Description Example
event:
required
string
Type of user action on search page. ‘_relatedsearchclick’
key:
required
string
Unique Analytics API Key ‘4Qp1Sv9MnALbAGbixW9ZaWrHxpbfwm6i’
user:
optional
string
A token identifying the webpage user. This datum is stored but is not currently used. ‘smith123’
session:
required
string
The ID of the web session or mobile application session. ‘XDJFNS355FGDFVVDFG’
query:
required
string
The query string from your search page, or q from the response document. ‘sitecore plugin’
position:
required
number
Absolute position of the related search in the full list of results. If we’re showing ten related searches per page, the first related search on the 5th page is position in position 41. First related search on the first page has position as 1 41
relatedSearch:
required
string
The related search term that was clicked on. ‘sitecore 7’
pageNo:
optional
number
The page number of the displayed results, from the response document. 1
pageUrl:
optional
string
The URL of the page that is sending the tracking request ‘https://searchstudio.searchstax.com/search’
shownHits:
optional
number
The number of hits shown in the response document. 10
totalHits:
optional
number
The number of hits in the index, from the response document. 1890
_vid:
required
string
Unique Identifier for the visitor. d7cc372a-2be6-ee1e-26e8-0f903fa36e67
language:
optional
string
A two-letter language code. Defaults to the default language. “en”, “fr”, or “es”

To call the REST API and insert the event, the event object should be encoded to Base64 and passed as the data, just like for the _relatedsearch event

DATA = base64encode(searchClickObj)
curl -v "https://analytics-us.searchstax.com/api/v2/track/?data=$DATA"

The above method returns an HTTP status code of 201/204 if the event was successfully added.

  

Track Search Satisfaction

SearchStax provides the ability to collect qualitative feedback about the search experience using the event _searchSatisfaction as shown below:

var searchSatisfactionObj = {
  "event": "_searchSatisfaction",
  "properties": {
    "key": "imDMrs56aTaDJc6jihDejUkDZYj3Gm8riJHlR0V1S58",
    "email": "user1@searchstax.com",
    "score": 10,
    "comments": "Very good search experience",
    "_vid": "d7cc372a-2be6-ee1e-26e8-0f903fa36e67"
  }
}
Parameter Description Example
key:
required
string
Unique Analytics API Key. ‘imDMrs56aTaDJc6jihDejUkDZYj3Gm8riJHlR0V1S58’
session:
required
string
The ID of the web session or mobile application session. ‘qqMKt4fxhcud0T5c3UJ5spgug’
email:
optional
string
Email ID of the user submitting the feedback ‘user123@searchstax.com’
comments:
optional
string
Feedback about the search experience as a comment ‘Very good search experience’
score:
required
string
0-10 score, rating the search experience 10
_vid:
required
string
Unique Identifier for the visitor “d7cc372a-2be6-ee1e-26e8-0f903fa36e67”

To call the REST API and insert the event, the event object should be encoded to Base64 and passed as the data, just like for the _search event

DATA = base64encode(searchSatisfactionObj)
curl -v "https://analytics-us.searchstax.com/api/v2/track/?data=$DATA"

The above method returns an HTTP status code of 201/204 if the event was successfully added.

Questions?

Do not hesitate to contact the SearchStax Support Desk.

The post Tracking API (REST) appeared first on SearchStax Docs.

]]>
Tracking API (Javascript) https://www.searchstax.com/docs/searchstudio/searchstax-studio-javascript-tracking-api/ Mon, 29 Mar 2021 16:25:00 +0000 https://site-qa.searchstax.com/knowledgecenter/?post_type=site_search&p=7901 Analytics Javascript Tracking API This page describes how to add SearchStax Analytics Events to the Javascript of your search page. This is a required step for tracking user events. The… Continue reading Tracking API (Javascript)

The post Tracking API (Javascript) appeared first on SearchStax Docs.

]]>
Analytics Javascript Tracking API

This page describes how to add SearchStax Analytics Events to the Javascript of your search page. This is a required step for tracking user events. The events, in turn, make it possible to test the effect of proposed changes to your site.

Contents of this page:

Javascript Library

Your search page would track searches, clicks, and user feedback and send the information to your Search App.

Paste the following script in the head section of your Search Page:

 <script type="text/javascript">
    var _msq = _msq || []; //declare object
    var analyticsBaseUrl = 'https://app.searchstax.com';
    var 
    (function () {
      var ms = document.createElement("script");
      ms.type = "text/javascript";
      ms.src = "https://static.searchstax.com/studio-js/v3/js/studio-analytics.js";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(ms, s);
    })();
 </script>

Change the 'analyticsBaseUrl' based on the Analytics URL shown in the “Analytics API” section of your App within Studio App Settings.

  

Events

An “event” is a user action on your search page, such as searching for a keyword or clicking on a search result. SearchStax supports the following event messages:

An event message is a wrapper for a list of property-value pairs. The values are the data that SearchStax tracks and analyzes.

Each type of event has its own set of required properties, which are detailed below. The following are the common properties across all events:

Parameter Description Example
key:
required
string  
This is the unique analytics app key as shown in the “Analytics API” tab of your App within Studio App Management ‘4Qp1Sv9MnALbAGbixW9ZaWrHxpbfwm6’
session:
required
string  
The ID of the web session or mobile application session. If omitted, some analytics features cannot be fully reported. ‘XDJFNS355FGDFVVDFG’

  

The “search” and “related-search” events are intended to be used in the following fashion:

  1. Your search page sends a query to the search API. The search results are returned. A track event fires to track the impressions from the search results.
  2. If using the related searches features, your search page sends a request to the related searches API to get related searches for the query. The related searches are returned. A trackRelatedSearch event fires to track the related searches that were returned
  3. If the user clicks on a document, a trackClick event fires to track which document was clicked on.
  4. If the user clicks on a related search, a trackRelatedSearchClick event fires to track which related search was clicked on.

  

Track Searches and Impressions

To track searches, use _msq.push() and dispatch a track event as part of parsing the response document.

_msq.push(['track', { 
   key: "4Qp1Sv9MnALbAGbixW9ZaWrHxpbfwm6i", 
   user: "smith123", 
   session: "XDJFNS355FGDFVVDFG", 
   query: "sitecore plugin", 
   shownHits: 10, 
   totalHits: 1890, 
   latency: 150, 
   pageNo: 1, 
   impressions: impressions,
   language: "en"
}]);

Parameter Description Example
key:
required
string
Unique Analytics API Key ‘4Qp1Sv9MnALbAGbixW9ZaWrHxpbfwm6i’
user:
optional
string
A token identifying the webpage user. This datum is stored but is not currently used. ‘smith123’
session:
required
string
The ID of the web session or mobile application session. ‘XDJFNS355FGDFVVDFG’
query:
required
string
The query string from your search page, or q from the response document. ‘sitecore plugin’
shownHits:
optional
number
The number of hits shown in the response document. 10
totalHits:
optional
number
The number of hits in the index, from the response document.

Note: To track searches that returned no results, set totalHits to 0.

1890
latency:
optional
number
The number of milliseconds to execute a search. You define the semantics. (One possibility is to use Qtime from the response document). Without this value, Analytics will not calculate average latency. 150
pageNo:
optional
number
The page number of the displayed results, from the response document. 1
impressions:
optional
array
An array of dictionaries, each describing a search result “impression.” This is required if you would like to track impressions. See the example below.
language:
optional
string
A two-letter language code. Defaults to the default language. “en”, “fr”, or “es”

The optional array of impression dictionaries lets the Analytics App track the documents that were displayed to the user as search results, whether the user clicked on them or not. Use a javascript array to catalog the search results in the following format:

var impressions = [
   {'cDocId': 'aDocId1', 'cDocTitle': 'aDocTitle1', 'position': 1},
   {'cDocId': 'aDocId2', 'cDocTitle': 'aDocTitle2', 'position': 2},
];

where aDocId1 is the ID of the document in position 1 and aDocTitle1 is the title of the document in position 1. The position parameter is the absolute position of the document in the full result list. (If we’re showing ten items per page, the first result on the fifth page is in position 41.)

For example, your application might respond to a query by (1) passing the query to Solr, (2) parsing the result document, and (3) generating a search-page update containing a script like this one at the end of the <body> section:

<script>
    var track = {
    "key": "imDMrs56aTaDJc6jihDejUkDZYj3Gm8riJHlR0",
    "query": "sitecore",
    "shownHits": 3,
    "totalHits": 12,
    "pageNo": 1,
    "latency": 1,
    "session": "Ll5UDHUQHccphnlb7lp6sQIo5",
    "language": "en",
    "impressions": [
      {"cDocId": "https://www.searchstax.com/videos/solr-cloud-best-practices-sitecore/",
        "cDocTitle": "Sitecore Solr Best Practices - SolrCloud SUGLA Meetup | SearchStax",
        "position": 1
      },
      {
        "cDocId": "https://www.searchstax.com/solutions/sitecore-solr/",
        "cDocTitle": "Sitecore Solr Search: Get fast and relevant search results | SearchStax",
        "position": 2
      },
      {
        "cDocId": "https://www.searchstax.com/case-studies/sitecore-solr-search-azure-isango/",
        "cDocTitle": "Case Study Isango!",
        "position": 3
      }
    ],
  }}
    if(track.query != '') {
        _msq.push(['track', track]);
}
</script>


In this way, your application can push a description of the search to your Analytics App by automatically calling the _msq.push() function as soon as the updated search page is viewed by the user.

  

  

  

To track related searches, use _msq.push() and dispatch a trackRelatedSearch event as part of parsing the response document.

_msq.push(['trackRelatedSearch', { 
   key: "4Qp1Sv9MnALbAGbixW9ZaWrHxpbfwm6i", 
   user: "smith123", 
   session: "XDJFNS355FGDFVVDFG", 
   query: "sitecore plugin", 
   shownHits: 10, 
   latency: 150, 
   impressions: impressions,
   language: "en"
   
}]);

Parameter Description Example
key:
required
string
Unique Analytics API Key ‘4Qp1Sv9MnALbAGbixW9ZaWrHxpbfwm6i’
user:
optional
string
A token identifying the webpage user. This datum is stored but is not currently used. ‘smith123’
session:
required
string
The ID of the web session or mobile application session. ‘XDJFNS355FGDFVVDFG’
query:
required
string
The query string from your search page, or q from the response document. ‘sitecore plugin’
shownHits:
optional
number
The number of hits shown in the response document. 10
latency:
optional
number
The number of milliseconds to execute a search. You define the semantics. (One possibility is to use Qtime from the response document). Without this value, Analytics will not calculate average latency. 150
impressions:
optional
array
An array of dictionaries, each describing a search result “impression.” This is required if you would like to track impressions. See the example below.
language:
optional
string
A two-letter language code. Defaults to the default language. “en”, “fr”, or “es”

The optional array of impression dictionaries lets the Analytics App track the related searches that were displayed to the user as related search results, whether the user clicked on them or not. Use a javascript array to catalog the related search results in the following format

var impressions = [
   {'relatedSearch': 'relatedTerm1', 'position': 1},
   {'relatedSearch': 'relatedTerm2', 'position': 2},
];

where relatedTerm1 is the returned related search term in position 1.

  

  

Track Clicks

To start generating data around click-through events, search quality and relevance, have _msq.push() send trackClick events to the Analytics App.

In your search-results page, add an on-click event in the link to each search result.

_msq.push(['trackClick', { 
   session: 'Ll5UDHUQHccphnlb7lp6sQIo5', 
   key: 'imDMrs56aTaDJc6jihDejUkDZYj3Gm8riJHlR0', 
   query: 'sitecore', 
   position: 2, 
   cDocId: 'https://www.searchstax.com/solutions/sitecore-solr/', 
   cDocTitle: 'Sitecore Solr Search: Get fast and relevant search results | SearchStax', 
   pageNo: 1, 
   shownHits: 3, 
   totalHits: 12,
   language: "en"
}]);

Parameter Description Example
key:
required
string
Unique Analytics API Key ‘4Qp1Sv9MnALbAGbixW9ZaWrHxpbfwm6i’
user:
optional
string
A token identifying the webpage user. This datum is stored but is not currently used. ‘smith123’
session:
required
string
The ID of the web session or mobile application session. ‘XDJFNS355FGDFVVDFG’
query:
required
string
The query string from your search page, or q from the response document. ‘sitecore plugin’
cDocId:
required
string
The document ID from the response document. https://www.searchstax.com/solutions/sitecore-solr/
cDocTitle
required
string
The document title from the response document. Note: In some applications, the document title may change. Analytics can be calculated as long as cDocID remains constant. ‘Sitecore Solr Search: Get fast and relevant search results | SearchStax’
position:
required
number
Absolute position of the document in the full list of results. If we’re showing ten items per page, the first result on the 5th page is position in position 41. First item on the first page has position as 1 41
pageNo:
optional
number
The page number of the displayed results, from the response document. 1
pageUrl:
optional
string
The URL of the page that is sending the tracking request ‘https://searchstudio.searchstax.com/search’
shownHits:
optional
number
The number of hits shown in the response document. 10
totalHits:
optional
number
The number of hits in the index, from the response document. 1890
language:
optional
string
A two-letter language code. Defaults to the default language. “en”, “fr”, or “es”

 

  

To start generating data around click-through events, search quality and relevance, have _msq.push() send trackRelatedSearchClick events to the Analytics App.

In your search-results page, add an on-click event in the link to each search result.

_msq.push(['trackRelatedSearchClick', { 
   session: 'Ll5UDHUQHccphnlb7lp6sQIo5', 
   key: 'imDMrs56aTaDJc6jihDejUkDZYj3Gm8riJHlR0', 
   query: 'sitecore', 
   position: 2, 
   relatedSearch: 'sitecore 7', 
   pageNo: 1, 
   shownHits: 3, 
   totalHits: 12,
   language: "en"
}]);

Parameter Description Example
key:
required
string
Unique Analytics API Key ‘4Qp1Sv9MnALbAGbixW9ZaWrHxpbfwm6i’
user:
optional
string
A token identifying the webpage user. This datum is stored but is not currently used. ‘smith123’
session:
required
string
The ID of the web session or mobile application session. ‘XDJFNS355FGDFVVDFG’
query:
required
string
The query string from your search page, or q from the response document. ‘sitecore plugin’
position:
required
number
Absolute position of the related search in the full list of results. If we’re showing ten related searches per page, the first related search on the 5th page is position in position 41. First related search on the first page has position as 1 41
relatedSearch:
required
string
The related search term that was clicked on. ‘sitecore 7’
pageNo:
optional
number
The page number of the displayed results, from the response document. 1
pageUrl:
optional
string
The URL of the page that is sending the tracking request ‘https://searchstudio.searchstax.com/search’
shownHits:
optional
number
The number of hits shown in the response document. 10
totalHits:
optional
number
The number of hits in the index, from the response document. 1890
language:
optional
string
A two-letter language code. Defaults to the default language. “en”, “fr”, or “es”

  

 

  

Track Search Satisfaction

SearchStax provides the ability to collect qualitative feedback about the search experience using trackSearchSatisfaction.

_msq.push(['trackSearchSatisfaction', {
    key: '4Qp1Sv9MnALbAGbixW9ZaWrHxpbfwm6i',
    email: 'user1@searchstax.com',
    score: 10,
    comments: 'Very good search experience',
    session: 'XDJFNS355FGDFVVDFG',
    language: 'en'
}]);

Parameter Description Example
key:
required
string
Unique Analytics API Key. ‘4Qp1Sv9MnALbAGbixW9ZaWrHxpbfwm6i’
session:
required
string
The ID of the web session or mobile application session. ‘XDJFNS355FGDFVVDFG’
email:
optional
string
Email ID of the user submitting the feedback ‘user123@searchstax.com’
comments:
optional
string
Feedback about the search experience as a comment ‘Very good search experience’
score:
required
string
0-10 score, rating the search experience 10

The searchFeedback events are used to compute the NPS score (Net {Promoter Score) for your Search Application.

  

  

Debugging Analytics APIs

You can use any browser debugging tools to debug the calls being made to the Analytics server. In Chrome, you can right click on the page, click on “Inspect” and look at the Network tab for calls made to the ‘analyticsBaseUrl’. Have ‘Preserve log’ checked so you can track clicks as they open in new pages.

The Analytics APIs will look like:

https://app.searchstax.com/api/v2/track/?data=eyJldmVudCI6Il9zZWFyY2hjbGljayIsInByb3BlcnRpZXMiOnsia2V5IjoiaW1ETXJzNTZhVGFESmM2amloRGVqVWtEWllqM0dtOHJpSkhsUjBWMVM1OCIsInF1ZXJ5Ijoic2l0ZWNvcmUiLCJzaG93bkhpdHMiOjksInRvdGFsSGl0cyI6MTMxLCJwYWdlTm8iOjEsImxhdGVuY3kiOjExLCJzZXNzaW9uIjoiNnNmN09GSWJRSlp1cU92ZU1VdUkyOW5SMSIsImNEb2NJZCI6Imh0dHBzOi8vd3d3LnNlYXJjaHN0YXguY29tL3NvbHV0aW9ucy9zaXRlY29yZS1zb2xyLyIsImNEb2NUaXRsZSI6IlNpdGVjb3JlIFNvbHIgU2VhcmNoOiBHZXQgZmFzdCBhbmQgcmVsZXZhbnQgc2VhcmNoIHJlc3VsdHMgfCBTZWFyY2hTdGF4IiwicG9zaXRpb24iOjEsIl92aWQiOiIxYzkwZWQ3MS1lZjljLTVlNjAtNGJlNS1jODI4OWYwMWJkYzkiLCJ0dCI6MTYxNzA2NjQwODAxMiwicGFnZVVybCI6Imh0dHBzJTNBJTJGJTJGd3d3LnNlYXJjaHN0YXguY29tJTJGc2VhcmNoJTNGc2VhcmNoU3R1ZGlvUXVlcnklM0RzaXRlY29yZSUyNnN0eWxlJTNEdHJ1ZSUyNmZhY2V0cyUzRCUyNnNvcnQlM0QlMjZzdGFydCUzRDAlMjZmYWNldENvbnRlbnQlMjUyMFR5cGUlM0QxJTI2ZmFjZXRBdXRob3IlM0QxJTI2ZmFjZXRLZXl3b3JkcyUzRDEifX0=

The argument to “data” is Base64 encoded properties. You can use online base64 decoders like https://www.base64decode.org/ to decode them to view the JSON data being passed

Questions?

Do not hesitate to contact the SearchStax Support Desk.

The post Tracking API (Javascript) appeared first on SearchStax Docs.

]]>
Reporting API (REST) https://www.searchstax.com/docs/searchstudio/searchstax-studio-reporting-api-rest/ Fri, 05 Aug 2022 20:27:45 +0000 https://www.searchstax.com/docs/?post_type=searchstudio&p=12300 Analytics Reporting REST API This page describes how a SearchStax Studio Enterprise Plan client can use the SearchStax® Analytics Tracking REST API to retrieve search events and items from the Search App.… Continue reading Reporting API (REST)

The post Reporting API (REST) appeared first on SearchStax Docs.

]]>
Analytics Reporting REST API

This page describes how a SearchStax Studio Enterprise Plan client can use the SearchStax® Analytics Tracking REST API to retrieve search events and items from the Search App.

The Tracking REST API can also perform Power Searches of searches and items.  

  

Reporting URL and Key

On the Settings page of your Search App, the Analytics API tab contains the Analytics Reporting API Endpoint and the Analytics Reporting API Key. The key is used to identify the Search App.

The Analytics Reporting API Endpoint is https://analytics-us.searchstax.com.

Reports

The Analytics Reporting REST API supports the following reporting actions:

Each type of report has its own set of required properties, which are detailed below.

Report Searches

To create a report of Most-Popular Searches, No-Result Searches, and No-Click Searches, use a cURL command in this general format:

curl '<Reporting API Endpoint>/api/rest/analytics/v1/reporting/searches/searches' -H 'authorization: Token <Key>'

A fully-expanded example resembles this:

curl 'https://analytics-us.searchstax.com/api/rest/analytics/v1/reporting/searches/searches?&startDate=2022-02-06T07:00:00&endDate=2022-02-28T06:59:59&offset=0&limit=10&language=en' -H 'authorization: Token 4Qp1Sv9MnALbAGbixW9ZaW95338fwm6i'

Parameter Description Example
key:
required
string
Unique Analytics Reporting API Key 4Qp1Sv9MnALbAGbixW9ZaW95338fwm6i
startdate:
optional
datetime
The date and time (UTC) of the earliest events in the report. Defaults to the last 31 days. 2022-02-06T07:00:00
enddate:
optional
string
The date and time (UTC) of the latest events in the report. Default to the last 31 days. Max end date is 31 days after the start date. 2022-02-28T06:59:59
offset:
optional
number
This index begins at 0. It is used for how far down in the results for most popular searches, no result searches, and searches with no clicks tables to start collecting in the report. Defaults to 0. 0
limit:
optional
number
This number begins at 0. It is used for how far down in the results for most popular searches, no result searches, and searches with no clicks tables to end the collection of data in the report.Defaults to the end of the results. 10
language:
optional
string
A two-letter language code. Defaults to the default language. en

The returned value is a JSON document describing searches. The parameters map into the values shown in the Studio Searches screen. A partial sample is shown below.

{
  "aggMetrics": [
    {
      "resultSearchCount": 58,
      "totalSearchCount": 61,
      "clickThroughRate": 36.0655737704918,
      "clickCount": 21,
      "sessionCount": 7,
      "sessionWithSearchCount": 6,
      "sessionWithSearchPercent": 85.71428571428571,
      "avgClickPosition": 2.380952380952381,
      "meanReciprocalRank": 0.6373015873015873,
      "noResultSearchCount": 3,
      "noResultSearchPercent": 4.918032786885246,
      "searchWithClickCount": 22,
      "searchExitCount": 1,
      "searchExitPercent": 14.285714285714285,
      "searchPerSessionCount": 8.714285714285714,
      "startDate": "2022-02-06T07:00:00+00:00",
      "endDate": "2022-02-28T06:59:59+00:00"
    }
  ],
  "topNoClickSearches": [
    {
      "searchCount": 6,
      "sumClicks": 0,
      "clickThroughRate": 0,
      "avgLatency": 21.166666666666668,
      "avgHits": 403,
      "query": "search",
      "ofTotal": 9.836065573770492
    },
    {
      "searchCount": 5,
      "sumClicks": 0,
      "clickThroughRate": 0,
      "avgLatency": 121.2,
      "avgHits": 80,
      "query": "drupal",
      "ofTotal": 8.19672131147541
    },
    {
      "searchCount": 5,
      "sumClicks": 0,
      "clickThroughRate": 0,
      "avgLatency": 18.4,
      "avgHits": 173,
      "query": "sitecore plugin",
      "ofTotal": 8.19672131147541
    },

Report Items

To create a report of Most-Clicked and Least-Clicked Items, use a cURL command in this general format:

curl '<Analytics Reporting API Endpoint>/api/rest/analytics/v1/reporting/clicks/clicks' -H 'authorization: Token <Key>' 

A fully-expanded example resembles this:

curl 'https://analytics-us.searchstax.com/api/rest/analytics/v1/reporting/clicks/clicks?&startDate=2022-02-06T07:00:00&endDate=2022-02-28T06:59:59&offset=0&limit=10&language=en' -H 'authorization: Token V3B2XGcj9nmA8cMJiEp5UURb1eZzQMiKL953384dszU'

Parameter Description Example
key:
required
string
Unique Analytics Reporting API Key 4Qp1Sv9MnALbAGbixW9ZaW95338fwm6i
startdate:
optional
datetime
The date and time (UTC) of the earliest events in the report. Defaults to the last 31 days. 2022-02-06T07:00:00
enddate:
optional
string
The date and time (UTC) of the latest events in the report. Default to the last 31 days. Max end date is 31 days after the start date. 2022-02-28T06:59:59
offset:
optional
number
This index begins at 0. It is used for how far down in the results for most popular searches, no result searches, and searches with no clicks tables to start collecting in the report. Defaults to 0. 0
limit:
optional
number
This number begins at 0. It is used for how far down in the results for most popular searches, no result searches, and searches with no clicks tables to end the collection of data in the report.Defaults to the end of the results. 10
language:
optional
string
A two-letter language code. Defaults to the default language. en

The returned value is a JSON document describing items. The parameters map into the values shown in the Studio Items screen. A partial sample is shown below.

{
  "aggMetrics": [
    {
      "impressionCount": 663,
      "clickCount": 21,
      "contentClickThroughRate": 3.167420814479638,
      "avgClickPosition": 2.380952380952381,
      "startDate": "2022-02-06T07:00:00+00:00",
      "endDate": "2022-02-28T06:59:59+00:00"
    }
  ],
  "mostClicked": [
    {
      "clickCount": 1,
      "ofTotal": 4.761904761904762,
      "cDocId": "095c1ffe-d2bb-4bc3-82ae-8c13075e5021",
      "cDocTitle": "Microsoft Azure | SearchStax Partners",
      "impressionCount": 2,
      "contentClickThroughRate": 50,
      "avgClickPosition": 2
    },
    {
      "clickCount": 1,
      "ofTotal": 4.761904761904762,
      "cDocId": "0a13ade1-da89-4a78-9531-50efacfc48b4",
      "cDocTitle": "Sitecore 10.0 - SearchStax Docs",
      "impressionCount": 7,
      "contentClickThroughRate": 14.285714285714285,
      "avgClickPosition": 5
    },
    {
      "clickCount": 1,
      "ofTotal": 4.761904761904762,
      "cDocId": "1115779e-6aa5-456c-bb39-2a372c589bd6",
      "cDocTitle": "Solr Version Policy | SearchStax",
      "impressionCount": 1,
      "contentClickThroughRate": 100,
      "avgClickPosition": 3
    },


Power Search (Searches)

To perform a Power Search of Searches using the REST API, use a cURL command in this general format:

curl '<Reporting API Endpoint>/api/rest/analytics/v1/reporting/searches/power-search/searches?&filterName=<Filter Name>&filterOperator=<Filter Operator>&filterValue=<Filter Value>&ordering=<Ordering>' -H 'authorization: Token <Key>'  

A fully-expanded example resembles this:

curl 'https://analytics-us.searchstax.com/api/rest/analytics/v1/reporting/searches/power-search/searches?filterName=clickThroughRate&filterOperator=gt&filterValue=3&ordering=-clickThroughRate&startDate=2022-02-06T07:00:00&endDate=2022-02-28T06:59:59&offset=0&limit=10&language=en' -H 'authorization: Token V3B2XGcj9nmA8cMJiEp5UURb1eZzQMiKL953384dszU'

Note that you can use up to three filterName=”name”&filterOperator=”operator”&filterValue=”value” constructions in sequence to apply multiple filters.

Parameter Description Example
key:
required
string
Unique Analytics Reporting API Key 4Qp1Sv9MnALbAGbixW9ZaW95338fwm6i
filterName:
required
string
The name of the filter as seen on the Power Search screen. clickThroughRate
avgHits
searchCount
sumClicks
avgClickPosition
avgLatency
filterOperator
required
string
The filter operator to be applied. Must appear between filterName and filterValue. gt
gte
lt
lte
eq
filterValue
required
number
The value that the filter will test. 50
ordering
required
string
The results are ordered by the filterName specified. This defaults to sort by ascending. Applying a ‘-’ before the filterName will produce a descending sort. -clickThroughRate
startdate:
optional
datetime
The date and time (UTC) of the earliest events in the report. Defaults to the last 31 days. 2022-02-06T07:00:00
enddate:
optional
string
The date and time (UTC) of the latest events in the report. Default to the last 31 days. Max end date is 31 days after the start date. 2022-02-28T06:59:59
offset:
optional
number
This index begins at 0. It is used for how far down in the results for most popular searches, no result searches, and searches with no clicks tables to start collecting in the report. Defaults to 0. 0
limit:
optional
number
This number begins at 0. It is used for how far down in the results for most popular searches, no result searches, and searches with no clicks tables to end the collection of data in the report.Defaults to the end of the results. 10
language:
optional
string
A two-letter language code. Defaults to the default language. en

The returned value is a JSON document describing searches. The parameters map into the values shown in the Studio Power Search screen. A partial sample is shown below.

{
  "results": [
    {
      "searchCount": 1,
      "sumClicks": 3,
      "clickThroughRate": 100,
      "avgLatency": 34,
      "avgHits": 67,
      "query": "partner",
      "ofTotal": 1.639344262295082,
      "avgClickPosition": 2.3333333333333335
    },
    {
      "searchCount": 1,
      "sumClicks": 2,
      "clickThroughRate": 100,
      "avgLatency": 39,
      "avgHits": 35,
      "query": "private",
      "ofTotal": 1.639344262295082,
      "avgClickPosition": 2.5
    },
    {
      "searchCount": 1,
      "sumClicks": 3,
      "clickThroughRate": 100,
      "avgLatency": 69,
      "avgHits": 432,
      "query": "solr",
      "ofTotal": 1.639344262295082,
      "avgClickPosition": 2
    },


Power Search (Items)

To perform a Power Search of Items using the REST API, use a cURL command in this general format:

curl '<Reporting API Endpoint>/api/rest/analytics/v1/reporting/clicks/power-search/clicks?&filterName=<Filter Name>&filterOperator=<Filter Operator>&filterValue=<Filter Value>&ordering=<Ordering>' -H 'authorization: Token <Key>'  

A fully-expanded example resembles this:

curl 'https://analytics-us.searchstax.com/api/rest/analytics/v1/reporting/clicks/power-search/clicks?filterName=contentClickThroughRate&filterOperator=lte&filterValue=20&ordering=-contentClickThroughRate&startDate=2022-02-06T07:00:00&endDate=2022-02-28T06:59:59&offset=0&limit=10&language=en' -H 'authorization: Token V3B2XGcj9nmA8cMJiEp5UURb1eZzQMiKL953384dszU'

Note that you can use up to three filterName=”name”&filterOperator=”operator”&filterValue=”value” constructions in sequence to apply multiple filters.

Parameter Description Example
key:
required
string
Unique Analytics Reporting API Key 4Qp1Sv9MnALbAGbixW9ZaW95338fwm6i
filterName:
required
string
The name of the filter as seen on the Power Search screen. contentClickThroughRate
impressionCount
clickCount
filterOperator
required
string
The filter operator to be applied. Must appear between filterName and filterValue. gt
gte
lt
lte
eq
filterValue
required
number
The value that the filter will test. 50
ordering
required
string
The results are ordered by the filterName specified. This defaults to sort by ascending. Applying a ‘-’ before the filterName will produce a descending sort. -contentClickThroughRate
startdate:
optional
datetime
The date and time (UTC) of the earliest events in the report. Defaults to the last 31 days. 2022-02-06T07:00:00
enddate:
optional
string
The date and time (UTC) of the latest events in the report. Default to the last 31 days. Max end date is 31 days after the start date. 2022-02-28T06:59:59
offset:
optional
number
This index begins at 0. It is used for how far down in the results for most popular searches, no result searches, and searches with no clicks tables to start collecting in the report. Defaults to 0. 0
limit:
optional
number
This number begins at 0. It is used for how far down in the results for most popular searches, no result searches, and searches with no clicks tables to end the collection of data in the report.Defaults to the end of the results. 10
language:
optional
string
A two-letter language code. Defaults to the default language. en

The returned value is a JSON document describing items. The parameters map into the values shown in the Studio Power Search screen. A partial sample is shown below.

{
  "results": [
    {
      "clickCount": 1,
      "ofTotal": 4.761904761904762,
      "cDocId": "0a13ade1-da89-4a78-9531-50efacfc48b4",
      "cDocTitle": "Sitecore 10.0 - SearchStax Docs",
      "impressionCount": 7,
      "contentClickThroughRate": 14.285714285714285,
      "avgClickPosition": 5
    },
    {
      "clickCount": 1,
      "ofTotal": 4.761904761904762,
      "cDocId": "4e33c9c8-008a-43f9-bc08-85f8fc5e68c0",
      "cDocTitle": "Free Disk Space - SearchStax Docs",
      "impressionCount": 7,
      "contentClickThroughRate": 14.285714285714285,
      "avgClickPosition": 1
    },
    {
      "clickCount": 1,
      "ofTotal": 4.761904761904762,
      "cDocId": "6289d367-00f2-4817-8659-00a5b0172ad3",
      "cDocTitle": "Sitecore Archives - SearchStax Docs",
      "impressionCount": 18,
      "contentClickThroughRate": 5.555555555555555,
      "avgClickPosition": 1
    },

Questions?

Do not hesitate to contact the SearchStax Support Desk.

The post Reporting API (REST) appeared first on SearchStax Docs.

]]>
Ingest API https://www.searchstax.com/docs/searchstudio/searchstax-studio-ingest-api/ Mon, 10 Jan 2022 20:41:10 +0000 https://www.searchstax.com/docs/?post_type=searchstudio&p=10481 Ingest API The SearchStax Studio Ingest API lets you update Solr documents in your Studio project.. The Search Endpoint (/emselect) and Suggestion Endpoint (/emsuggest) for your Search App is available… Continue reading Ingest API

The post Ingest API appeared first on SearchStax Docs.

]]>
Ingest API

The SearchStax Studio Ingest API lets you update Solr documents in your Studio project..

The Search Endpoint (/emselect) and Suggestion Endpoint (/emsuggest) for your Search App is available within your Apps Management page as shown below. They use the “Read-Only” API credentials.

The Ingest endpoint is the /update endpoint and uses the “Read-Write” Search API credentials

  

Contents of this page:

  

Indexing JSON Documents

For indexing a single JSON document, pass the JSON document to the /update endpoint as shown below:

For apps using Token Authentication:

curl -H "Authorization: Token b70dacf3956e6e148393fbfREDACTED" -X POST -H 'Content-type:application/json' --data-binary '{"id":"1"}' "https://searchcloud-2-us-east-1.searchstax.com/12345/custom-1234/update?commit=true"

For app using Basic Authentication:

curl -X POST -H 'Content-Type: application/json' 'https://ss123456-cvrfzabx-us-east-1-aws.searchstax.com/solr/ss123456-SearchStudioCorpSite/update/json/docs' --user app40-admin:REDACTEDPWD --data-binary '
{
  "id": "1",
  "title": "Doc 1"
}'

Adding multiple documents can be done by passing an array of JSON objects to the /update endpoint as shown below

curl -H "Authorization: Token b70dacf3956e6e148393fbfREDACTED" -X POST -H 'Content-type:application/json' --data-binary '[{"id":"1","title_t":"Test Title","description_t":"Testing","group_s":"Token"}]' "https://searchcloud-2-us-east-1.searchstax.com/12345/custom-1234/update?commit=true"
curl -X POST -H 'Content-Type: application/json' 'https://ss123456-cvrfzabx-us-east-1-aws.searchstax.com/solr/ss123456-SearchStudioCorpSite/update' --user app40-admin:REDACTEDPWD --data-binary '
[
  {
    "id": "1",
    "title": "Doc 1"
  },
  {
    "id": "2",
    "title": "Doc 2"
  }
]'

If the data is in a JSON file and contains an array of JSON objects, you can make a call to the /update endpoint as shown below

curl -H "Authorization: Token b70dacf3956e6e148393fbfREDACTED" -X POST -H 'Content-type:application/json' --data-binary @example.json "https://searchcloud-2-us-east-1.searchstax.com/12345/custom-1234/update?commit=true"
curl -X POST -H 'Content-Type: application/json' 'https://ss123456-cvrfzabx-us-east-1-aws.searchstax.com/solr/ss123456-SearchStudioCorpSite/update' --user app40-admin:REDACTEDPWD --data-binary @example.json -H 'Content-type:application/json'
  

Indexing XML Documents

To index XML documents, you can send one or multiple <add> tags to the \update request as shown below:

For apps using Token Authentication:

curl -H "Authorization: Token b70dacf3956e6e148393fbfREDACTED" -X POST -H 'Content-type:text/xml' --data-binary '<add><doc><field name="id">id1</field><field name="title">Document1</field><field name="text">This is the first document</field></doc></add>' "https://searchcloud-2-us-east-1.searchstax.com/12345/custom-1234/update?commit=true"

For app using Basic Authentication:

curl -X POST -H 'Content-Type: text/xml' 'https://ss123456-cvrfzabx-us-east-1-aws.searchstax.com/solr/ss123456-SearchStudioCorpSite/update' --user app40-admin:REDACTEDPWD --data-binary '
<add>
  <doc>
    <field name="id">id1</field>
    <field name="title">Document1</field>
    <field name="text">This is the first document</field>
   </doc>
</add>'
  • The <add> element introduces one more documents to be added. This can be substituted by <update> to update the document
  • The <doc> element introduces the fields making up a document.
  • The <field> element presents the content for a specific field.
  

Deleting Documents

Documents can be deleted from the index in two ways.

  • “Delete by ID” deletes the document with the specified ID
  • “Delete by Query” deletes all documents matching a specified query

Example:

For apps using Token Authentication:

curl -H "Authorization: Token b70dacf3956e6e148393fbfREDACTED" -X POST -H 'Content-type:text/xml' --data-binary '<delete><id>0002166313</id><id>0031745983</id><query>title:title1</query><query>text:redact</query></delete>' "https://searchcloud-2-us-east-1.searchstax.com/12345/custom-1234/update"
curl -H "Authorization: Token b70dacf3956e6e148393fbfREDACTED" -X POST -H 'Content-type:text/xml' --data-binary '{"delete":{"id":"0002166313"},"delete":{"id":"0031745983"},"delete":{"query":"title:title1"},"delete":{"query":"text:redact"}}' "https://searchcloud-2-us-east-1.searchstax.com/12345/custom-1234/update"

For app using Basic Authentication:

curl -X POST -H 'Content-Type: text/xml' 'https://ss123456-cvrfzabx-us-east-1-aws.searchstax.com/solr/ss123456-SearchStudioCorpSite/update' --user app40-admin:REDACTEDPWD --data-binary '
<delete>
  <id>0002166313</id>
  <id>0031745983</id>
  <query>title:title1</query>
  <query>text:redact</query>
</delete>'
curl -X POST -H 'Content-Type: application/json' 'https://ss123456-cvrfzabx-us-east-1-aws.searchstax.com/solr/ss123456-SearchStudioCorpSite/update' --user app40-admin:REDACTEDPWD --data-binary '
{
  "delete": {"id": "0002166313"},
  "delete": {"id": "0031745983"},
  "delete": {"query": "title:title1"},
  "delete": {"query": "text:redact"}
}'
  

API Limits

  • All update requests should have a max size of 2048KB.

Questions?

Do not hesitate to contact the SearchStax Support Desk.

The post Ingest API appeared first on SearchStax Docs.

]]>
Related Searches API https://www.searchstax.com/docs/searchstudio/related-searches-api/ Tue, 21 Dec 2021 20:32:14 +0000 https://www.searchstax.com/docs/?post_type=searchstudio&p=10430 Related Searches API SearchStax provides an API that retrieves the Related Searches defined for a specific search phrase in the SearchStax Studio App. Related Searches allows users to manually define… Continue reading Related Searches API

The post Related Searches API appeared first on SearchStax Docs.

]]>
Related Searches API

SearchStax provides an API that retrieves the Related Searches defined for a specific search phrase in the SearchStax Studio App.

Related Searches allows users to manually define Search terms that are related, and augments them from search terms learned using Artificial Intelligence using Analytics data. For the AI augmented related searches, Analytics should be connected with your Search page and there should be enough searches with clicks available.

This page describes how to retrieve a Json document of related-search strings for display on your search page.

The API can be accessed through any tool that assembles HTTP requests and dispatch them to a server. Among these would be the Python coreapi package, the Postman tool, and cURL. For Windows, use PowerShell 7.

Symbols enclosed in carets (< and >) such as <username> are metavariables. Substitute your local values when you encounter them in the examples.

Related Search

This method returns a list of Related Searches from a SearchStudio App.

GET <related-searches-URL>?search=<search-phrase>

where <related-searches-URL> is an endpoint from the Discovery API Tab of the App Settings screen, and <search-phrase> is the base query that has related searches defined on the Related Searches screen.

This method uses SearchAPIKey authorization. The Search API key is displayed on the Discovery API Tab. It must be passed in the header of the request.

When invoked from Linux (Bash script):

URL="https://app.searchstax.com/api/v1/nn/related-search/"
APIKEY="456cwe54sasb8e5lu5y6k48j55u95338slas"
KEYWORD="sitecore"

SEARCHES=$(curl -H "Authorization: $APIKEY" "$URL?search=$KEYWORD") 

When invoked from Windows Powershell:

# Removes TLS obstacles from connection. Otherwise connections fail. 
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12

$URL = "https://app.searchstax.com/api/v1/nn/related-search/"
$APIKEY = "81c09977fedb7e89310c87df81d7bc787301155e"
$KEYWORD = "Sitecore"

# Set up HTTP header for authorization token
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", $APIKEY)

$RESPONSE = Invoke-RestMethod -Method Get -ContentType 'application/json' -Headers $headers `
              -uri $($URL+"?search=$KEYWORD") 
$RESPONSE = $RESPONSE | ConvertTo-Json -Depth 3

Write-Host $RESPONSE

The response is a JSON document containing a list of related searches.

{
  "responseHeader": {
    "zkConnected": true,
    "status": 0,
    "QTime": 0
  },
  "response": {
    "numFound": 5,
    "start": 0,
    "numFoundExact": true,
    "docs": [
      {
        "search_term": "sitecore",
        "related_search": "sitecore 10",
        "related_score": 1
      },
      {
        "search_term": "sitecore",
        "related_search": "sitecore plugin",
        "related_score": 1
      },
      {
        "search_term": "sitecore",
        "related_search": "sitecore replace azure",
        "related_score": 1
      },
      {
        "search_term": "sitecore",
        "related_search": "site search for sitecore",
        "related_score": 1
      },
      {
        "search_term": "sitecore",
        "related_search": "managed solr for sitecore",
        "related_score": 1
      }
    ]
  }
}

The fields of each related search have the following meanings:

  • search_term: This is the search string that keys to the Related Searches.
  • related_search: Each entry contains the string of a single Related Search.
  • related_score: A measure of similarity to the search_term. The range of values is 0 to 1. Higher values are more similar.

Questions?

Do not hesitate to contact the SearchStax Support Desk.

The post Related Searches API appeared first on SearchStax Docs.

]]>
Overview https://www.searchstax.com/docs/searchstudio/api-documentation-overview/ Mon, 22 May 2023 22:47:28 +0000 https://www.searchstax.com/docs/?post_type=searchstudio&p=15520 SearchStudio API Overview SearchStax Studio includes a number of APIs to streamline and seamlessly accelerate the implementation process. Questions? Do not hesitate to contact the SearchStax Support Desk.

The post Overview appeared first on SearchStax Docs.

]]>
SearchStudio API Overview

SearchStax Studio includes a number of APIs to streamline and seamlessly accelerate the implementation process.

  • Search APIs – Search APIs are components that allow developers to seamlessly introduce search and auto-suggest capabilities to websites and applications
  • Analytics APIs – the Analytics APIs are designed to capture the tracking and reporting analytics data used by the Studio
  • Discovery APIs – the Discovery APIs drive the information for Popular Searches and Related Searches
  • Ingest APIs – the Ingest API lets you update Solr documents in your Studio project

Questions?

Do not hesitate to contact the SearchStax Support Desk.

The post Overview appeared first on SearchStax Docs.

]]>
Overview https://www.searchstax.com/docs/searchstudio/search-api-overview/ Mon, 22 May 2023 22:21:21 +0000 https://www.searchstax.com/docs/?post_type=searchstudio&p=15511 Search API Overview SearchStax Studio’s Search API tab include Endpoints for the Search API and Auto-Suggest API. Select the API to learn more about using the API in your search… Continue reading Overview

The post Overview appeared first on SearchStax Docs.

]]>
Search API Overview

SearchStax Studio’s Search API tab include Endpoints for the Search API and Auto-Suggest API. Select the API to learn more about using the API in your search application.

Questions?

Do not hesitate to contact the SearchStax Support Desk.

The post Overview appeared first on SearchStax Docs.

]]>