---
updatedAt: 2026-04-08T10:20:53.000Z
agentTools:
  projectIndex: https://developer.goacoustic.com/acoustic-personalization/llms.txt
---

# Content rendering – Display the personalized content

Display the personalized content or product recommendations from Personalization on your channel.

[block:callout]
{
  "type": "info",
  "title": "Important:",
  "body": "Rendering personalized content is the responsibility of the channel developer. The code snippets are provided here are for guidance and illustration purposes only."
}
[/block]

## Content flicker

You may notice flickering of content (for example, images) on your channel. Use the following steps to handle the content flickering on your channel. The flicker may occur when default content is momentarily displayed on the channel. Soon it is replaced by the personalized content that is returned by Personalization.

Example scenario 1:
When a visitor first loads the page, there is no personalized content to display. Since the website content loads from the client's server, the server content loads first. When the personalized content replaces the original content, it causes flickering.

Solution:
Use lightweight placeholder content instead of actual (default) content. Then, based on the PZN library response, you can replace the placeholder content. You can replace it with either the default or personalized content. The lightweight placeholder handles the graceful transition of contents.

Example scenario 2:
During subsequent page loads, there is no flicker, as there is no change in content. In this case, there is cached content in the browser. The personalized content is picked from the browser cache.

Example scenario 3:
During subsequent page loads, the personalized content returned from the library changes. And therefore, the content changes from the cached content. The content transition causes flicker. Solution: In this case, the cached content is displayed initially. When transitioning to the new content, you can blur the cached content. Then, based on the library response, replace the cached content. You can replace it with either the default or personalized content. Blurring the content takes care of the graceful transition of content.

In scenarios 1 and 2, CSS transitions assist in the smoother loading of the images.

[block:callout]
{
  "type": "info",
  "title": "Tip:",
  "body": "For better image transitioning, it is recommended to use images with low file size."
}
[/block]

## Handle content flicker

There are multiple approaches to handle the content flicker. The following shows one approach.
**Using the zone opacity**
In your website CSS, add the following snippet.

[block:code]
{
  "codes": [
    {
      "code": "<style>\n      #zoneId {\n            opacity: 0;\n            }\n</style>",
      "language": "css"
    }
  ]
}
[/block]

Here, ZONEID is the id attribute of the DOM Node from the HTML page you want to personalize.
Setting the opacity to 0 (or a similar low value to slightly grey it out) keeps the zone content hidden. Hidden content prevents flicker. The web browser still renders the page and loads all the images, style sheets, and components.
Reset the opacity attribute back to 1 after PZN returns a response as part of the rendering logic.

## Content rendering examples

Cache helps to render personalized content on the zones of your application quickly. Use the PZN rendering widget if your channel does not have the caching mechanism.

This example assumes that you are using Content as the content management system (CMS).

[block:callout]
{
  "type": "info",
  "title": "Tip:",
  "body": "To render personalized images faster, use the image pre-loading feature of JavaScript."
}
[/block]

[block:html]
{
  "html": " <ul class=\"nav nav-pills\">\n    <li class=\"active\"><a data-toggle=\"pill\" href=\"#mpa\">MPA</a></li>\n    <li><a data-toggle=\"pill\" href=\"#Aspa\">Angular SPA </a></li>\n    <li><a data-toggle=\"pill\" href=\"#Rspa\">React SPA </a></li>\n  </ul>\n\n<div class=\"tab-content\">\n  <!------------------------START----------------------------> \n<div id=\"mpa\" class=\"tab-pane fade in active\">\n  \n<p>The zones of your MPA must be registered in Personalization. For more information, see <a href=\"https://developer.goacoustic.com/acoustic-personalization/docs/configure-zones-on-your-channel\" target=\"_blank\">Register a zone</a>.</p>\n<ol>\n<li value=\"1\">Add the following code snippet anywhere before the PZN library configuration code. It uses the browser caching feature to render personalized content on the zone faster.</li></ol>\n\n<div class=\"CodeTabs CodeTabs_initial\">\n<div class=\"CodeTabs-toolbar\"><button type=\"button\">JavaScript</button>\n</div>\n<div class=\"CodeTabs-inner\"><pre><code class=\"rdmd-code lang-javascript theme-light\" data-lang=\"javascript\" name=\"\"><button aria-label=\"Copy Code\" class=\"rdmd-code-copy fa\"></button><div class=\"cm-s-neo\">\n     <span class=\"cm-keyword\">function</span> <span class=\"cm-def\">renderingWidget</span>(<span class=\"cm-def\">zoneArray</span>) {\n       <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">zoneData</span>, <span class=\"cm-def\">outletDiv</span>, <span class=\"cm-def\">now</span>;\n       <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">contentFromLS</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">JSON</span>.<span class=\"cm-property\">parse</span>(<span class=\"cm-variable\">window</span>.<span class=\"cm-property\">localStorage</span>.<span class=\"cm-property\">getItem</span>(<span class=\"cm-string\">'personalisedContent'</span>));\n       <span class=\"cm-variable-2\">zoneArray</span>.<span class=\"cm-property\">forEach</span>(<span class=\"cm-keyword\">function</span> (<span class=\"cm-def\">outletId</span>) {\n          <span class=\"cm-variable-2\">outletDiv</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">document</span>.<span class=\"cm-property\">getElementById</span>(<span class=\"cm-variable-2\">outletId</span>);\n         <span class=\"cm-keyword\">if</span>(<span class=\"cm-variable-2\">outletDiv</span>){\n          <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">background</span> <span class=\"cm-operator\">=</span> <span class=\"cm-string\">\"url(\"</span> <span class=\"cm-operator\">+</span> <span class=\"cm-operator\">&lt;&lt;</span><span class=\"cm-variable\">placeHolderImageUrl</span><span class=\"cm-operator\">&gt;&gt;</span> <span class=\"cm-operator\">+</span> <span class=\"cm-string\">\") 0px 0px / cover no-repeat\"</span>;\n          <span class=\"cm-keyword\">if</span> (<span class=\"cm-variable-2\">contentFromLS</span> <span class=\"cm-operator\">&amp;&amp;</span> <span class=\"cm-variable-2\">contentFromLS</span>[<span class=\"cm-variable-2\">outletId</span>])\n          {\n             <span class=\"cm-variable-2\">zoneData</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable-2\">contentFromLS</span>[<span class=\"cm-variable-2\">outletId</span>];\n            <span class=\"cm-comment\">/* Add display logic code to display the personalized/default content contained</span>\n<span class=\"cm-comment\">           . . .</span>\n\n<span class=\"cm-comment\">            window.localStorage.setItem('personalisedContent', JSON.stringify(contentFromLS));</span>\n<span class=\"cm-comment\">                   }</span>\n<span class=\"cm-comment\">              }</span>\n<span class=\"cm-comment\">           }</span>\n<span class=\"cm-comment\">       });</span>\n<span class=\"cm-comment\">    }</span>\n<span class=\"cm-comment\">    /* Call the rendering widget function for an array of outletIds for registered zones with</span>\n<span class=\"cm-comment\">    similar contentType */</span>\n    <span class=\"cm-variable\">renderingWidget</span>(<span class=\"cm-operator\">&lt;&lt;</span> <span class=\"cm-variable\">Array</span> <span class=\"cm-variable\">of</span> <span class=\"cm-variable\">outlet</span> <span class=\"cm-variable\">Ids</span> <span class=\"cm-operator\">&gt;&gt;</span>);\n</div></code></pre></div>\n</div>\n  \n<ol>\n<li value=\"2\">Use the caching feature used in rendering logic. The latest cached content for a zone configured for personalization is fetched. Make the following changes in the zone configuration code.</li></ol>\n\n<div class=\"CodeTabs CodeTabs_initial\">\n<div class=\"CodeTabs-toolbar\"><button type=\"button\">JavaScript</button>\n</div>\n<div class=\"CodeTabs-inner\"><pre><code class=\"rdmd-code lang-javascript theme-light\" data-lang=\"javascript\" name=\"\"><button aria-label=\"Copy Code\" class=\"rdmd-code-copy fa\"></button><div class=\"cm-s-neo\">\n    <span class=\"cm-variable\">contentObjFromLS</span> <span class=\"cm-operator\">=</span> (<span class=\"cm-variable\">window</span>.<span class=\"cm-property\">localStorage</span>.<span class=\"cm-property\">getItem</span>(<span class=\"cm-string\">'personalisedContent'</span>)) <span class=\"cm-operator\">?</span>\n    <span class=\"cm-variable\">JSON</span>.<span class=\"cm-property\">parse</span>(<span class=\"cm-variable\">window</span>.<span class=\"cm-property\">localStorage</span>.<span class=\"cm-property\">getItem</span>(<span class=\"cm-string\">'personalisedContent'</span>)) : {};\n\n    <span class=\"cm-variable\">oldZoneInformation</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">contentObjFromLS</span>[<span class=\"cm-variable\">outletId</span>]; \n</div></code></pre></div>\n</div>\n  \n<ol>\n<li value=\"3\">Add the following code to zone configuration code to handle the following scenarios:<ul>\n<li>When there is no data in local storage.</li><li>When the new content received from the library is not the same as the one stored in LocalStorage. The code displays the latest content received and updates the localStorage.</li></ul>\n</li></ol>\n  \n<div class=\"CodeTabs CodeTabs_initial\">\n<div class=\"CodeTabs-toolbar\"><button type=\"button\">JavaScript</button>\n</div>\n<div class=\"CodeTabs-inner\"><pre><code class=\"rdmd-code lang-javascript theme-light\" data-lang=\"javascript\" name=\"\"><button aria-label=\"Copy Code\" class=\"rdmd-code-copy fa\"></button><div class=\"cm-s-neo\">\n    <span class=\"cm-keyword\">if</span> (<span class=\"cm-operator\">!</span><span class=\"cm-variable\">oldZoneInformation</span> <span class=\"cm-operator\">||</span> (<span class=\"cm-variable\">contentId</span> <span class=\"cm-operator\">!==</span> <span class=\"cm-variable\">oldZoneInformation</span>[<span class=\"cm-number\">0</span>].<span class=\"cm-property\">contentID</span>))\n    { <span class=\"cm-keyword\">const</span> <span class=\"cm-def\">outletArea</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">personalizationObject</span>.<span class=\"cm-property\">getZoneArea</span>(<span class=\"cm-variable\">outletId</span>); \n    <span class=\"cm-variable\">displayContent</span>(<span class=\"cm-variable\">contentId</span>, <span class=\"cm-variable-2\">outletArea</span>);\n\n  <span class=\"cm-variable\">……</span>. . . \n\n  <span class=\"cm-property\">contentObjFromLS</span>[<span class=\"cm-variable\">outletId</span>] <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">newZoneInformation</span>;\n  <span class=\"cm-variable\">window</span>.<span class=\"cm-property\">localStorage</span>.<span class=\"cm-property\">setItem</span>(<span class=\"cm-string\">'personalisedContent'</span>, <span class=\"cm-variable\">JSON</span>.<span class=\"cm-property\">stringify</span>(<span class=\"cm-variable\">contentObjFromLS</span>));\n</div></code></pre></div>\n</div>\n  \n<p><strong>Sample code</strong><br>Example code for rendering widget, specific for rendering the URL content.</p>\n\n\n<div class=\"CodeTabs CodeTabs_initial\">\n<div class=\"CodeTabs-toolbar\"><button type=\"button\">JavaScript</button>\n</div>\n<div class=\"CodeTabs-inner\"><pre><code class=\"rdmd-code lang-javascript theme-light\" data-lang=\"javascript\" name=\"\"><button aria-label=\"Copy Code\" class=\"rdmd-code-copy fa\"></button><div class=\"cm-s-neo\">\n    <span class=\"cm-keyword\">function</span> <span class=\"cm-def\">renderingWidget</span>(<span class=\"cm-def\">zoneArray</span>) {\n       <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">zoneData</span>, <span class=\"cm-def\">outletDiv</span>, <span class=\"cm-def\">now</span>;\n       <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">contentFromLS</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">JSON</span>.<span class=\"cm-property\">parse</span>(<span class=\"cm-variable\">window</span>.<span class=\"cm-property\">localStorage</span>.<span class=\"cm-property\">getItem</span>(<span class=\"cm-string\">'personalisedContent'</span>));\n       <span class=\"cm-variable-2\">zoneArray</span>.<span class=\"cm-property\">forEach</span>(<span class=\"cm-keyword\">function</span> (<span class=\"cm-def\">outletId</span>) {\n          <span class=\"cm-variable-2\">outletDiv</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">document</span>.<span class=\"cm-property\">getElementById</span>(<span class=\"cm-variable-2\">outletId</span>);\n         <span class=\"cm-keyword\">if</span>(<span class=\"cm-variable-2\">outletDiv</span>){\n          <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">background</span> <span class=\"cm-operator\">=</span> <span class=\"cm-string\">\"url(\"</span> <span class=\"cm-operator\">+</span> <span class=\"cm-operator\">&lt;&lt;</span><span class=\"cm-variable\">placeHolderImageUrl</span><span class=\"cm-operator\">&gt;&gt;</span> <span class=\"cm-operator\">+</span> <span class=\"cm-string\">\") 0px 0px / cover no-repeat\"</span>;\n          <span class=\"cm-keyword\">if</span> (<span class=\"cm-variable-2\">contentFromLS</span> <span class=\"cm-operator\">&amp;&amp;</span> <span class=\"cm-variable-2\">contentFromLS</span>[<span class=\"cm-variable-2\">outletId</span>])\n  {\n     <span class=\"cm-variable-2\">zoneData</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable-2\">contentFromLS</span>[<span class=\"cm-variable-2\">outletId</span>];\n     <span class=\"cm-keyword\">if</span> (<span class=\"cm-variable-2\">zoneData</span>[<span class=\"cm-number\">0</span>].<span class=\"cm-property\">contentID</span> <span class=\"cm-operator\">==</span> <span class=\"cm-string\">'DCIDNF404'</span>) {\n          <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">background</span> <span class=\"cm-operator\">=</span> <span class=\"cm-string\">\"url(\"</span> <span class=\"cm-operator\">+</span> <span class=\"cm-operator\">&lt;&lt;</span><span class=\"cm-variable\">defaultContent_url</span><span class=\"cm-operator\">&gt;&gt;</span> <span class=\"cm-operator\">+</span> <span class=\"cm-string\">\") 0px 0px / cover no-repeat\"</span>;\n          <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">opacity</span> <span class=\"cm-operator\">=</span> <span class=\"cm-number\">1</span>;\n          } <span class=\"cm-keyword\">else</span> {\n         <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">image</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">new</span> <span class=\"cm-variable\">Image</span>();\n         <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">background</span> <span class=\"cm-operator\">=</span> <span class=\"cm-string\">\"url(\"</span> <span class=\"cm-operator\">+</span> <span class=\"cm-variable-2\">zoneData</span>[<span class=\"cm-number\">0</span>].<span class=\"cm-property\">contentID</span> <span class=\"cm-operator\">+</span> <span class=\"cm-string\">\") 0px 0px / cover</span>\n  <span class=\"cm-variable\">no</span><span class=\"cm-operator\">-</span><span class=\"cm-variable\">repeat</span><span class=\"cm-string\">\";</span>\n        <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">filter</span> <span class=\"cm-operator\">=</span> <span class=\"cm-string\">'blur(5px)'</span>;\n        <span class=\"cm-variable-2\">image</span>.<span class=\"cm-property\">onload</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">function</span> () {\n          <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">background</span> <span class=\"cm-operator\">=</span> <span class=\"cm-string\">\"url(\"</span> <span class=\"cm-operator\">+</span> <span class=\"cm-variable-2\">zoneData</span>[<span class=\"cm-number\">0</span>].<span class=\"cm-property\">contentID</span> <span class=\"cm-operator\">+</span> <span class=\"cm-string\">\") 0px 0px / cover</span>\n  <span class=\"cm-variable\">no</span><span class=\"cm-operator\">-</span><span class=\"cm-variable\">repeat</span><span class=\"cm-string\">\";</span>\n         <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">animation</span> <span class=\"cm-operator\">=</span> <span class=\"cm-string\">'1s ease-in-out 0s 1 slideInFromLeft'</span>;\n         <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">filter</span> <span class=\"cm-operator\">=</span> <span class=\"cm-string\">'blur(0px)'</span>;\n         <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">opacity</span> <span class=\"cm-operator\">=</span> <span class=\"cm-number\">1</span>;\n       };\n    <span class=\"cm-variable-2\">image</span>.<span class=\"cm-property\">src</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable-2\">zoneData</span>[<span class=\"cm-number\">0</span>].<span class=\"cm-property\">contentID</span>;\n    }\n  <span class=\"cm-variable-2\">now</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">new</span> <span class=\"cm-variable\">Date</span>().<span class=\"cm-property\">getTime</span>();\n  <span class=\"cm-meta\">...</span>..\n  <span class=\"cm-meta\">...</span>..\n      }\n    }\n });\n  <span class=\"cm-variable\">renderingWidget</span>([<span class=\"cm-string\">'Outlet1'</span>, <span class=\"cm-string\">'Outlet2'</span>, <span class=\"cm-string\">'Outlet3'</span>]);\n</div></code></pre></div>\n</div>\n  \n<p>Next, add code like the following example in the function that processes the content IDs. For example, <code>processContent())</code> function inside the <code>init()</code> method of your zone configuration snippet.</p>\n\n\n<blockquote class=\"callout callout_info\" theme=\"📘\">\n        <h3 class=\"callout-heading false\">\n          <span class=\"callout-icon\">📘</span>\n          <p>Note:</p></h3>\n\t<p>The function names shown here are for guidance purposes only. Use the same functions/variables that you used for zone configuration.</p>\n</blockquote>\n\t\n\n<div class=\"CodeTabs CodeTabs_initial\">\n<div class=\"CodeTabs-toolbar\"><button type=\"button\">JavaScript</button>\n</div>\n<div class=\"CodeTabs-inner\"><pre><code class=\"rdmd-code lang-javascript theme-light\" data-lang=\"javascript\" name=\"\"><button aria-label=\"Copy Code\" class=\"rdmd-code-copy fa\"></button><div class=\"cm-s-neo\">\n    {\n      <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">contentId</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">personalizationObject</span>.<span class=\"cm-property\">getContentId</span>(<span class=\"cm-variable\">zoneId</span>);\n      <span class=\"cm-comment\">/* fetch local storage data for zone */</span>\n     <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">contentObjFromLS</span> <span class=\"cm-operator\">=</span> (<span class=\"cm-variable\">window</span>.<span class=\"cm-property\">localStorage</span>.<span class=\"cm-property\">getItem</span>(<span class=\"cm-string\">'personalisedContent'</span>))\n  <span class=\"cm-operator\">?</span> <span class=\"cm-variable\">JSON</span>.<span class=\"cm-property\">parse</span>(<span class=\"cm-variable\">window</span>.<span class=\"cm-property\">localStorage</span>.<span class=\"cm-property\">getItem</span>(<span class=\"cm-string\">'personalisedContent'</span>)) : {};\n      <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">oldZoneInformation</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable-2\">contentObjFromLS</span>[<span class=\"cm-variable\">outletID</span>];\n      <span class=\"cm-keyword\">if</span> (<span class=\"cm-operator\">!</span><span class=\"cm-variable-2\">oldZoneInformation</span> <span class=\"cm-operator\">||</span> (<span class=\"cm-variable-2\">contentId</span> <span class=\"cm-operator\">!==</span> <span class=\"cm-variable-2\">oldZoneInformation</span>[<span class=\"cm-number\">0</span>].<span class=\"cm-property\">contentID</span>)) {\n        <span class=\"cm-keyword\">const</span> <span class=\"cm-def\">outletArea</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">personalizationObject</span>.<span class=\"cm-property\">getZoneArea</span>(<span class=\"cm-variable\">outletId</span>);\n        <span class=\"cm-variable\">displayContent</span>(<span class=\"cm-variable-2\">outletArea</span>, <span class=\"cm-variable-2\">contentId</span>);\n        <span class=\"cm-comment\">/* if data doesnt exist,add a new entry for the zone */</span>\n        <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">newZoneInformation</span> <span class=\"cm-operator\">=</span> [];\n        <span class=\"cm-variable-2\">newZoneInformation</span>.<span class=\"cm-property\">push</span>({\n            <span class=\"cm-property\">contentID</span>: <span class=\"cm-variable-2\">contentId</span>,\n            <span class=\"cm-property\">expiry_time</span>: <span class=\"cm-keyword\">new</span> <span class=\"cm-variable\">Date</span>().<span class=\"cm-property\">getTime</span>() <span class=\"cm-operator\">+</span> (<span class=\"cm-number\">1</span> <span class=\"cm-operator\">*</span> <span class=\"cm-number\">60</span> <span class=\"cm-operator\">*</span> <span class=\"cm-number\">60</span> <span class=\"cm-operator\">*</span> <span class=\"cm-number\">1000</span>) <span class=\"cm-comment\">/* expiring the localStorage</span>\n<span class=\"cm-comment\">  data every 1 hour */</span>\n       });\n  <span class=\"cm-variable-2\">contentObjFromLS</span>[<span class=\"cm-variable\">outletID</span>] <span class=\"cm-operator\">=</span> <span class=\"cm-variable-2\">newZoneInformation</span>;\n  <span class=\"cm-variable\">window</span>.<span class=\"cm-property\">localStorage</span>.<span class=\"cm-property\">setItem</span>(<span class=\"cm-string\">'personalisedContent'</span>, <span class=\"cm-variable\">JSON</span>.<span class=\"cm-property\">stringify</span>(<span class=\"cm-variable-2\">contentObjFromLS</span>));\n     }\n  }\n  </div></code></pre></div>\n</div>\n  \n<p>In the code snippets:</p>\n<ul>\n<li>Replace <code>ZONEARRAY</code> with an array of <code>outlet IDs</code> corresponding to the registered zones.</li><li>Replace <code>ZONEID</code> with the registered zone ID.</li><li>Replace <code>OUTLETID</code> with the outlet ID (usually the div id) of the page that has the registered zone.</li><li>Replace <code>CONTENTID</code> with the content ID for the personalized content from your CMS.</li><li>Replace <code>PLACEHOLDERIMAGEURL</code> with an image URL to display as a placeholder image. The actual content of the zone will replace it once it has loaded.</li><li>Replace <code>DEFAULTCONTENT_URL</code> with the default content to display if rules do not match the user behavior.</li><li>The error code <code>DCIDNF404</code> is returned when no published rules are available. Or when none of the published rules match the visitor behavior on the channel. In such a case, Personalization does not return any personalized content. The channel must handle this scenario by specifying a default content to be displayed in <code>DEFAULTCONTENT</code> at the specified place in the code snippet.</li><li>Provide the <code>personalizationObject</code> to refer to a personalization object.</li></ul>\n\n\n</div>\n  <!------------------------------END mpa ---------------------->\n     \n<div id=\"Aspa\" class=\"tab-pane\">\n \n<p>The zones of your Angular SPA  must be registered in Personalization. For more information, see <a href=\"https://developer.goacoustic.com/acoustic-personalization/docs/configure-zones-on-your-channel\" target=\"_blank\">Register a zone</a>.</p>\n<ol>\n<li value=\"1\">Add the following two rendering widget functions in the <code>.ts</code> file of your component:</li>\n  </ol>\n  <ul>\n  <li><code>renderingWidget()</code> function – uses the browser cache feature to render personalized content faster.</li></ol>\n  </ul>\n\n<div class=\"CodeTabs CodeTabs_initial\">\n<div class=\"CodeTabs-toolbar\"><button type=\"button\">JavaScript</button>\n</div>\n<div class=\"CodeTabs-inner\"><pre><code class=\"rdmd-code lang-javascript theme-light\" data-lang=\"javascript\" name=\"\"><button aria-label=\"Copy Code\" class=\"rdmd-code-copy fa\"></button><div class=\"cm-s-neo\">\n      <span class=\"cm-variable\">renderingWidget</span>(<span class=\"cm-variable\">zone</span>) {\n     <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">zoneData</span> , <span class=\"cm-def\">zoneContent</span>, <span class=\"cm-def\">now</span>;\n     <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">contentFromLS</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">window</span>.<span class=\"cm-property\">localStorage</span>.<span class=\"cm-property\">getItem</span>(<span class=\"cm-string\">'personalisedContent'</span>) <span class=\"cm-operator\">?</span> <span class=\"cm-variable\">JSON</span>.<span class=\"cm-property\">parse</span>(<span class=\"cm-variable\">window</span>.<span class=\"cm-property\">localStorage</span>.<span class=\"cm-property\">getItem</span>(<span class=\"cm-string\">'personalisedContent'</span>))\n    : {};\n     <span class=\"cm-keyword\">if</span> (<span class=\"cm-variable-2\">contentFromLS</span> <span class=\"cm-operator\">&amp;&amp;</span> <span class=\"cm-variable-2\">contentFromLS</span>[<span class=\"cm-variable\">zone</span>]){\n         <span class=\"cm-variable-2\">zoneData</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable-2\">contentFromLS</span>[<span class=\"cm-variable\">zone</span>];\n         <span class=\"cm-variable-2\">zoneContent</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable-2\">zoneData</span>[<span class=\"cm-number\">0</span>].<span class=\"cm-property\">contentID</span>;\n         <span class=\"cm-variable-2\">now</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">new</span> <span class=\"cm-variable\">Date</span>().<span class=\"cm-property\">getTime</span>();\n         <span class=\"cm-keyword\">if</span> (<span class=\"cm-variable-2\">now</span> <span class=\"cm-operator\">&gt;</span> <span class=\"cm-variable-2\">zoneData</span>[<span class=\"cm-number\">0</span>].<span class=\"cm-property\">expiry_time</span>) {\n         <span class=\"cm-comment\">/* Remove the localStorage entry for the zone if expiry time has been reached</span>\n<span class=\"cm-comment\">    */</span>\n         <span class=\"cm-variable-2\">zoneData</span>.<span class=\"cm-property\">splice</span>(<span class=\"cm-number\">0</span>);\n         <span class=\"cm-variable\">localStorage</span>.<span class=\"cm-property\">set</span>(<span class=\"cm-string\">'personalisedContent'</span>, <span class=\"cm-variable\">JSON</span>.<span class=\"cm-property\">stringify</span>(<span class=\"cm-variable-2\">contentFromLS</span>));\n          }\n       }\n        <span class=\"cm-keyword\">return</span> <span class=\"cm-variable-2\">zoneContent</span> <span class=\"cm-operator\">?</span> <span class=\"cm-variable-2\">zoneContent</span> : <span class=\"cm-string\">''</span>;\n    }</div></code></pre></div>\n</div>\n  \n<ul>\n<li><code>updateZoneInfo() function</code> – updates zone and content data in the webstorage object. The content is updated every time content is received from the PZN library. This update helps <code>renderingWidget()</code> to achieve faster rendering.</li></ul>\n\n<div class=\"CodeTabs CodeTabs_initial\">\n<div class=\"CodeTabs-toolbar\"><button type=\"button\">JavaScript</button>\n</div>\n<div class=\"CodeTabs-inner\"><pre><code class=\"rdmd-code lang-javascript theme-light\" data-lang=\"javascript\" name=\"\"><button aria-label=\"Copy Code\" class=\"rdmd-code-copy fa\"></button><div class=\"cm-s-neo\">\n    <span class=\"cm-variable\">updateZoneInfo</span>(<span class=\"cm-variable\">zone</span>, <span class=\"cm-variable\">contentId</span>){\n    <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">contentFromLS</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">window</span>.<span class=\"cm-property\">localStorage</span>.<span class=\"cm-property\">getItem</span>(<span class=\"cm-string\">'personalisedContent'</span>) <span class=\"cm-operator\">?</span> <span class=\"cm-variable\">JSON</span>.<span class=\"cm-property\">parse</span>(<span class=\"cm-variable\">window</span>.<span class=\"cm-property\">localStorage</span>.<span class=\"cm-property\">getItem</span>(<span class=\"cm-string\">'personalisedContent'</span>))\n  : {};\n    <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">newZoneInformation</span> <span class=\"cm-operator\">=</span> [];\n    <span class=\"cm-variable-2\">newZoneInformation</span>.<span class=\"cm-property\">push</span>({\n       <span class=\"cm-property\">contentID</span>: <span class=\"cm-variable\">contentId</span>,\n       <span class=\"cm-property\">expiry_time</span>: <span class=\"cm-keyword\">new</span> <span class=\"cm-variable\">Date</span>().<span class=\"cm-property\">getTime</span>() <span class=\"cm-operator\">+</span> (<span class=\"cm-number\">1</span> <span class=\"cm-operator\">*</span> <span class=\"cm-number\">60</span> <span class=\"cm-operator\">*</span> <span class=\"cm-number\">60</span> <span class=\"cm-operator\">*</span> <span class=\"cm-number\">1000</span>) <span class=\"cm-comment\">/* expiring the localStorage</span>\n<span class=\"cm-comment\">  data every 1 hour */</span>\n      });\n  <span class=\"cm-variable-2\">contentFromLS</span>[<span class=\"cm-variable\">zone</span>] <span class=\"cm-operator\">=</span> <span class=\"cm-variable-2\">newZoneInformation</span>;\n  <span class=\"cm-variable\">window</span>.<span class=\"cm-property\">localStorage</span>.<span class=\"cm-property\">setItem</span>(<span class=\"cm-string\">'personalisedContent'</span>, <span class=\"cm-variable\">JSON</span>.<span class=\"cm-property\">stringify</span>(<span class=\"cm-variable-2\">contentFromLS</span>));\n  }\n  </div></code></pre></div>\n</div>\n  \n<ol>\n<li value=\"2\">Next, use the stored content from local storage to set the value of the <code>ContentVariable</code>. The <code>ContentVariable</code> handles rendering this content on the registered zone. Call the <code>renderingWidget()</code> function in the <code>ngOnInit()</code> function on the zone you want to implement rendering logic. Here is an example code that illustrates this step:</li></ol>\n\n<div class=\"CodeTabs CodeTabs_initial\">\n<div class=\"CodeTabs-toolbar\"><button type=\"button\">JavaScript</button>\n</div>\n<div class=\"CodeTabs-inner\"><pre><code class=\"rdmd-code lang-javascript theme-light\" data-lang=\"javascript\" name=\"\"><button aria-label=\"Copy Code\" class=\"rdmd-code-copy fa\"></button><div class=\"cm-s-neo\">\n     <span class=\"cm-operator\">&lt;&lt;</span><span class=\"cm-variable\">ContentVariable</span><span class=\"cm-operator\">&gt;&gt;</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">this</span>.<span class=\"cm-property\">renderingWidget</span>(<span class=\"cm-operator\">&lt;&lt;</span><span class=\"cm-variable\">zoneName</span><span class=\"cm-operator\">&gt;&gt;</span>)\n     </div></code></pre></div>\n</div>\n  \n<ol>\n<li value=\"3\">Call the <code>updateZoneInfo</code> to update the content information in the storage object. This call ensures the content data is available in the local storage for rendering logic on the zone. You can call the function after receiving content from the library.</li></ol>\n\n\n<div class=\"CodeTabs CodeTabs_initial\">\n<div class=\"CodeTabs-toolbar\"><button type=\"button\">JavaScript</button>\n</div>\n<div class=\"CodeTabs-inner\"><pre><code class=\"rdmd-code lang-javascript theme-light\" data-lang=\"javascript\" name=\"\"><button aria-label=\"Copy Code\" class=\"rdmd-code-copy fa\"></button><div class=\"cm-s-neo\">\n     <span class=\"cm-keyword\">this</span>.<span class=\"cm-property\">updateZoneInfo</span>((<span class=\"cm-operator\">&lt;&lt;</span><span class=\"cm-variable\">zoneName</span><span class=\"cm-operator\">&gt;&gt;</span>, <span class=\"cm-operator\">&lt;&lt;</span><span class=\"cm-variable\">contentId</span><span class=\"cm-operator\">&gt;&gt;</span>);\n     </div></code></pre></div>\n</div>\n  \n<p><strong>Sample code</strong><br>Example code shows the placement of the function calls inside the ngOnInit() function.</p>\n\n\n<div class=\"CodeTabs CodeTabs_initial\">\n<div class=\"CodeTabs-toolbar\"><button type=\"button\">JavaScript</button>\n</div>\n<div class=\"CodeTabs-inner\"><pre><code class=\"rdmd-code lang-javascript theme-light\" data-lang=\"javascript\" name=\"\"><button aria-label=\"Copy Code\" class=\"rdmd-code-copy fa\"></button><div class=\"cm-s-neo\">\n    <span class=\"cm-keyword\">function</span> <span class=\"cm-def\">renderingWidget</span>(<span class=\"cm-def\">zoneArray</span>) {\n       <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">zoneData</span>, <span class=\"cm-def\">outletDiv</span>, <span class=\"cm-def\">now</span>;\n       <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">contentFromLS</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">JSON</span>.<span class=\"cm-property\">parse</span>(<span class=\"cm-variable\">window</span>.<span class=\"cm-property\">localStorage</span>.<span class=\"cm-property\">getItem</span>(<span class=\"cm-string\">'personalisedContent'</span>));\n       <span class=\"cm-variable-2\">zoneArray</span>.<span class=\"cm-property\">forEach</span>(<span class=\"cm-keyword\">function</span> (<span class=\"cm-def\">outletId</span>) {\n          <span class=\"cm-variable-2\">outletDiv</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">document</span>.<span class=\"cm-property\">getElementById</span>(<span class=\"cm-variable-2\">outletId</span>);\n         <span class=\"cm-keyword\">if</span>(<span class=\"cm-variable-2\">outletDiv</span>){\n          <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">background</span> <span class=\"cm-operator\">=</span> <span class=\"cm-string\">\"url(\"</span> <span class=\"cm-operator\">+</span> <span class=\"cm-operator\">&lt;&lt;</span><span class=\"cm-variable\">placeHolderImageUrl</span><span class=\"cm-operator\">&gt;&gt;</span> <span class=\"cm-operator\">+</span> <span class=\"cm-string\">\") 0px 0px / cover no-repeat\"</span>;\n          <span class=\"cm-keyword\">if</span> (<span class=\"cm-variable-2\">contentFromLS</span> <span class=\"cm-operator\">&amp;&amp;</span> <span class=\"cm-variable-2\">contentFromLS</span>[<span class=\"cm-variable-2\">outletId</span>])\n  {\n     <span class=\"cm-variable-2\">zoneData</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable-2\">contentFromLS</span>[<span class=\"cm-variable-2\">outletId</span>];\n     <span class=\"cm-keyword\">if</span> (<span class=\"cm-variable-2\">zoneData</span>[<span class=\"cm-number\">0</span>].<span class=\"cm-property\">contentID</span> <span class=\"cm-operator\">==</span> <span class=\"cm-string\">'DCIDNF404'</span>) {\n          <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">background</span> <span class=\"cm-operator\">=</span> <span class=\"cm-string\">\"url(\"</span> <span class=\"cm-operator\">+</span> <span class=\"cm-operator\">&lt;&lt;</span><span class=\"cm-variable\">defaultContent_url</span><span class=\"cm-operator\">&gt;&gt;</span> <span class=\"cm-operator\">+</span> <span class=\"cm-string\">\") 0px 0px / cover no-repeat\"</span>;\n          <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">opacity</span> <span class=\"cm-operator\">=</span> <span class=\"cm-number\">1</span>;\n          } <span class=\"cm-keyword\">else</span> {\n         <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">image</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">new</span> <span class=\"cm-variable\">Image</span>();\n         <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">background</span> <span class=\"cm-operator\">=</span> <span class=\"cm-string\">\"url(\"</span> <span class=\"cm-operator\">+</span> <span class=\"cm-variable-2\">zoneData</span>[<span class=\"cm-number\">0</span>].<span class=\"cm-property\">contentID</span> <span class=\"cm-operator\">+</span> <span class=\"cm-string\">\") 0px 0px / cover</span>\n  <span class=\"cm-variable\">no</span><span class=\"cm-operator\">-</span><span class=\"cm-variable\">repeat</span><span class=\"cm-string\">\";</span>\n        <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">filter</span> <span class=\"cm-operator\">=</span> <span class=\"cm-string\">'blur(5px)'</span>;\n        <span class=\"cm-variable-2\">image</span>.<span class=\"cm-property\">onload</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">function</span> () {\n          <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">background</span> <span class=\"cm-operator\">=</span> <span class=\"cm-string\">\"url(\"</span> <span class=\"cm-operator\">+</span> <span class=\"cm-variable-2\">zoneData</span>[<span class=\"cm-number\">0</span>].<span class=\"cm-property\">contentID</span> <span class=\"cm-operator\">+</span> <span class=\"cm-string\">\") 0px 0px / cover</span>\n  <span class=\"cm-variable\">no</span><span class=\"cm-operator\">-</span><span class=\"cm-variable\">repeat</span><span class=\"cm-string\">\";</span>\n         <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">animation</span> <span class=\"cm-operator\">=</span> <span class=\"cm-string\">'1s ease-in-out 0s 1 slideInFromLeft'</span>;\n         <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">filter</span> <span class=\"cm-operator\">=</span> <span class=\"cm-string\">'blur(0px)'</span>;\n         <span class=\"cm-variable-2\">outletDiv</span>.<span class=\"cm-property\">style</span>.<span class=\"cm-property\">opacity</span> <span class=\"cm-operator\">=</span> <span class=\"cm-number\">1</span>;\n       };\n    <span class=\"cm-variable-2\">image</span>.<span class=\"cm-property\">src</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable-2\">zoneData</span>[<span class=\"cm-number\">0</span>].<span class=\"cm-property\">contentID</span>;\n    }\n  <span class=\"cm-variable-2\">now</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">new</span> <span class=\"cm-variable\">Date</span>().<span class=\"cm-property\">getTime</span>();\n  <span class=\"cm-meta\">...</span>..\n  <span class=\"cm-meta\">...</span>..\n      }\n    }\n });\n  <span class=\"cm-variable\">renderingWidget</span>([<span class=\"cm-string\">'Outlet1'</span>, <span class=\"cm-string\">'Outlet2'</span>, <span class=\"cm-string\">'Outlet3'</span>]);\n</div></code></pre></div>\n</div>\n  \n<p>In the code snippets:</p>\n<ul>\n<li>Replace <code>ZONEARRAY</code> with an array of <code>outlet IDs</code> corresponding to the registered zones.</li>\n  <li>Replace <code>ZONEID</code> with the registered zone ID.</li>\n  <li>Replace <code>OUTLETID</code> with the outlet ID (usually the div id) of the page that has the registered zone.</li>\n  <li>Replace <code>CONTENTID</code> with the content ID for the personalized content from your CMS.</li>\n  <li>In the IMG_CONST, provide a map of content IDs and the actual content for personalization.</li>\n  <li>The error code <code>DCIDNF404</code> is returned when no published rules are available. Or when none of the published rules match the visitor behavior on the channel. In such a case, Personalization does not return any personalized content. The channel must handle this scenario by specifying a default content to be displayed in <code>DEFAULTCONTENT</code> at the specified place in the code snippet.</li>\n  <li>Provide the <code>personalizationObject</code> to refer to a personalization object.</li></ul>\n   \n</div>\n  <!------------------------------END Aspa ---------------------->    \n     <div id=\"Rspa\" class=\"tab-pane\">\n      \n    \n<p>The zones of your React SPA  must be registered in Personalization. For more information, see <a href=\"https://developer.goacoustic.com/acoustic-personalization/docs/configure-zones-on-your-channel\" target=\"_blank\">Register a zone</a>.</p>\n<ol>\n<li value=\"1\">Import local storage in the React component where you would like to use the rendering widget:</li></ol>\n\n\n<div class=\"CodeTabs CodeTabs_initial\">\n<div class=\"CodeTabs-toolbar\"><button type=\"button\">JavaScript</button>\n</div>\n<div class=\"CodeTabs-inner\"><pre><code class=\"rdmd-code lang-javascript theme-light\" data-lang=\"javascript\" name=\"\"><button aria-label=\"Copy Code\" class=\"rdmd-code-copy fa\"></button><div class=\"cm-s-neo\">\n    <span class=\"cm-keyword\">import</span> <span class=\"cm-def\">ls</span> <span class=\"cm-keyword\">from</span> <span class=\"cm-string\">'local-storage'</span>;\n    </div></code></pre></div>\n</div>\n       \n<ol>\n<li value=\"2\">Add the following rendering widget functions, after <code>componentDidMount()</code> function. The functions must be added before the <code>render()</code> functions of your component:<ul>\n<li><code>renderingWidget()</code> function – uses the browser cache feature to render personalized content faster.</li></ul>\n</li></ol>\n\n\n<div class=\"CodeTabs CodeTabs_initial\">\n<div class=\"CodeTabs-toolbar\"><button type=\"button\">JavaScript</button>\n</div>\n<div class=\"CodeTabs-inner\"><pre><code class=\"rdmd-code lang-javascript theme-light\" data-lang=\"javascript\" name=\"\"><button aria-label=\"Copy Code\" class=\"rdmd-code-copy fa\"></button><div class=\"cm-s-neo\">\n    <span class=\"cm-variable\">renderingWidget</span>(<span class=\"cm-variable\">zone</span>) {\n      <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">zoneData</span> , <span class=\"cm-def\">zoneContent</span>, <span class=\"cm-def\">now</span>;\n      <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">contentFromLS</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">ls</span>.<span class=\"cm-property\">get</span>(<span class=\"cm-string\">'personalisedContent'</span>) <span class=\"cm-operator\">?</span> <span class=\"cm-variable\">JSON</span>.<span class=\"cm-property\">parse</span>(<span class=\"cm-variable\">ls</span>.<span class=\"cm-property\">get</span>(<span class=\"cm-string\">'personalisedContent'</span>))\n    : {};\n      <span class=\"cm-keyword\">if</span> (<span class=\"cm-variable-2\">contentFromLS</span> <span class=\"cm-operator\">&amp;</span><span class=\"cm-variable\">amp</span>;<span class=\"cm-operator\">&amp;</span><span class=\"cm-variable\">amp</span>; <span class=\"cm-variable-2\">contentFromLS</span>[<span class=\"cm-variable\">zone</span>]){\n        <span class=\"cm-variable-2\">zoneData</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable-2\">contentFromLS</span>[<span class=\"cm-variable\">zone</span>];\n        <span class=\"cm-variable-2\">zoneContent</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable-2\">zoneData</span>[<span class=\"cm-number\">0</span>].<span class=\"cm-property\">contentID</span>;\n        <span class=\"cm-variable-2\">now</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">new</span> <span class=\"cm-variable\">Date</span>().<span class=\"cm-property\">getTime</span>();\n        <span class=\"cm-keyword\">if</span> (<span class=\"cm-variable-2\">now</span> <span class=\"cm-operator\">&gt;</span> <span class=\"cm-variable-2\">zoneData</span>[<span class=\"cm-number\">0</span>].<span class=\"cm-property\">expiry_time</span>) {\n          <span class=\"cm-comment\">/* remove the localStorage entry for the zone if expiry time has been reached</span>\n<span class=\"cm-comment\">    */</span>\n          <span class=\"cm-variable-2\">zoneData</span>.<span class=\"cm-property\">splice</span>(<span class=\"cm-number\">0</span>);\n          <span class=\"cm-variable\">ls</span>.<span class=\"cm-property\">set</span>(<span class=\"cm-string\">'personalisedContent'</span>, <span class=\"cm-variable\">JSON</span>.<span class=\"cm-property\">stringify</span>(<span class=\"cm-variable-2\">contentFromLS</span>));\n           }\n       }\n      <span class=\"cm-keyword\">return</span> <span class=\"cm-variable-2\">zoneContent</span> <span class=\"cm-operator\">?</span> <span class=\"cm-variable-2\">zoneContent</span> : <span class=\"cm-string\">''</span>;\n    } </div></code></pre></div>\n</div>\n       \n<ul>\n<li><code>updateZoneInfo()</code> function – updates zone and content data in the <code>webstorage</code> object. The content is updated every time content is received from the PZN library. This update helps <code>renderingWidget()</code> to achieve faster rendering.</li></ul>\n\n<div class=\"CodeTabs CodeTabs_initial\">\n<div class=\"CodeTabs-toolbar\"><button type=\"button\">JavaScript</button>\n</div>\n<div class=\"CodeTabs-inner\"><pre><code class=\"rdmd-code lang-javascript theme-light\" data-lang=\"javascript\" name=\"\"><button aria-label=\"Copy Code\" class=\"rdmd-code-copy fa\"></button><div class=\"cm-s-neo\">\n    <span class=\"cm-variable\">updateZoneInfo</span>(<span class=\"cm-variable\">zone</span>, <span class=\"cm-variable\">contentId</span>){\n     <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">contentFromLS</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">ls</span>.<span class=\"cm-property\">get</span>(<span class=\"cm-string\">'personalisedContent'</span>) <span class=\"cm-operator\">?</span> <span class=\"cm-variable\">JSON</span>.<span class=\"cm-property\">parse</span>(<span class=\"cm-variable\">ls</span>.<span class=\"cm-property\">get</span>(<span class=\"cm-string\">'personalisedContent'</span>))\n    : {};\n     <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">newZoneInformation</span> <span class=\"cm-operator\">=</span> [];\n     <span class=\"cm-variable-2\">newZoneInformation</span>.<span class=\"cm-property\">push</span>({\n        <span class=\"cm-property\">contentID</span>: <span class=\"cm-variable\">contentId</span>,\n        <span class=\"cm-property\">expiry_time</span>: <span class=\"cm-keyword\">new</span> <span class=\"cm-variable\">Date</span>().<span class=\"cm-property\">getTime</span>() <span class=\"cm-operator\">+</span> (<span class=\"cm-number\">1</span> <span class=\"cm-operator\">*</span> <span class=\"cm-number\">60</span> <span class=\"cm-operator\">*</span> <span class=\"cm-number\">60</span> <span class=\"cm-operator\">*</span> <span class=\"cm-number\">1000</span>) <span class=\"cm-comment\">/* expiring the</span>\n<span class=\"cm-comment\">    localStorage data every 1 hour */</span>\n        });\n     <span class=\"cm-variable-2\">contentFromLS</span>[<span class=\"cm-variable\">zone</span>] <span class=\"cm-operator\">=</span> <span class=\"cm-variable-2\">newZoneInformation</span>;\n     <span class=\"cm-variable\">ls</span>.<span class=\"cm-property\">set</span>(<span class=\"cm-string\">'personalisedContent'</span>, <span class=\"cm-variable\">JSON</span>.<span class=\"cm-property\">stringify</span>(<span class=\"cm-variable-2\">contentFromLS</span>));\n    }\n    </div></code></pre></div>\n</div>\n       \n<ol>\n<li value=\"3\">Next, use the stored content from local storage to set the <code>ContentVariable</code>'s value. The <code>ContentVariable</code> handles rendering this content on the registered zone. Call the <code>renderingWidget()</code> function in the <code>componentDidMount()</code> function on the zone. Set the state for <code>zoneContent</code> as received from the personalization library.<br>The Acoustic engine continues to look for new content in the background. Here is a sample code that illustrates how to this step:</li></ol>\n\n\n<div class=\"CodeTabs CodeTabs_initial\">\n<div class=\"CodeTabs-toolbar\"><button type=\"button\">JavaScript</button>\n</div>\n<div class=\"CodeTabs-inner\"><pre><code class=\"rdmd-code lang-javascript theme-light\" data-lang=\"javascript\" name=\"\"><button aria-label=\"Copy Code\" class=\"rdmd-code-copy fa\"></button><div class=\"cm-s-neo\">\n     <span class=\"cm-keyword\">this</span>.<span class=\"cm-property\">setState</span>({\n       <span class=\"cm-property\">welcomeBannerContent</span>: <span class=\"cm-keyword\">this</span>.<span class=\"cm-property\">renderingWidget</span>(<span class=\"cm-operator\">&lt;&lt;</span><span class=\"cm-variable\">zoneName</span><span class=\"cm-operator\">&gt;&gt;</span>),}) \n       </div></code></pre></div>\n</div>\n       \n<p><strong>Sample code</strong><br>Example code shows the placement of the function calls inside the <code>ComponentDidMount()</code>  function.</p>\n\n\n<div class=\"CodeTabs CodeTabs_initial\">\n<div class=\"CodeTabs-toolbar\"><button type=\"button\">JavaScript</button>\n</div>\n<div class=\"CodeTabs-inner\"><pre><code class=\"rdmd-code lang-javascript theme-light\" data-lang=\"javascript\" name=\"\"><button aria-label=\"Copy Code\" class=\"rdmd-code-copy fa\"></button><div class=\"cm-s-neo\">\n    <span class=\"cm-variable\">componentDidMount</span> () {\n      <span class=\"cm-keyword\">this</span>.<span class=\"cm-property\">WRTP</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">this</span>.<span class=\"cm-property\">context</span>;\n      <span class=\"cm-keyword\">this</span>.<span class=\"cm-property\">_isMounted</span> <span class=\"cm-operator\">=</span> <span class=\"cm-atom\">true</span>;\n      <span class=\"cm-keyword\">this</span>.<span class=\"cm-property\">_isMounted</span> <span class=\"cm-operator\">&amp;</span><span class=\"cm-variable\">amp</span>;<span class=\"cm-operator\">&amp;</span><span class=\"cm-variable\">amp</span>;\n      <span class=\"cm-keyword\">this</span>.<span class=\"cm-property\">setState</span>({\n       <span class=\"cm-comment\">/* Calling renderingWidget() to fetch zone data from LS and</span>\n<span class=\"cm-comment\">  set the state of WelcomeBannner zone content with the stored content */</span>\n       <span class=\"cm-property\">welcomeBannerContent</span>: <span class=\"cm-keyword\">this</span>.<span class=\"cm-property\">renderingWidget</span>(<span class=\"cm-string\">'WelcomeBannerZone'</span>),\n       });\n     <span class=\"cm-keyword\">this</span>.<span class=\"cm-property\">_isMounted</span> <span class=\"cm-operator\">&amp;&amp;</span>;\n     <span class=\"cm-keyword\">this</span>.<span class=\"cm-property\">WRTP</span>.<span class=\"cm-property\">onReady</span>(() <span class=\"cm-operator\">=&gt;</span> {\n       <span class=\"cm-keyword\">let</span> <span class=\"cm-def\">contentId</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">this</span>.<span class=\"cm-property\">WRTP</span>.<span class=\"cm-property\">getContentId</span>(<span class=\"cm-string\">'WelcomeBannerZone'</span>);\n      <span class=\"cm-keyword\">this</span>.<span class=\"cm-property\">_isMounted</span> <span class=\"cm-operator\">&amp;&amp;</span> <span class=\"cm-keyword\">this</span>.<span class=\"cm-property\">setState</span>({\n          <span class=\"cm-property\">welcomeBannerContent</span>: <span class=\"cm-variable-2\">contentId</span>,\n           });\n     <span class=\"cm-comment\">/* Calling updateZoneInfo() to update newly received content data from personalization</span>\n<span class=\"cm-comment\">  library for WelcomeBanner zone in LS */</span>\n      <span class=\"cm-keyword\">this</span>.<span class=\"cm-property\">updateZoneInfo</span>(<span class=\"cm-string\">'WelcomeBannerZone'</span>, <span class=\"cm-variable-2\">contentId</span>);\n      });\n  }</div></code></pre></div>\n</div>\n       \n<p>In the code snippets:</p>\n<ul>\n<li>Replace <code>ZONE</code> with the registered zone ID.</li>\n  <li>Replace <code>OUTLETID</code> with the outlet ID (usually the div id) of the page that has the registered zone.</li>\n  <li>Replace <code>CONTENTID</code> with the content ID for the personalized content from your CMS.</li>\n  <li>In the IMG_CONST, provide a map of content IDs and the actual content for personalization.</li>\n  <li>The error code <code>DCIDNF404</code> is returned when no published rules are available. Or when none of the published rules match the visitor behavior on the channel. In such a case, Personalization does not return any personalized content. The channel must handle this scenario by specifying a default content to be displayed in <code>DEFAULTCONTENT</code> at the specified place in the code snippet.</li>\n  <li>Provide the <code>personalizationObject</code> to refer to a personalization object.</li></ul>\n\n\n</div>\n  <!------------------------------END Rspa ---------------------->     \n     \n\n</div>\n<!-----------------------------END-------------------------->\n\n<style>\n    .content-body .header-scroll{\n      font-family: National12, Roboto,sans serif;\n      font-size:24px;\n      color:#13173d;\n      font-weight: 400;\n      line-height: 1.2;\n    }\n   \n    .container {\n      width:100%;\n    }\n    .nav-pills > li.active > a, .nav-pills > li.active > a:hover{\n      color:#fff !important;\n      background-color: #047970;}\n    .nav > li > a{\n      color: #047970 !important;\n      font-family: National2,Roboto,sans serif !important;}\n    .nav > li > a:hover {\n      background-color: #047970;\n      color:#fff !important;}\n    .nav-pills > li > a{\n      border: 1px #047970 solid;}\n    .nav > li > a:focus {\n      background-color: #fff;}\n    .nav-pills > li.active > a, .nav-pills > li.active > a:focus {\n      background-color:#047970!important;}\n    .nav-pills > li + li \n    {\n      margin-top: 0 !important;}\n    </style>"
}
[/block]