1. Concepts

Plugins

Version: 1.x

Plugins are modular components that extend the Content SDK with specific functionality. Each plugin provides a capability such as analytics, events, or personalization and can declare dependencies on other plugins. The SDK initializes only the capabilities required by the current environment. Plugins are type-safe and support TypeScript type inference.

The interface for a plugin is as follows:

export interface Plugin<Options = unknown, Adapter = unknown> {
  name: string;
  options?: Options;
  dependencies?: PluginDependency[];
  init?: () => void | Promise<void>;
  adapter?: Adapter;
}
FieldDescription
nameName of the plugin.
optionsOptions specific to the plugin.
dependenciesPlugins that must be present and initialized before the dependent plugin runs.
init()Initialization function. The SDK calls it once when initialization is required. The function can be asynchronous.
adapterOptional adapter that specifies the environment requirements for the plugin in a type-safe way.

Available plugins

The following plugins provide the analytics, events, and personalization capabilities used by the Angular integration. The integration registers the plugins required for each environment. You do not need to register them yourself.

PluginPurposePackage
analyticsPlugin()Provides client ID handling and shared analytics initialization. The events and personalization plugins depend on it.@sitecore-content-sdk/analytics-core
eventsPlugin()Enables page-view and custom event tracking using the client ID provided by the analytics plugin.@sitecore-content-sdk/events
personalizeServerPlugin()Enables server-side personalization. It uses the analytics plugin for visitor identification and cookie settings.@sitecore-content-sdk/personalize
personalizeBrowserPlugin()Enables personalization in the browser.@sitecore-content-sdk/personalize

How plugins work in an Angular application

An Angular application can run in the browser, during server-side rendering (SSR), and in the Express request pipeline. Each environment requires a different adapter and set of plugins.

Where your code runsPlugins and adaptersEnabled by
BrowserAnalytics and events with the browser adapterprovideSitecoreAngular()
Server-side renderingAnalytics and events with the server adapterprovideSitecoreAngular()
Express request pipeline: personalizationAnalytics and server-side personalizationcreatePersonalizeMiddleware()
Express request pipeline: bot detectionAnalytics and eventscreateBotTrackingMiddleware()

The browser and SSR analytics services initialize the SDK lazily. Initialization occurs when the application sends its first event. The middleware initializes the required plugins when the first applicable request reaches it. You do not need to await plugin initialization or sequence startup code yourself.

Your application interacts with the browser and SSR integrations through Angular dependency injection. Configure provideSitecoreAngular() in the application configuration, then inject the analytics token where you need to send page views, custom events, identity data, or form events. See plugins, adapters, and lightweight tracking for more information.

To replace the default plugin registration with your own, or to register additional plugins and adapters, see Analytics customization.

If you have suggestions for improving this article, let us know!