Pages

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from this space and version 15.11

...

SettingDescriptionRole
NameEnter a name for the piece of shared code.Required
DescriptionEnter a description for the piece of shared code. You can use the description to, for example, explain what the shared code does on the site and when it's executed.Optional
Evaluation

If you want to execute the shared code only after a certain event occurs on a page, select a trigger.

You can only select a single trigger, but you can freely change the selected trigger, and you can remove the trigger if you no longer need it.

If you do not select a trigger, the shared code is automatically executed for every page on every page load.

Selecting a trigger

To select a trigger:

  1. Click Select trigger.
  2. Select a trigger.

    Selecting a trigger

  3. At the bottom of the view, click Select.

Changing the trigger

To change the selected trigger:

  1. Click Select trigger.
  2. Select a different trigger.

    Changing the selected trigger

  3. At the bottom of the view, click Select.

Removing the trigger

To remove the selected trigger:

  1. Click Select trigger.
  2. In the Selected trigger section, click  for the trigger.

    Removing the selected trigger

  3. At the bottom of the view, click Select.
Optional
Content

Enter the JavaScript code you want to execute on the page.

Tip

When you create a new piece of shared code, this field contains example JavaScript code to get you started. You can remove the code if you don't need it.

You can use the following object variables in the code:

  • easy: Access Frosmo Platform features and data, such as the site configuration (easy.config) and visitor context data (easy.context). This is the same object you get when you use frosmo.easy in the browser console.

    For more information about debugging modifications and other platform features in the console, see Console debugging with Frosmo Core.

  • sharedCode.id: Get the shared code ID as a number.
  • site: Access site functions and data defined in the site's custom code. This is the same object you get when you use frosmo.site in the browser console.

    Note

    site is only available on sites that include custom code in their custom script.


  • triggerEventData: Access the data for the event that triggered the execution of the shared code. This object is only available when you use a trigger with the shared code.

The field automatically validates (lints) the code against ECMAScript 2018 (ES2018).

Required

Defining the shared code settings

Figure: Defining the shared code settings