Since May 1st, 2024, Apple requires all iOS apps to include a privacy manifest.
For more details, see Privacy Manifest.
- Add the
insights
client. - Add click events) when users click search results.
- Track conversions that start in your InstantSearch app.
Add the InstantSearch Insights library
Add the library as a dependency using Swift Package Manager, CocoaPods, or Carthage, and addimport InstantSearchInsights
to your source files.
Swift Package Manager
To use Swift Package Manager, open your project with Xcode. Go to File > Add Packages and enter the URL of the InstantSearch iOS library (https://github.com/algolia/instantsearch-ios
).
In the Choose Package Products for instantsearch-ios dialog,
include InstantSearchInsights
If you’re a framework author and use InstantSearch Insights as a dependency, update your Package.swift
file:
Swift
.product(name: "InstantSearchInsights", package: "InstantSearch")
to your target dependencies list.
CocoaPods
If you use CocoaPods, add the following line to yourPodfile
:
Ruby
pod update
to download the dependencies.
Carthage
If you use Carthage, add the following line to yourCartfile
:
Cartfile
InstantSearchInsights
from the Carthage build directory.
Add the Insights client
To add the Insights client, you’ll need your Algolia application ID, (search) API key, and auserToken
to identify your users.
You can find your application ID and API key in the Algolia dashboard.
Swift
generateTimestamps
parameter to false
:
Swift
region
parameter to .de
or .us
:
Swift
Customize the events flush delay
By default, the client sends events to Algolia every 30 minutes. You can adjust this delay by changing theflushDelay
value (in seconds):
Swift
Set the Insights API region
By default, each time you send an event, Algolia geo-routes the API call so that the call targets the closest servers. The analytics API supports two regions: United States and Germany. You can specify the region you prefer to use as follows.Swift
Enable automatic view events
InstantSearch can automatically send view events when hits are returned from Algolia. To enable this feature, setisAutoSendingHitsViewEvents
to true
when you initialize HitsSearcher
:
Swift
Send click events from hits widgets
To send click events when users select a search result in aHits
widget,
use the following code:
Swift
Hits
widgets, you must enable sending click events on each one separately.
Check your click events in the Events Debugger.
For more information, see Validate your events.
Send click, conversion, and view events
Use the following methods to send click, conversion, or view events:Swift
Enable logging
You can also check if you’ve sent an event by enabling logging:Swift
positions
parameter of the clickedObjectIdsAfterSearch
method,
the first object in the list of search results has a value of 1 (not 0), the second has a value of 2.