Skip to content

Commit

Permalink
enhance(search): track clicks on mobile, too
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelgerber committed Apr 11, 2024
1 parent e685062 commit 8cfbb2a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions site/search/SearchPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,17 @@ function ExplorerHit({
cardPosition: number
}) {
const firstHit = groupedHit.views[0]

const exploreAllProps = {
href: `${BAKED_BASE_URL}/${EXPLORERS_ROUTE_FOLDER}/${groupedHit.explorerSlug}`,
"data-algolia-index": getIndexName(SearchIndexName.ExplorerViews),
"data-algolia-object-id": firstHit.objectID,
"data-algolia-position": firstHit.hitPositionOverall,
"data-algolia-card-position": cardPosition,
"data-algolia-position-within-card": 0,
"data-algolia-event-name": "click_explorer",
}

return (
<div
key={groupedHit.explorerSlug}
Expand All @@ -224,16 +235,8 @@ function ExplorerHit({
</div>

<a
href={`${BAKED_BASE_URL}/${EXPLORERS_ROUTE_FOLDER}/${groupedHit.explorerSlug}`}
className="search-results__explorer-hit-link hide-sm-only"
data-algolia-index={getIndexName(
SearchIndexName.ExplorerViews
)}
data-algolia-object-id={firstHit.objectID}
data-algolia-position={firstHit.hitPositionOverall}
data-algolia-card-position={cardPosition}
data-algolia-position-within-card={0}
data-algolia-event-name="click_explorer"
{...exploreAllProps}
>
Explore all {groupedHit.numViewsWithinExplorer} indicators
</a>
Expand Down Expand Up @@ -273,8 +276,8 @@ function ExplorerHit({
))}
</ul>
<a
href={`${BAKED_BASE_URL}/${EXPLORERS_ROUTE_FOLDER}/${groupedHit.explorerSlug}`}
className="search-results__explorer-hit-link-mobile hide-sm-up"
{...exploreAllProps}
>
Explore all {groupedHit.numViewsWithinExplorer} indicators
</a>
Expand Down

0 comments on commit 8cfbb2a

Please sign in to comment.