Create custom values
Custom values let you create your own JavaScript-based logic for component personalization.
Unlike profile data or conditions, custom values can combine profile attributes, visitor behavior, and custom logic into a single value that you can use as an input in decision tables for audience targeting.
You can create custom values manually or generate the JavaScript with the Code Assistant.
Create a custom value using JavaScript
If you are familiar with JavaScript, you can create a custom value manually by writing your own logic in the code editor.
To create a custom value manually:
-
On the Custom Values page, click Create.
-
Enter a name for the custom value.
-
Click Create.
-
In the code editor, enter or edit the JavaScript for the logic you want to use.
For example, the following custom code returns the
lastPagevalue from the visitor’s most recent session: -
On the Overview tab in the right pane:
-
Enter a short description for the custom value.
-
Select or create tags to help organize and identify it.
-
Select the Return type, such as String, Number, Boolean, Date, or Array.
-
-
Click Save.
Create a custom value with the Code Assistant
If you are not familiar with JavaScript, you can use the Code Assistant to generate a custom value from a natural language prompt.
To create custom data with the Code Assistant:
-
On the Custom Values page, click Create.
-
Enter a name for the custom value.
-
Click Create.
-
In the Code Assistant pane, do one of the following:
-
Enter a prompt describing the logic you want to create.
When writing prompts, be specific about visitor attributes, time frames, conditions, and the expected return value.
Example prompts:
-
Return true if the visitor’s birthday is within the next seven days.
-
Categorize visitors as high, medium, or low intent based on session count and page views.
-
Return true if the visitor viewed more than five product pages.
-
-
Select one of the suggested prompts.
The Code Assistant generates JavaScript based on the current prompt and any code already in the editor.
NoteAI-generated responses can vary. Running the same prompt multiple times may produce different results.
-
-
To preview the generated code, click View.
-
In the dialog:
-
Click Replace code to insert the generated code into the editor.
-
Click Copy code to copy the generated code to your clipboard.
ImportantAI-generated code may not always be accurate. Always review and test the generated code before using it.
-
-
Optionally, after inserting the code:
-
Make manual changes in the code editor.
-
Click Undo
to revert changes.
-
-
Click Save.
Next steps
After saving the custom value:
-
Test the custom value using a guest profile to verify that it returns the expected values.
-
Publish the custom value to make it available for use as an input to the decision t able in component personalization.