Contentful Personalization & Analytics
    Preparing search index...

    Options for the useViewportTracking hook.

    interface UseViewportTrackingOptions {
        enabled?: boolean;
        entry: Entry;
        selectedOptimization?: {
            experienceId: string;
            sticky?: boolean;
            variantIndex: number;
            variants: Record<string, string>;
        };
        threshold?: number;
        viewDurationUpdateIntervalMs?: number;
        viewTimeMs?: number;
    }
    Index

    Properties

    enabled?: boolean

    Whether view tracking is enabled for this entry. When false, the hook returns a no-op onLayout and isVisible: false without setting up timers or scroll listeners.

    true

    entry

    entry: Entry

    The resolved Contentful entry to track (baseline or variant).

    selectedOptimization?: {
        experienceId: string;
        sticky?: boolean;
        variantIndex: number;
        variants: Record<string, string>;
    }

    Selected optimization data for variant tracking. Omit for baseline/non-optimized entries.

    Type Declaration

    • experienceId: string

      Identifier of the personalization or experiment experience.

    • Optionalsticky?: boolean

      Indicates whether this optimization selection is sticky for the user.

      false
      

      Sticky selections should be reused on subsequent requests for the same user, rather than re-allocating a new variant.

    • variantIndex: number

      Index of the selected variant within the experience configuration.

      Typically corresponds to the index of the selected OptimizationConfig entry.

    • variants: Record<string, string>

      Mapping of baseline entry IDs to their selected variant entry IDs.

      The keys are component identifiers and the values are the identifiers of the selected variant for that component.

    threshold?: number

    Minimum visibility ratio (0.0 - 1.0) required to consider the entry visible.

    0.8

    viewDurationUpdateIntervalMs?: number

    Interval (in milliseconds) between periodic view duration update events after the initial event has fired.

    5000

    viewTimeMs?: number

    Minimum accumulated visible time (in milliseconds) before the first tracking event fires.

    2000