Web Personalization - V2

MoEngage's Web Personalization allows you to personalize the website experience for every visitor with limited or no involvement from tech teams. Ensure that you have followed the SDK integration doc and that the SDK is working properly.

Prefetch the MoE domain

Add the following code snippet at the top of the <head> to prefetch the moengage.com domain:

JavaScript
<link rel="preconnect" href="https://cdn.moengage.com/" crossorigin />
<link rel="dns-prefetch" href="https://cdn.moengage.com/" />
<link rel="preconnect" href="https://sdk-0X.moengage.com/" crossorigin />
<link rel="dns-prefetch" href="https://sdk-0X.moengage.com/" />

The 'X' in the API Endpoint URL refers to the MoEngage Data Center (DC). MoEngage hosts each customer in a different DC. You can find your DC number (value of X) and replace the value of 'X' in the URL by referring to the DC and API endpoint mapping here.

Initiate Web P Module

Add this script to initiate the web personalization module:

JavaScript
<script src="https://cdn.moengage.com/webpush/moe_webSdk_webp.min.latest.js?app_id={app_id}&cluster={cluster}"></script>

Change the below fields:

  • Replace the 'app_id' in the URL above with the APP ID in the MoEngage Dashboard settings.
    Navigate to Dashboard -> Settings -> App -> General and copy the APP ID.
  • MoEngage hosts each customer in a different data center. Tracked data is stored in our default data center. To find your data center mapping, refer to Data Center Mapping. 

For example, if the dashboard URL starts with https://dashboard-01.moengage.com, and app_id is XXXXYYYYZZZZ111122223333,  then the prefetch and initiation code would be:

JavaScript
<link rel="preconnect" href="https://cdn.moengage.com/" crossorigin />
<link rel="dns-prefetch" href="https://cdn.moengage.com/" />
<link rel="preconnect" href="https://sdk-01.moengage.com/" crossorigin />
<link rel="dns-prefetch" href="https://sdk-01.moengage.com/" />
<script src="https://cdn.moengage.com/webpush/moe_webSdk_webp.min.latest.js?app_id=XXXXYYYYZZZZ111122223333&cluster=DC_1"></script>

Test Environment

For data to be tracked in the test environment, include `debug_logs` in the src of the above script as follows:

JavaScript
<script src="https://cdn.moengage.com/webpush/moe_webSdk_webp.min.latest.js?app_id={app_id}&cluster={cluster}&debug_logs=1"></script>

For example, if the dashboard URL starts with https://dashboard-01.moengage.com, and app_id is XXXXYYYYZZZZ111122223333,  then the whole code will look like:

JavaScript
<script src="https://cdn.moengage.com/webpush/moe_webSdk_webp.min.latest.js?app_id=XXXXYYYYZZZZ111122223333&cluster=DC_1&debug_logs=1"></script>

Cache Data Refresh

Web Personalization data will be fetched and stored in the browser cache. The data will be synced again on the Next Page Load only if it meets any of the below conditions:

  • 15 minutes have passed since the last data fetch
  • Login or Logout is executed
Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?