Socket
Book a DemoInstallSign in
Socket

@sitecore/engage

Package Overview
Dependencies
Maintainers
5
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sitecore/engage

© Sitecore Corporation A/S. All rights reserved. Sitecore© is a registered trademark of Sitecore Corporation A/S.

0.3.6-canary.6
canary
npmnpm
Version published
Weekly downloads
5.3K
-2.22%
Maintainers
5
Weekly downloads
 
Created
Source

Sitecore Engage

© Sitecore Corporation A/S. All rights reserved. Sitecore© is a registered trademark of Sitecore Corporation A/S.

Sitecore Engage is a JavaScript library for sending behavioral data from a web application to Sitecore CDP.

Prerequisites

Before installing Sitecore Engage, you need:

Installation

npm install @sitecore/engage

Importing

import { init } from '@sitecore/engage';

Usage

This section describes using Sitecore Engage in a Next.js web application.

  • In index.js, import useEffect from React and init from @sitecore/engage.
import { useEffect } from 'react';
import { init } from '@sitecore/engage';

export default function Home() {
  // ...
}
  • In the Home function, create an asynchronous function loadEngage for loading the Engage API, then call loadEngage in an Effect Hook.

    Tip We recommend that you use the Effect Hook because the window object must be present before you load the Engage API.

export default function Home() {
  const loadEngage = async () => {
    // ...
  };

  useEffect(() => {
    loadEngage();
  }, []);

  return <></>;
}
  • In the loadEngage function:

    • Load the Engage API by passing details about your Sitecore CDP instance to the init() function. Replace the placeholder values with your cookie domain, and your Sitecore CDP client key and target URL.

      Important

      • The init() function is asynchronous, so you must await the return value.
      • In production, call the init() function in a module once, then share it across the application using the state management solution of your choice, for example, React Context or Redux.
    • Start sending VIEW events to Sitecore CDP by passing event details to the pageView() function. Replace the placeholder values with event details specific to your organization. Replace the value for pointOfSale with your Sitecore CDP point of sale.

const loadEngage = async () => {
  // Load Engage API
  const engage = await init({
    clientKey: '{client_key_PLACEHOLDER}', // for example, "ZpHxO9WvLOfQRVPlvo0BqB8YjGYuFfNe"
    targetURL: '{stream_api_target_endpoint_PLACEHOLDER}', // for example, "https://api-engage-eu.sitecorecloud.io"
    cookieDomain: '{cookie_domain_PLACEHOLDER}', // for example, ".beta.myretailsite.com"
    cookieExpiryDays: 365,
    forceServerCookieMode: false,
  });

  // Send VIEW events
  engage.pageView({
    channel: '{channel_PLACEHOLDER}', // for example, "WEB"
    currency: '{currency_PLACEHOLDER}', // for example, "EUR"
    pointOfSale: '{point_of_sale_PLACEHOLDER}', // for example, "myretailsite/ireland"
  });
};
  • Reload your web application. Every time your webpage loads, a VIEW event is sent to Sitecore CDP.

Documentation and community resources

Contributions

We are very grateful to the community for contributing bug fixes and improvements. We welcome all efforts to evolve and improve Sitecore Engage; read below to learn how to participate in those efforts.

Code of Conduct

Sitecore has adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.

Contributing Guide

Read our contributing guide to learn about our development process, how to propose bug fixes and improvements, and how to build and test your changes to React.

License

Sitecore JavaScript Services is using the Apache 2.0 license.

Support

FAQs

Package last updated on 30 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.