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 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
- Step 2 – Create a component
- 2.1 Create from scratch
- 2.2 Save existing scenario steps as a component
- Step 3 – Insert a component into a scenario
- Step 4 – Update a component
- 4.1 Check which scenarios are affected
- 4.2 Edit the component
- Step 5 – Detach or delete a component
- 5.1 Detach a component from a scenario
- 5.2 Delete a component
- Verify your setup
- Troubleshooting
- Next steps
Step 1 – Open the Reusable components panel
- Go to the DataLayer Guard configuration page
- 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.
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.
- In the Reusable components panel, click + add component
- Enter a Component name. Pick a name a teammate will recognize, such as
Cookie Consent FloworLogin as Test User - Under Steps, add the steps the component should run, the same way you would in a scenario
- Click Save
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.
- Open the scenario that contains the steps
- Above the steps list, click Save as component
- Enter a Component name
- Select the steps to include. All steps are selected by default; click Select all to turn them all off or on
- Keep Replace selected steps with a component reference on, so the original scenario uses the new component right away (recommended)
- Click Save Component
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.
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
- Open the scenario you want to add the component to
- Above the steps list, click Insert component
- Pick the component from the dropdown
- A new Component block appears at the bottom of the steps. Drag it to the right position
- Click Save on the scenario
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.
4.2 Edit the component
- Open the Reusable components panel
- Click the component, or click the edit icon on its row
- Adjust the Component name or Steps
- 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
- Open the scenario
- On the Component block, click the disconnect icon (tooltip: Detach. Keep steps but unlink from source)
- The block turns into regular, editable steps
- Click Save on the scenario
5.2 Delete a component
- Open the Reusable components panel
- Click the delete icon on the component's row
- Confirm in the dialog, which shows how many scenarios are affected
- A confirmation message shows how many scenarios were detached
Verify your setup
Before relying on a component in your scenarios:
- Open a scenario that uses the component
- Expand the Component block and check that the steps are what you expect
- Run the scenario, for example in the
Scenario 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 & 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