Library tools

Use the helper functions in Personalization Library

You can use the helper functions in Personalization Library to set a Log Level to view detailed information about how personalization is generated or to clear the cached data.

Set log levels

Log messages in the browser console can guide the channel developers in basic debugging and resolving of any issues. The log levels also provide various response codes depending on the scenario.

📘

Note

By default, logging is disabled, and no logs are displayed in the console. To view the logs, you must enable the logging.

Enable logging

To set the log level, perform the following steps:

  1. Open the channel web page where you have configured Acoustic Personalization.
  2. Press F12 key, or, right-click on the web page and select Inspect.
  3. Go to the Console tab.
  4. In the Console window, run the following command:
personalization.setLogLevel(1)
  1. Refresh the web page.

Log format

Log Level messages are in the format: acoustic: [timestamp] [message]

LogLevel 1 supports the following logs:

  • Indicates whether personalization is happening for a zone. Value can be either TRUE or FALSE
  • Indicates whether personalization is successful on the zone. Value can be either TRUE or FALSE
  • Time taken to load resources: Time taken, in milliseconds, to load the rule data, caricature data, or geolocation data.
    Here is an example.
acoustic: 1573465284067 Time taken to load Rule Data (API Options + GET): 2382 ms
  • Time taken for personalization of a zone: Time taken, in milliseconds, for loading the personalized content on the zone.

  • Control group: Value for the control group, in %, as specified by user when creating the rule.

  • Holdout value: This is an algorithm-generated value. If Holdout value <= Control group, then the holdout is true, and hence no personalization is shown on the zone.
    For the first visit, this value is Undefined. It can be either TRUE or FALSE for the subsequent visits.

Log messages for response codes

Log messages also include Personalization Library response codes and messages. These messages are in the format: acoustic: [Timestamp] [Response code][Response message]
Here are a few examples.

acoustic: 1573465284061 CAR204 : Visitor activity data not available.

acoustic: 1573465284068 NPR204 : There are no published rules for the specified channel ID and zone ID.

Clear stored data

Use the following function to clear the specific storage area mentioned in function argument.

personalization.reset("<<storageArea>>")
personalization.resetLogLevel()

In the function, replace the STORAGEAREA parameter as shown below.

ParameterDescriptionExample
localStorageClears data from Local Storagepersonalization.reset("localStorage")
sessionStorageClears data from Session Storagepersonalization.reset("sessionStorage")
caricatureClears the caricature datapersonalization.reset("caricature")
allClears data from Local Storage, Session Storage and the caricature datapersonalization.reset("all")