Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sitecore-cloudsdk/personalize

Package Overview
Dependencies
Maintainers
0
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sitecore-cloudsdk/personalize

This package provides browser- and server-side functions to run personalizations in your app. Personalization is for showing the most relevant content to your users.

  • 0.4.4
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

personalize

This package provides browser- and server-side functions to run personalizations in your app. Personalization is for showing the most relevant content to your users.

Installation

npm install @sitecore-cloudsdk/personalize

Usage

  1. Initialize the package using the CloudSDK function, available in the core package.
  2. To run web personalization (browser-side only):
    1. Initialize the events package.
    2. Enable web personalization during initialization.
  3. To run interactive personalization, use the personalize function.

Code examples

Run personalizations from the browser side:

'use client';

import { useEffect } from 'react';
import { CloudSDK } from '@sitecore-cloudsdk/core/browser';
import { personalize } from '@sitecore-cloudsdk/personalize/browser';

export default function Home() {
  const getPersonalizeData = async () => {
    // Run interactive personalization:
    const data = await personalize({
      channel: 'WEB',
      currency: 'EUR',
      friendlyId: '<YOUR_EXPERIENCE_FRIENDLY_ID>'
    });

    console.log(data);
  };

  useEffect(() => {
    CloudSDK({
      /* Initialization settings. See `core` package code examples. */
    })
      .addEvents() // Initialize the `events` package to enable web personalization
      .addPersonalize({ enablePersonalizeCookie: true, webPersonalization: true }) // Enable web personalization
      .initialize();

    getPersonalizeData();
  }, []);

  return <></>;
}

Run personalizations from the server side:

import type { NextRequest, NextResponse } from 'next/server';
import { CloudSDK } from '@sitecore-cloudsdk/core/server';
import { personalize } from '@sitecore-cloudsdk/personalize/server';

export async function middleware(request: NextRequest) {
  const response = NextResponse.next();

  await CloudSDK(request, response, {
    /* Initialization settings. See `core` package code examples. */
  })
    .addPersonalize({ enablePersonalizeCookie: true })
    .initialize();

  // Run interactive personalization:
  const data = await personalize(request, {
    channel: 'WEB',
    currency: 'EUR',
    friendlyId: '<YOUR_EXPERIENCE_FRIENDLY_ID>'
  });

  console.log(data);

  return response;
}

Documentation

Official Sitecore Cloud SDK documentation

FAQs

Package last updated on 08 Jan 2025

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc