Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ add click event analytics for autosuggest #3398

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions site/search/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import {
parseIndexName,
} from "./searchClient.js"
import { queryParamsToStr } from "@ourworldindata/utils"
import {
PreferenceType,
getPreferenceValue,
} from "../CookiePreferencesManager.js"

type BaseItem = Record<string, unknown>

Expand Down Expand Up @@ -264,6 +268,7 @@ export function Autocomplete({
return sources
},
plugins: [recentSearchesPlugin],
insights: getPreferenceValue(PreferenceType.Analytics),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmm I think the fact that we're merging indexes might mess not be compatible with their default solution.

Because even if you click the "first" result that is a chart, it tracks it as position 4

If we want to fix this, I think we'd have to dig into how their library automatically works and try to reconstruct the event data and submitter ourselves.

algolia.index.issue.mp4

})

const container = document.querySelector(AUTOCOMPLETE_CONTAINER_ID)
Expand Down
Loading