Contentful Personalization & Analytics
    Preparing search index...
    interface UseViewportTrackingOptions {
        entry: Entry;
        personalization?: {
            experienceId: string;
            sticky?: boolean;
            variantIndex: number;
            variants: Record<string, string>;
        };
        threshold?: number;
        viewTimeMs?: number;
    }
    Index

    Properties

    entry

    entry: Entry

    The resolved Contentful entry to track (baseline or variant). For personalized entries, this should be the entry from PersonalizedEntryResolver.resolve().entry. For non-personalized entries, pass the entry directly.

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

    The personalization data from PersonalizedEntryResolver.resolve().personalization. Required for tracking variant views. Omit for baseline/non-personalized entries.

    Type declaration

    • experienceId: string

      Identifier of the personalization or experiment experience.

    • Optionalsticky?: boolean

      Indicates whether this personalization 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 PersonalizationConfig 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 component "visible". Default: 0.8 (80% of the component must be visible in viewport)

    viewTimeMs?: number

    Minimum time (in milliseconds) the component must be visible before tracking fires. Default: 2000ms (2 seconds)