This guide walks you through creating and using Reusable components in DataLayer Guard, so you can share the same sequence of steps across multiple scenarios without copy pasting. When the shared sequence changes, you update it once and every scenario that uses it picks up the change automatically.
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 to 10 minutes
🔧 Requirements: Access to the Code-Cube.io portal and a DataLayer Guard configuration with at least one scenario
Implementation
- Step 1 - Open the Reusable components panel
- Step 2 - Create a component
- Step 3 - Insert a component into a scenario
- Step 4 - Update a component
- Step 5 - Detach or delete a component
Step 1. Open the Reusable components panel
Before you can build or insert a component, open the dedicated panel inside DataLayer Guard.
- 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. You will see a 'Create your first component' button in the empty state.
Step 2. Create a component
You can build a component in two ways. Use whichever fits where you are in your workflow.
2.1 Create from scratch
Use this option when you already know that a sequence will be shared, for example when you want to standardise your login flow before building any scenarios.
- In the 'Reusable components' panel, click '+ add component'
- Enter a 'Component name'. Pick something a future teammate will recognise, such as
Cookie Consent FloworLogin as Test User - Under 'Steps', add the steps the component should execute, the same way you would inside a scenario
- Click 'Save'
Tip: Name components after the user action they represent rather than the technical step. Login as Test User reads better in a scenario step list than Click + fill + submit.
2.2 Save existing scenario steps as a component
Use this option when you already built a sequence in a scenario and realise it is worth reusing.
- Open the scenario that contains the steps you want to reuse
- Above the steps list, click 'Save as component'
- In the modal, enter a 'Component name'
- Tick the steps to include. All steps are selected by default. Click 'Select all' to toggle them off and on
- Keep 'Replace selected steps with a component reference' on if you want the original scenario to start using the new component immediately. This is the recommended setting
- Click 'Save Component'
The selected steps are extracted into a new component. If the toggle 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 existing component references or scenario links.
Step 3. Insert a component into a scenario
Once a component exists, you can drop it into any 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 position you want
- Click 'Save' on the scenario
Component blocks render with a blue 'Component' tag and the component name. They expand inline to show the resolved steps, numbered alongside the other steps in the scenario.
Tip: Components can also be inserted into the 'Cookies acceptance' and 'Login flow' slots of a scenario, not only the main steps list. Use this to standardise the parts of every scenario that always run the same way.
Step 4. Update a component
The whole point of components is that one edit updates every scenario that uses them.
4.1 Open and edit the component
- Open the 'Reusable components' panel
- Click the component you want to edit, or click the 'edit' icon on its row
- Adjust the 'Component name' or 'Steps'
- Click 'Save'
Every scenario referencing this component will pick up the new steps on its next run. No per scenario edits are required.
Important: The save button stays disabled until 'Component name' has a value. If you try to close the editor with unsaved edits, a 'Save your changes' prompt appears so nothing is lost silently.
4.2 Check which scenarios will be affected
Use the 'Used in' column on the components list to see how many scenarios reference a component before you change it. Click the count to open a popover that lists each scenario and the slot where the component is used (Steps, Cookies acceptance, or Login flow). Click any scenario in the popover to jump straight to it.
Step 5. Detach or delete a component
When a scenario should no longer follow the shared sequence, you have two options.
5.1 Detach (keep the steps, remove the link)
Detach turns a component block into an independent copy of its current steps inside that one scenario. Other scenarios that reference the component are not affected.
- Open the scenario
- On the Component block, click the disconnect icon (the tooltip reads 'Detach. Keep steps but unlink from source')
- The block expands into regular, editable steps
- Click 'Save' on the scenario
5.2 Delete the component entirely
Deleting removes the component itself. Any scenario that referenced it gets the component's steps copied in as independent steps automatically, so nothing is silently broken.
- Open the 'Reusable components' panel
- On the row, click the delete icon
- Confirm in the modal. It tells you how many scenarios will be affected
- The component disappears from the list and a toast confirms how many scenarios were detached
Important: Detach and delete are not the same. Detach unlinks one scenario from a component but leaves the component intact. Delete removes the component and converts every reference into independent steps across every scenario that used it.
Verify your setup
Before relying on a component in production scenarios:
- Open any scenario that references the component
- Expand the Component block and confirm the resolved steps match what you expect
- Run the scenario manually, or wait for its next scheduled run, and review the result
- Edit the component, reopen the scenario, and confirm the new steps appear immediately in the resolved view
Troubleshooting
Symptom | Cause | Fix |
'Component not found. Detach or delete this block' warning on a scenario | The referenced component was deleted but a stale reference snapshot was left behind | Click the disconnect icon to convert it to independent steps, or click delete to remove the block |
'Insert component' dropdown is missing above the steps list | No components exist yet | Create one first via the 'Reusable components' panel (Step 2) |
Two components with the same name appear in the 'Insert component' dropdown | Duplicate names are allowed but discouraged | Open one in the editor and rename it. Saving a duplicate name triggers a soft warning so you can rename on the spot |
'Save' is greyed out in the component editor | 'Component name' is empty | Enter a name. Components must be named to be saved |
Edits to a component did not show up in a scenario | The scenario was open in another tab with unsaved changes | Reload the scenario. The resolved steps view always reads from the latest saved component |
Important: Components cannot reference other components. Keep each component a flat list of steps. There is no cycle detection on nested references.
What's next
- Combine components with the 'Cookies acceptance' and 'Login flow' slots to standardise the opening of every scenario in your DataLayer Guard setup
- Set up notifications and alerts on the scenarios that use your components so any regression in a shared flow is caught once, centrally
- Explore scenario links if you want to reference an entire scenario from another scenario, rather than just a step sequence