Trending queries
The Trending queries API provides list of popular and relevant phrases based on the analytics events. These phrases are customizable from the Luigi's Box application dashboards.
Trending queries endpoint is particularly suited for building a "trending queries" widget on your site.
Calling this endpoint gives you a list of your top queries for the past 30 days but you can customize this list in the main Luigi's Box application. There are no API parameters, the output is only controlled from Luigi's Box application UI.
From the management UI, you can:
- Set the number of returned queries
- Ban some queries from appearing in the API output
- Rewrite query text, e.g., to add accents or change caps
- Add your own queries, even if they are not trending at the moment
- Enable top hit loading for a query, you can use the top hit URL in the widget to send users directly to the most popular result for the query
Get trending queries
GET https://live.luigisbox.com/v2/trending_queries
Required Parameters
tracker_id |
Identifier of your site within Luigi's Box. You can see this identifier in every URL in the Luigi's Box app once you are logged-in. |
Request Headers
Consider sending request header of Accept-Encoding
as well with values for supported encoding methods of your HTTP client, e.g. gzip
or br, gzip, deflate
for multiple supported methods. Encodings make the response from Trending queries endpoint considerably smaller and thus faster to transfer.
Example request
require 'faraday'
require 'faraday_middleware'
require 'json'
connection = Faraday.new(url: 'https://analytics.luigisbox.com') do |conn|
conn.use FaradayMiddleware::Gzip
end
response = connection.get("/v2/trending_queries?tracker_id=1234-5678")
if response.success?
puts JSON.pretty_generate(JSON.parse(response.body))
else
puts "Error, HTTP status #{response.status}"
puts response.body
end
#!/bin/bash
curl -i -XGET --compressed\
"https://analytics.luigisbox.com/v2/trending_queries?tracker_id=1234-5678"\
<?php
// Using Guzzle (http://guzzle.readthedocs.io/en/latest/overview.html#installation)
require 'GuzzleHttp/autoload.php';
$client = new GuzzleHttp\Client();
$res = $client->request('GET', "https://analytics.luigisbox.com/v2/trending_queries?tracker_id=1234-5678", [
'headers' => [
'Accept-Encoding' => 'gzip'
]
]);
echo $res->getStatusCode();
echo $res->getBody();
// This endpoint requires no authentication
// This endpoint requires no body
The above command returns JSON structured like this.
[
{
"title": "Query A",
"links": [{
"rel": "top_content",
"href": "https://example.com/news/"
}]
},
{
"title": "query B"
}
]