Contentful Personalization & Analytics
    Preparing search index...
    • Detects taps on a View via raw touch events and emits component_click analytics events through the existing Insights pipeline.

      Parameters

      • options: UseTapTrackingOptions

        Tracking options including the entry, personalization data, and enabled state.

      Returns UseTapTrackingReturn

      UseTapTrackingReturn with touch handlers to spread onto a View, or undefined handlers when tracking is disabled.

      If called outside of an OptimizationProvider.

      Uses onTouchStart/onTouchEnd rather than wrapping children in a Pressable, so taps are captured even when a child Pressable handles the gesture. A touch is classified as a tap only when the finger moves less than TAP_DISTANCE_THRESHOLD points between start and end.

      function TrackedEntry({ entry }: { entry: Entry }) {
      const { onTouchStart, onTouchEnd } = useTapTracking({
      entry,
      enabled: true,
      })

      return (
      <View onTouchStart={onTouchStart} onTouchEnd={onTouchEnd}>
      <Text>{entry.fields.title}</Text>
      </View>
      )
      }