Creates a new EventBuilder instance.
Configuration used to customize event payloads.
Optional InternalappApplication metadata attached to each event.
Name of the application.
Version of the application.
InternalchannelChannel value attached to each event.
InternalgetFunction that provides the locale when available.
InternalgetFunction that provides baseline page properties.
InternalgetFunction that provides the user agent string when available.
InternallibraryLibrary metadata attached to each event.
Name of the SDK/library (e.g., "@contentful/optimization-web").
Version of the analytics library.
Builds a component_click payload for entry click tracking.
ClickBuilderArgs arguments describing the entry click.
A ClickEvent describing the click.
Channel from which the event originated.
Contentful entry ID or flag key corresponding to the interaction.
Type of tracked optimization target for the interaction event.
'Entry' — A content entry.'Variable' — A Custom Flag or other variable-backed optimization target.Context object carrying environment and client metadata.
Optionalapp?: { name: string; version: string }Application-level metadata.
Name of the application.
Version of the application.
Campaign attribution metadata.
Optionalcontent?: stringCampaign content (e.g., utm_content).
Optionalmedium?: stringCampaign medium (e.g., utm_medium).
Optionalname?: stringName of the campaign (e.g., utm_campaign).
Optionalsource?: stringCampaign source (e.g., utm_source).
Optionalterm?: stringCampaign term (e.g., utm_term).
GDPR-related consent information.
Indicates whether the user has given consent.
Analytics library metadata.
Name of the SDK/library (e.g., "@contentful/optimization-web").
Version of the analytics library.
Locale identifier of the event (e.g., "en-US").
Optionallocation?: {Optional geo-location information associated with the event.
Optionalcity?: stringCity name associated with the location.
Optionalcontinent?: stringContinent name associated with the location.
Optionalcoordinates?: { latitude: number; longitude: number }Geographical coordinates for the location.
Latitude component of the coordinates.
Longitude component of the coordinates.
Optionalcountry?: stringCountry name associated with the location.
OptionalcountryCode?: stringCountry code associated with the location.
OptionalpostalCode?: stringPostal or ZIP code associated with the location.
Optionalregion?: stringRegion or state name associated with the location.
OptionalregionCode?: stringRegion or state code associated with the location.
Optionaltimezone?: stringTime zone identifier associated with the location.
Optionalpage?: {Path component of the page URL (e.g., /products/123).
Parsed query parameters for the page.
Referrer URL that led to the current page.
Raw search string including the leading ? (e.g., "?q=test").
Optionaltitle?: stringTitle of the page as seen by the user.
Full URL of the page.
Optionalscreen?: { name: string; [key: string]: JSONType }Name or label for the screen.
OptionaluserAgent?: stringUser agent string of the client, if available.
OptionalexperienceId?: stringIdentifier of the experience that rendered this entry or flag.
Unique identifier for this message.
Timestamp when the event originally occurred.
Timestamp when the event payload was sent.
Timestamp when the event was recorded or processed.
Discriminator indicating that this is an entry click event.
OptionaluserId?: stringIdentifier of the authenticated user, if known.
Index of the variant associated with this interaction.
Builds a component view event payload for Custom Flag exposure tracking.
FlagViewBuilderArgs arguments describing the Custom Flag view.
A ViewEvent describing the view.
Channel from which the event originated.
Contentful entry ID or flag key corresponding to the interaction.
Type of tracked optimization target for the interaction event.
'Entry' — A content entry.'Variable' — A Custom Flag or other variable-backed optimization target.Context object carrying environment and client metadata.
Optionalapp?: { name: string; version: string }Application-level metadata.
Name of the application.
Version of the application.
Campaign attribution metadata.
Optionalcontent?: stringCampaign content (e.g., utm_content).
Optionalmedium?: stringCampaign medium (e.g., utm_medium).
Optionalname?: stringName of the campaign (e.g., utm_campaign).
Optionalsource?: stringCampaign source (e.g., utm_source).
Optionalterm?: stringCampaign term (e.g., utm_term).
GDPR-related consent information.
Indicates whether the user has given consent.
Analytics library metadata.
Name of the SDK/library (e.g., "@contentful/optimization-web").
Version of the analytics library.
Locale identifier of the event (e.g., "en-US").
Optionallocation?: {Optional geo-location information associated with the event.
Optionalcity?: stringCity name associated with the location.
Optionalcontinent?: stringContinent name associated with the location.
Optionalcoordinates?: { latitude: number; longitude: number }Geographical coordinates for the location.
Latitude component of the coordinates.
Longitude component of the coordinates.
Optionalcountry?: stringCountry name associated with the location.
OptionalcountryCode?: stringCountry code associated with the location.
OptionalpostalCode?: stringPostal or ZIP code associated with the location.
Optionalregion?: stringRegion or state name associated with the location.
OptionalregionCode?: stringRegion or state code associated with the location.
Optionaltimezone?: stringTime zone identifier associated with the location.
Optionalpage?: {Path component of the page URL (e.g., /products/123).
Parsed query parameters for the page.
Referrer URL that led to the current page.
Raw search string including the leading ? (e.g., "?q=test").
Optionaltitle?: stringTitle of the page as seen by the user.
Full URL of the page.
Optionalscreen?: { name: string; [key: string]: JSONType }Name or label for the screen.
OptionaluserAgent?: stringUser agent string of the client, if available.
OptionalexperienceId?: stringIdentifier of the experience that rendered this entry or flag.
Unique identifier for this message.
Timestamp when the event originally occurred.
Timestamp when the event payload was sent.
Timestamp when the event was recorded or processed.
Discriminator indicating that this is an entry or flag view event.
OptionaluserId?: stringIdentifier of the authenticated user, if known.
Index of the variant associated with this interaction.
OptionalviewDurationMs?: numberMonotonically increasing visible duration for the active view.
OptionalviewId?: stringUUID identifying a single active view session.
This is a specialized variant of EventBuilder.buildView
that sets componentType to 'Variable'.
Builds a component_hover payload for entry hover tracking.
HoverBuilderArgs arguments describing the entry hover.
A HoverEvent describing the hover.
Channel from which the event originated.
Contentful entry ID or flag key corresponding to the interaction.
Type of tracked optimization target for the interaction event.
'Entry' — A content entry.'Variable' — A Custom Flag or other variable-backed optimization target.Context object carrying environment and client metadata.
Optionalapp?: { name: string; version: string }Application-level metadata.
Name of the application.
Version of the application.
Campaign attribution metadata.
Optionalcontent?: stringCampaign content (e.g., utm_content).
Optionalmedium?: stringCampaign medium (e.g., utm_medium).
Optionalname?: stringName of the campaign (e.g., utm_campaign).
Optionalsource?: stringCampaign source (e.g., utm_source).
Optionalterm?: stringCampaign term (e.g., utm_term).
GDPR-related consent information.
Indicates whether the user has given consent.
Analytics library metadata.
Name of the SDK/library (e.g., "@contentful/optimization-web").
Version of the analytics library.
Locale identifier of the event (e.g., "en-US").
Optionallocation?: {Optional geo-location information associated with the event.
Optionalcity?: stringCity name associated with the location.
Optionalcontinent?: stringContinent name associated with the location.
Optionalcoordinates?: { latitude: number; longitude: number }Geographical coordinates for the location.
Latitude component of the coordinates.
Longitude component of the coordinates.
Optionalcountry?: stringCountry name associated with the location.
OptionalcountryCode?: stringCountry code associated with the location.
OptionalpostalCode?: stringPostal or ZIP code associated with the location.
Optionalregion?: stringRegion or state name associated with the location.
OptionalregionCode?: stringRegion or state code associated with the location.
Optionaltimezone?: stringTime zone identifier associated with the location.
Optionalpage?: {Path component of the page URL (e.g., /products/123).
Parsed query parameters for the page.
Referrer URL that led to the current page.
Raw search string including the leading ? (e.g., "?q=test").
Optionaltitle?: stringTitle of the page as seen by the user.
Full URL of the page.
Optionalscreen?: { name: string; [key: string]: JSONType }Name or label for the screen.
OptionaluserAgent?: stringUser agent string of the client, if available.
OptionalexperienceId?: stringIdentifier of the experience that rendered this entry or flag.
Monotonically increasing hover duration for the active hover.
UUID identifying a single active hover session.
Unique identifier for this message.
Timestamp when the event originally occurred.
Timestamp when the event payload was sent.
Timestamp when the event was recorded or processed.
Discriminator indicating that this is an entry hover event.
OptionaluserId?: stringIdentifier of the authenticated user, if known.
Index of the variant associated with this interaction.
Builds an identify event payload to associate a user ID with traits.
IdentifyBuilderArgs arguments describing the identified user.
An IdentifyEvent payload.
Channel from which the event originated.
Context object carrying environment and client metadata.
Optionalapp?: { name: string; version: string }Application-level metadata.
Name of the application.
Version of the application.
Campaign attribution metadata.
Optionalcontent?: stringCampaign content (e.g., utm_content).
Optionalmedium?: stringCampaign medium (e.g., utm_medium).
Optionalname?: stringName of the campaign (e.g., utm_campaign).
Optionalsource?: stringCampaign source (e.g., utm_source).
Optionalterm?: stringCampaign term (e.g., utm_term).
GDPR-related consent information.
Indicates whether the user has given consent.
Analytics library metadata.
Name of the SDK/library (e.g., "@contentful/optimization-web").
Version of the analytics library.
Locale identifier of the event (e.g., "en-US").
Optionallocation?: {Optional geo-location information associated with the event.
Optionalcity?: stringCity name associated with the location.
Optionalcontinent?: stringContinent name associated with the location.
Optionalcoordinates?: { latitude: number; longitude: number }Geographical coordinates for the location.
Latitude component of the coordinates.
Longitude component of the coordinates.
Optionalcountry?: stringCountry name associated with the location.
OptionalcountryCode?: stringCountry code associated with the location.
OptionalpostalCode?: stringPostal or ZIP code associated with the location.
Optionalregion?: stringRegion or state name associated with the location.
OptionalregionCode?: stringRegion or state code associated with the location.
Optionaltimezone?: stringTime zone identifier associated with the location.
Optionalpage?: {Path component of the page URL (e.g., /products/123).
Parsed query parameters for the page.
Referrer URL that led to the current page.
Raw search string including the leading ? (e.g., "?q=test").
Optionaltitle?: stringTitle of the page as seen by the user.
Full URL of the page.
Optionalscreen?: { name: string; [key: string]: JSONType }Name or label for the screen.
OptionaluserAgent?: stringUser agent string of the client, if available.
Unique identifier for this message.
Timestamp when the event originally occurred.
Timestamp when the event payload was sent.
Timestamp when the event was recorded or processed.
Traits describing the user.
Discriminator indicating that this event is an identify event.
OptionaluserId?: stringIdentifier of the authenticated user, if known.
Builds a page view event payload.
Optional PageViewBuilderArgs overrides for the page view event.
A PageViewEvent payload.
Channel from which the event originated.
Override the context property of UniversalEventProperties with a page-specific context.
Optionalapp?: { name: string; version: string }Application-level metadata.
Name of the application.
Version of the application.
Campaign attribution metadata.
Optionalcontent?: stringCampaign content (e.g., utm_content).
Optionalmedium?: stringCampaign medium (e.g., utm_medium).
Optionalname?: stringName of the campaign (e.g., utm_campaign).
Optionalsource?: stringCampaign source (e.g., utm_source).
Optionalterm?: stringCampaign term (e.g., utm_term).
GDPR-related consent information.
Indicates whether the user has given consent.
Analytics library metadata.
Name of the SDK/library (e.g., "@contentful/optimization-web").
Version of the analytics library.
Locale identifier of the event (e.g., "en-US").
Optionallocation?: {Optional geo-location information associated with the event.
Optionalcity?: stringCity name associated with the location.
Optionalcontinent?: stringContinent name associated with the location.
Optionalcoordinates?: { latitude: number; longitude: number }Geographical coordinates for the location.
Latitude component of the coordinates.
Longitude component of the coordinates.
Optionalcountry?: stringCountry name associated with the location.
OptionalcountryCode?: stringCountry code associated with the location.
OptionalpostalCode?: stringPostal or ZIP code associated with the location.
Optionalregion?: stringRegion or state name associated with the location.
OptionalregionCode?: stringRegion or state code associated with the location.
Optionaltimezone?: stringTime zone identifier associated with the location.
Page context for events that occur within a web page.
Path component of the page URL (e.g., /products/123).
Parsed query parameters for the page.
Referrer URL that led to the current page.
Raw search string including the leading ? (e.g., "?q=test").
Optionaltitle?: stringTitle of the page as seen by the user.
Full URL of the page.
OptionaluserAgent?: stringUser agent string of the client, if available.
Unique identifier for this message.
Optionalname?: stringOptional name for the page.
Timestamp when the event originally occurred.
Page-level properties such as URL, path, and referrer.
Path component of the page URL (e.g., /products/123).
Parsed query parameters for the page.
Referrer URL that led to the current page.
Raw search string including the leading ? (e.g., "?q=test").
Optionaltitle?: stringTitle of the page as seen by the user.
Full URL of the page.
Timestamp when the event payload was sent.
Timestamp when the event was recorded or processed.
Discriminator indicating that this event is a page view.
OptionaluserId?: stringIdentifier of the authenticated user, if known.
Page properties are created by merging:
properties argument passed in.The title always falls back to DEFAULT_PAGE_PROPERTIES.title when undefined.
Builds a screen view event payload.
ScreenViewBuilderArgs arguments for the screen view event.
A ScreenViewEvent payload.
Channel from which the event originated.
Override the context property of UniversalEventProperties with a screen-specific context.
Optionalapp?: { name: string; version: string }Application-level metadata.
Name of the application.
Version of the application.
Campaign attribution metadata.
Optionalcontent?: stringCampaign content (e.g., utm_content).
Optionalmedium?: stringCampaign medium (e.g., utm_medium).
Optionalname?: stringName of the campaign (e.g., utm_campaign).
Optionalsource?: stringCampaign source (e.g., utm_source).
Optionalterm?: stringCampaign term (e.g., utm_term).
GDPR-related consent information.
Indicates whether the user has given consent.
Analytics library metadata.
Name of the SDK/library (e.g., "@contentful/optimization-web").
Version of the analytics library.
Locale identifier of the event (e.g., "en-US").
Optionallocation?: {Optional geo-location information associated with the event.
Optionalcity?: stringCity name associated with the location.
Optionalcontinent?: stringContinent name associated with the location.
Optionalcoordinates?: { latitude: number; longitude: number }Geographical coordinates for the location.
Latitude component of the coordinates.
Longitude component of the coordinates.
Optionalcountry?: stringCountry name associated with the location.
OptionalcountryCode?: stringCountry code associated with the location.
OptionalpostalCode?: stringPostal or ZIP code associated with the location.
Optionalregion?: stringRegion or state name associated with the location.
OptionalregionCode?: stringRegion or state code associated with the location.
Optionaltimezone?: stringTime zone identifier associated with the location.
Screen context for events that occur within a mobile or TV application.
Name or label for the screen.
OptionaluserAgent?: stringUser agent string of the client, if available.
Unique identifier for this message.
Name of the screen being viewed.
Timestamp when the event originally occurred.
Optionalproperties?: Record<string, JSONType>Optional properties describing the screen context.
Timestamp when the event payload was sent.
Timestamp when the event was recorded or processed.
Discriminator indicating that this event is a screen view.
OptionaluserId?: stringIdentifier of the authenticated user, if known.
Builds a track event payload for arbitrary user actions.
TrackBuilderArgs arguments describing the tracked event.
A TrackEvent payload.
Channel from which the event originated.
Context object carrying environment and client metadata.
Optionalapp?: { name: string; version: string }Application-level metadata.
Name of the application.
Version of the application.
Campaign attribution metadata.
Optionalcontent?: stringCampaign content (e.g., utm_content).
Optionalmedium?: stringCampaign medium (e.g., utm_medium).
Optionalname?: stringName of the campaign (e.g., utm_campaign).
Optionalsource?: stringCampaign source (e.g., utm_source).
Optionalterm?: stringCampaign term (e.g., utm_term).
GDPR-related consent information.
Indicates whether the user has given consent.
Analytics library metadata.
Name of the SDK/library (e.g., "@contentful/optimization-web").
Version of the analytics library.
Locale identifier of the event (e.g., "en-US").
Optionallocation?: {Optional geo-location information associated with the event.
Optionalcity?: stringCity name associated with the location.
Optionalcontinent?: stringContinent name associated with the location.
Optionalcoordinates?: { latitude: number; longitude: number }Geographical coordinates for the location.
Latitude component of the coordinates.
Longitude component of the coordinates.
Optionalcountry?: stringCountry name associated with the location.
OptionalcountryCode?: stringCountry code associated with the location.
OptionalpostalCode?: stringPostal or ZIP code associated with the location.
Optionalregion?: stringRegion or state name associated with the location.
OptionalregionCode?: stringRegion or state code associated with the location.
Optionaltimezone?: stringTime zone identifier associated with the location.
Optionalpage?: {Path component of the page URL (e.g., /products/123).
Parsed query parameters for the page.
Referrer URL that led to the current page.
Raw search string including the leading ? (e.g., "?q=test").
Optionaltitle?: stringTitle of the page as seen by the user.
Full URL of the page.
Optionalscreen?: { name: string; [key: string]: JSONType }Name or label for the screen.
OptionaluserAgent?: stringUser agent string of the client, if available.
Name of the event being tracked.
Unique identifier for this message.
Timestamp when the event originally occurred.
Additional properties describing the event.
Timestamp when the event payload was sent.
Timestamp when the event was recorded or processed.
Discriminator indicating that this event is a track event.
OptionaluserId?: stringIdentifier of the authenticated user, if known.
ProtectedbuildBuilds the universal event properties shared across all event types.
Arguments overriding the default context values.
A fully populated UniversalEventProperties object.
Channel from which the event originated.
Context object carrying environment and client metadata.
Optionalapp?: { name: string; version: string }Application-level metadata.
Name of the application.
Version of the application.
Campaign attribution metadata.
Optionalcontent?: stringCampaign content (e.g., utm_content).
Optionalmedium?: stringCampaign medium (e.g., utm_medium).
Optionalname?: stringName of the campaign (e.g., utm_campaign).
Optionalsource?: stringCampaign source (e.g., utm_source).
Optionalterm?: stringCampaign term (e.g., utm_term).
GDPR-related consent information.
Indicates whether the user has given consent.
Analytics library metadata.
Name of the SDK/library (e.g., "@contentful/optimization-web").
Version of the analytics library.
Locale identifier of the event (e.g., "en-US").
Optionallocation?: {Optional geo-location information associated with the event.
Optionalcity?: stringCity name associated with the location.
Optionalcontinent?: stringContinent name associated with the location.
Optionalcoordinates?: { latitude: number; longitude: number }Geographical coordinates for the location.
Latitude component of the coordinates.
Longitude component of the coordinates.
Optionalcountry?: stringCountry name associated with the location.
OptionalcountryCode?: stringCountry code associated with the location.
OptionalpostalCode?: stringPostal or ZIP code associated with the location.
Optionalregion?: stringRegion or state name associated with the location.
OptionalregionCode?: stringRegion or state code associated with the location.
Optionaltimezone?: stringTime zone identifier associated with the location.
Optionalpage?: {Path component of the page URL (e.g., /products/123).
Parsed query parameters for the page.
Referrer URL that led to the current page.
Raw search string including the leading ? (e.g., "?q=test").
Optionaltitle?: stringTitle of the page as seen by the user.
Full URL of the page.
Optionalscreen?: { name: string; [key: string]: JSONType }Name or label for the screen.
OptionaluserAgent?: stringUser agent string of the client, if available.
Unique identifier for this message.
Timestamp when the event originally occurred.
Timestamp when the event payload was sent.
Timestamp when the event was recorded or processed.
OptionaluserId?: stringIdentifier of the authenticated user, if known.
This method is used internally by the specific event-builder methods (e.g. EventBuilder.buildPageView).
Builds a component view event payload for entry exposure tracking.
ViewBuilderArgs arguments describing the entry view.
A ViewEvent describing the view.
Channel from which the event originated.
Contentful entry ID or flag key corresponding to the interaction.
Type of tracked optimization target for the interaction event.
'Entry' — A content entry.'Variable' — A Custom Flag or other variable-backed optimization target.Context object carrying environment and client metadata.
Optionalapp?: { name: string; version: string }Application-level metadata.
Name of the application.
Version of the application.
Campaign attribution metadata.
Optionalcontent?: stringCampaign content (e.g., utm_content).
Optionalmedium?: stringCampaign medium (e.g., utm_medium).
Optionalname?: stringName of the campaign (e.g., utm_campaign).
Optionalsource?: stringCampaign source (e.g., utm_source).
Optionalterm?: stringCampaign term (e.g., utm_term).
GDPR-related consent information.
Indicates whether the user has given consent.
Analytics library metadata.
Name of the SDK/library (e.g., "@contentful/optimization-web").
Version of the analytics library.
Locale identifier of the event (e.g., "en-US").
Optionallocation?: {Optional geo-location information associated with the event.
Optionalcity?: stringCity name associated with the location.
Optionalcontinent?: stringContinent name associated with the location.
Optionalcoordinates?: { latitude: number; longitude: number }Geographical coordinates for the location.
Latitude component of the coordinates.
Longitude component of the coordinates.
Optionalcountry?: stringCountry name associated with the location.
OptionalcountryCode?: stringCountry code associated with the location.
OptionalpostalCode?: stringPostal or ZIP code associated with the location.
Optionalregion?: stringRegion or state name associated with the location.
OptionalregionCode?: stringRegion or state code associated with the location.
Optionaltimezone?: stringTime zone identifier associated with the location.
Optionalpage?: {Path component of the page URL (e.g., /products/123).
Parsed query parameters for the page.
Referrer URL that led to the current page.
Raw search string including the leading ? (e.g., "?q=test").
Optionaltitle?: stringTitle of the page as seen by the user.
Full URL of the page.
Optionalscreen?: { name: string; [key: string]: JSONType }Name or label for the screen.
OptionaluserAgent?: stringUser agent string of the client, if available.
OptionalexperienceId?: stringIdentifier of the experience that rendered this entry or flag.
Unique identifier for this message.
Timestamp when the event originally occurred.
Timestamp when the event payload was sent.
Timestamp when the event was recorded or processed.
Discriminator indicating that this is an entry or flag view event.
OptionaluserId?: stringIdentifier of the authenticated user, if known.
Index of the variant associated with this interaction.
OptionalviewDurationMs?: numberMonotonically increasing visible duration for the active view.
OptionalviewId?: stringUUID identifying a single active view session.
Helper class for building optimization events.
Remarks
This class coordinates configuration and argument validation to produce strongly-typed event payloads compatible with
@contentful/optimization-api-schemas.See
EventBuilderConfig