The main use case for App output data is for it to be utilized within a mobile app or headless commerce environment to drive different outcomes or content being shown, as HTML is often not required.
App Output data can include:
App Fields (Hard coded data)
For example, if you want to associate a string with the outcome of a Slot rule tree, such as if a person has recently purchased, you could add purchased to a SmartBlock App field.
Product data (Product Field Mapping)
Pull product data into a SmartBlock App field. For example, the price of a product that is being recommended to the visitor.
Person or SmartBlock data (App Output Field Mapping)
Pull personal details into a SmartBlock App field. For example, a person’s name for use in the content.
Create and manage SmartBlock App output
App fields - hard coded data
If you need hard coded data to be outputted using a specified SmartBlock, you can use Create App Fields to set up the fields, and then App Output Field Mapping to output those fields.
To create App Fields within a SmartBlock:
Go to Content > SmartBlocks.
Create or edit a SmartBlock.
Select the App Output tab.
If you don’t see App Output, expand the More options (three dots) menu.
Select Create App Field.
Enter the following details:
Name
Provide a user-friendly name that describes the purpose of the App field.Key
Assign an identifier to the App field. This should be unique and not contain any spaces.Type
Expand the Type drop-down menu and select the field type: Text, Number or Date.Value
Enter the static output that should be given for this field.
Select CREATE.
App output field mapping
To make the App Fields, SmartBlock, or Person data output in your code, you need to set up a mapping to determine the output.
To set up the mapping:
Expand the User menu and go to Settings > Exports.
Select App Output Field Mappings.
Select CREATE FIELD MAPPING.
Expand the Field Name drop-down menu and select app_fields.
For Element in Field, enter the Key from your App field.
Enter the Output Fieldname that matches the name in your headless or app environment.
This is what you want it to be called in the output code.Add any other App fields or person fields that you want included in your App output by selecting from the drop-down menu and assigning the relevant output fieldname.
Select SAVE.
Go back to your SmartBlock, and select the App Output tab.
Expand the associated drop-down menu and select the App Output Field Mapping.
Product fields mapping - outputting product data
To make product data, for example, product name, description, or price output in the code, you need to set up a mapping to determine the output.
Expand the User menu and go to Settings > Exports.
Select Product Fields Field Mapping.
Select CREATE FIELD MAPPING.
Expand the Field Name drop-down menu and select the data that you want to include in the App Out and define the Output Name.
Add all product details you want to include to the mapping.
Select SAVE.
Go back to your SmartBlock, and select the App Output tab.
Expand the associated drop-down menu and select the Product Fields Field Mapping.
HTML output
By default, HTML output of SmartBlocks is enabled. If you want to turn it off, select the Enable HTML toggle at the bottom of the App Output tab.
App output preview
When configuring an App output in a SmartBlock, a new Preview panel appears on the right. Select the App Output tab to view the JSON that is returned for that SmartBlock, and see the output of any App fields or mappings that you add.