Sep 20, 2024
Analytics API client
This client is new in v9 of the Swift API clients.
The Analytics API client is part of the Algolia.Search
package.
You can add this package to your Package.swift
file:
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// swift-tools-version: 5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Algolia API clients",
platforms: [
.macOS(.v11)
],
dependencies: [
.package(
url: "https://github.com/algolia/algoliasearch-client-swift.git", from: "9.9.0")
],
targets: [
.executableTarget(
name: "Algolia API clients",
dependencies: [
.product(name: "Analytics", package: "algoliasearch-client-swift")
]
)
]
)
To use the Analytics client, add this import to your files:
Copy
1
import Analytics
To create an instance of the client:
Copy
1
let client = try AnalyticsClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY", region: .us)
Make sure to use the region that matches your Algolia application’s analytics region:
region.us
for the United States and region.de
for Europe.
You can check your analytics region in the Infrastructure > Analytics section of the Algolia dashboard.
List of methods
Each method makes one request to the Analytics API.
Searches
client.getTopSearches | Retrieve top searches |
client.getSearchesCount | Retrieve number of searches |
client.getSearchesNoResults | Retrieve top searches without results |
client.getNoResultsRate | Retrieve no results rate |
client.getTopHits | Retrieve top search results |
Clicks
client.getSearchesNoClicks | Retrieve top searches without clicks |
client.getNoClickRate | Retrieve no click rate |
client.getAverageClickPosition | Retrieve average click position |
client.getClickPositions | Retrieve click positions |
client.getClickThroughRate | Retrieve click-through rate |
client.getConversionRate | Retrieve conversion rate |
client.getAddToCartRate | Retrieve add-to-cart rate |
client.getPurchaseRate | Retrieve purchase rate |
client.getRevenue | Retrieve revenue data |
Users
client.getUsersCount | Retrieve number of users |
client.getTopCountries | Retrieve top countries |
Filters
client.getTopFilterAttributes | Retrieve top filters |
client.getTopFilterForAttribute | Retrieve top filter values |
client.getTopFiltersNoResults | Retrieve top filters for a search without results |
Status
client.getStatus | Retrieve update status |
Did you find this page helpful?