- Concepts
Plugins
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:
| Field | Description |
|---|---|
name | Name of the plugin. |
options | Options specific to the plugin. |
dependencies | Plugins 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. |
adapter | Optional 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.
| Plugin | Purpose | Package |
|---|---|---|
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 runs | Plugins and adapters | Enabled by |
|---|---|---|
| Browser | Analytics and events with the browser adapter | provideSitecoreAngular() |
| Server-side rendering | Analytics and events with the server adapter | provideSitecoreAngular() |
| Express request pipeline: personalization | Analytics and server-side personalization | createPersonalizeMiddleware() |
| Express request pipeline: bot detection | Analytics and events | createBotTrackingMiddleware() |
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.