0.5.1 • Published 5 months ago
@sitecore-cloudsdk/personalize v0.5.1
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/personalizeUsage
- Initialize the package using the 
CloudSDKfunction, available in thecorepackage. - To run web personalization (browser-side only):
- Initialize the 
eventspackage. - Enable web personalization during initialization.
 
 - Initialize the 
 - To run interactive personalization, use the 
personalizefunction. 
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
0.5.1-rc.0
7 months ago
0.5.0-rc.0
10 months ago
0.5.2-rc.0
5 months ago
0.4.4
10 months ago
0.5.0
9 months ago
0.4.1
12 months ago
0.4.3
11 months ago
0.5.1
7 months ago
0.4.2
12 months ago
0.4.0
1 year ago
0.4.0-rc.1
1 year ago
0.4.0-rc.0
1 year ago
0.3.1-rc.1
1 year ago
0.3.1-rc.0
1 year ago
0.3.1
1 year ago
0.3.0
2 years ago
0.2.4
2 years ago
0.2.3
2 years ago
0.2.2
2 years ago
0.2.1
2 years ago
0.1.5
2 years ago
0.2.0
2 years ago
0.1.4
2 years ago
0.1.3
2 years ago
0.1.2
2 years ago
0.1.1
2 years ago
0.1.0
2 years ago
0.1.0-rc.5
2 years ago
0.1.0-rc.4
2 years ago
0.1.0-rc.3
2 years ago
0.1.0-rc.2
2 years ago
0.1.0-rc.0
2 years ago