Search

Home

What is Code Cube

Privacy & security

FAQ

Reusable components

Reusable components

Reusable components let you share the same sequence of steps, such as a cookie consent or login flow, across multiple DataLayer Guard scenarios without copying and pasting. When the shared sequence changes, you update it once and every scenario that uses it picks up the change automatically.

New to scenarios? Start with Monitoring via Page ScenariosMonitoring via Page Scenarios.

What will you do?

  • Open the Reusable components panel in DataLayer Guard
  • Create a component from scratch, or save existing scenario steps as a component
  • Insert a component into one or more scenarios
  • Update a component and let the change flow through to every scenario that uses it
  • Detach or delete a component safely

⏰ Estimated time: 5 - 10 minutes

🔧 Requirements: Access to the Code-Cube.io portal and a DataLayer Guard configuration with at least one scenario

Step 1 – Open the Reusable components panel

  1. Go to the DataLayer Guard configuration page
  2. In the side panel, click Reusable components

The first time you open the panel, the list is empty and shows a Create your first component button.

image

Step 2 – Create a component

You can create a component in two ways. Use whichever fits your workflow.

2.1 Create from scratch

Use this option when you already know a sequence will be shared, for example to standardize your login flow before building any scenarios.

  1. In the Reusable components panel, click + add component
  2. Enter a Component name. Pick a name a teammate will recognize, such as Cookie Consent Flow or Login as Test User
  3. Under Steps, add the steps the component should run, the same way you would in a scenario
  4. Click Save
image
💡

Tip: Name components after the user action they represent, not the technical steps. Login as Test User reads better in a step list than Click + fill + submit.

2.2 Save existing scenario steps as a component

Use this option when you've already built a sequence in a scenario and want to reuse it.

  1. Open the scenario that contains the steps
  2. Above the steps list, click Save as component
  3. Enter a Component name
  4. Select the steps to include. All steps are selected by default; click Select all to turn them all off or on
  5. Keep Replace selected steps with a component reference on, so the original scenario uses the new component right away (recommended)
  6. Click Save Component
image

The selected steps move into the new component. If the replace option was on, the scenario now shows a single Component block in their place.

image
☝🏼

Important: Only regular steps can be saved as a component. The Save as component button is hidden when a scenario contains only component references or scenario links.

Step 3 – Insert a component into a scenario

  1. Open the scenario you want to add the component to
  2. Above the steps list, click Insert component
  3. Pick the component from the dropdown
  4. A new Component block appears at the bottom of the steps. Drag it to the right position
  5. Click Save on the scenario
image

Component blocks show a blue Component tag and the component name. They expand to show their steps, numbered along with the other steps in the scenario.

💡

Tip: You can also insert components into the Cookies acceptance and Login flow slots of a scenario, not only the main steps list. Use this to standardize the parts of every scenario that always run the same way.

Step 4 – Update a component

One edit to a component updates every scenario that uses it.

4.1 Check which scenarios are affected

Before you change a component, check the Used in column in the components list. Click the count to see each scenario that uses the component and where (Steps, Cookies acceptance, or Login flow). Click a scenario to go straight to it.

image
image

4.2 Edit the component

  1. Open the Reusable components panel
  2. Click the component, or click the edit icon on its row
  3. Adjust the Component name or Steps
  4. Click Save

Every scenario that uses the component picks up the new steps on its next run. You don't need to edit the scenarios.

☝🏼

Important: Save stays disabled until the component has a name. If you close the editor with unsaved changes, a Save your changes prompt appears.

Step 5 – Detach or delete a component

When a scenario should no longer follow the shared sequence, you have two options.

Option
What happens
Detach
Unlinks one scenario from the component. That scenario keeps a copy of the steps; the component and other scenarios are not affected
Delete
Removes the component itself. Every scenario that used it automatically gets a copy of its steps, so nothing breaks

5.1 Detach a component from a scenario

  1. Open the scenario
  2. On the Component block, click the disconnect icon (tooltip: Detach. Keep steps but unlink from source)
  3. The block turns into regular, editable steps
  4. Click Save on the scenario

5.2 Delete a component

  1. Open the Reusable components panel
  2. Click the delete icon on the component's row
  3. Confirm in the dialog, which shows how many scenarios are affected
  4. A confirmation message shows how many scenarios were detached

Verify your setup

Before relying on a component in your scenarios:

  1. Open a scenario that uses the component
  2. Expand the Component block and check that the steps are what you expect
  3. Run the scenario, for example in the Scenario TesterScenario Tester, or wait for its next scheduled run, and review the result

Troubleshooting

Problem
Cause
Fix
Component not found. Detach or delete this block warning on a scenario
The component was deleted, but an outdated reference was left behind
Click the disconnect icon to turn it into regular steps, or click delete to remove the block
Insert component is missing above the steps list
No components exist yet
Create one in the Reusable components panel (Step 2)
Two components with the same name in the Insert component dropdown
Duplicate names are allowed but not recommended
Open one and rename it. Saving a duplicate name shows a warning so you can rename it right away
Save is greyed out in the component editor
The component has no name
Enter a name
Changes to a component don't show up in a scenario
The scenario was open in another tab with unsaved changes
Reload the scenario
☝🏼

Important: Components can't contain other components. Keep each component a simple list of steps.

Still stuck? Email support@code-cube.io.

Next steps

  • Use components in the Cookies acceptance and Login flow slots to standardize the start of every scenario
  • Set up Notifications & alertsNotifications & alerts on scenarios that use components, so a problem in a shared flow is caught once, centrally
  • Use scenario links to reference an entire scenario from another scenario, instead of a sequence of steps