This guide walks you through the full setup of Code Cube's Tag Monitor using Google Tag Manager server-side.
What will you do?
- Configure your domains and containers in the Code Cube portal
- Import the Tag Monitor template into your GTM server container
- Set up the tag with sampling and metadata
- Publish and verify your implementation
β° Estimated time: 10β15 minutes
π§ Requirements: Access to your GTM Server container and Code Cube portal
Implementation
- Step 1 β Portal configuration
- Step 2 β Import template in GTM (Server)
- Step 3 β Configure the tag in GTM
- Step 4 β Configure tag metadata
- Step 5 β Deploy and verify
Step 1 β Portal configuration
Before configuring anything in GTM, define which domains and containers should be monitored with Code Cubeβs Tag Monitor.
1.1 Domains & Time zone
- Go to the step 'General settings' on the Tag Monitor configuration page
- Add all domains you want to monitor
- Select the appropriate time zone
Important: Alerts and data will only be available for domains listed here. If your domain is not added, Tag Monitor wonβt process any data.
1.2 GTM container settings
- Go to the step 'Client-side error monitoringβ on the Tag Monitor configuration page
- Add the GTM container IDs you want to enable monitoring for
Important: Alerts and data will only be available for domains listed here. If your domain is not added, Tag Monitor wonβt process any data.
Step 2 β Import Code Cube template in GTM
Install the Tag Monitor tag template in your GTM container. This provides the logic needed to send tag data to Code Cube.
2.1 Download the template
- Go to 'Server-side error monitoring' in the Tag Monitor configuration page
- Click "Download template"
2.2 Import template to GTM
- Open your GTM server-side container
- Go to "Templates" > "Tag Templates"
- Click "New"
- Click the three dots > "Import"
- Upload the downloaded file
- Save without making any changes
Step 3. Configure the tag in GTM
Now configure how the Tag Monitor tag collects and sends data β including basic settings and sampling.
3.1 Create the tag
- Create a new tag
- Choose the imported Tag Monitor template as the tag type.
- Fill in the required fields:
- Database name: Copy from the configuration page
- Consent: Set to 'No additional consent requiredβ.
- Metadata: Add key
exclude
with valuetrue
3.2 Set-up the trigger
Use a Custom Event trigger with regex matching and optional sampling to control data volume.
- Create a new trigger
- Trigger type: Custom Event
- Event name:
.*
(match all) - Enable "Use regex matching"
You can add sampling to the trigger, which will help to minimze the impact on performance for high-traffic environments.
- Enable the built-in variable "Random Number"
- Add a condition to only fire the tag when
Random Number
matches your sampling logic
Recommended Sampling Rates:
segment of 0.5% | random number | less then or equal to | 10737418 |
segment of 5% | random number | less then or equal to | 107374182 |
segment of 10% | random number | ends on | 1* |
segment of 20% | random number | less then or equal to | 429496729 |
segment of 25% | random number | less then or equal to | 536870911 |
segment of 50% | random number | less then or equal to | 1073741823 |
3.3 Enable required variables
Some built-in variables should be enabled, as these are used by Tag Monitor to identify the container the tag was fired from.
- Go to Variables > Built-in Variables
- Enable:
- Container ID
- Container Version
4. Configure Tag metadata
Add your tag names to the outgoing requests for easier debugging and reporting.
Option A: Automatic update (Recommended)
- Go to 'Configure tag names' on the configuration page
- Click Start bulk editing
- Follow the guided process to update your GTM container via API
Option B: Manual Update
For each tag in your container:
- Open Advanced Settings
- Check "Include tag name" under Additional Metadata
- Set key name to
name
Step 5 β Deploy and verify
Once everything is configured, itβs time to go live and confirm everything works as expected.
5.1 Publish changes
- Submit and publish your GTM workspace
- Choose the right environment (usually production)
5.2 Verify
- Open the Tag Monitor dashboard in the Code Cube portal
- Look for incoming data from your configured domain and container
- Check that tag names are being registered correctly
Step 2. Import Code Cube template in GTM
2.1 Download the template
- Open the step 'Server-side monitoring' on the Tag Monitor configuration page.
- Click the download button to download the Tag Monitor template
2.2 Import template to GTM
- Open your Google Tag Manager server-side container.
- Navigate to "Templates".
- Click "New" in the "Tag Templates" section.
- Click the three dots in the top right corner.
- Select "Import" and choose the downloaded Tag Monitor template.
- Save without making any modifications.
This template will soon be available in the Community Template Gallery for easier installation.
Step 3. Configure the tag in GTM
Set up the core Tag Monitor configuration to define how your implementation will collect and process data.
3.1 Create the tag
- Create a new tag in your container.
- Select the imported Tag Monitor template as the tag type.
- Configure these required settings:
- Database Name / Dataset ID: Copy this value from the Code Cube configuration page, step 'Server-side monitoring'.
- Table Name / Table ID: Enter "raw_data_server"
- Metadata: Add key "exclude" with value "true"
3.2 Set-up the trigger
- Create a new 'Custom Event' trigger
- Configure to fire on all events:
- Event name:
.*
- Enable "Use regex matching"
- Add sampling for better performance:
- Enable the built-in variable "Random Number"
- Add rule: "Some custom events" where "Random Number" meets criteria.
Recommended Sampling Rates:
segment of 0.5% | random number | less then or equal to | 10737418 |
segment of 5% | random number | less then or equal to | 107374182 |
segment of 10% | random number | ends on | 1* |
segment of 20% | random number | less then or equal to | 429496729 |
segment of 25% | random number | less then or equal to | 536870911 |
segment of 50% | random number | less then or equal to | 1073741823 |
The trigger can be customized following your own insights and requirements. For example you can add extra rules to include certain events or pages.
3.3 Enable required variables
- Go to Variables > Built-in Variables
- Enable:
- Container ID
- Container Version
4. Configure Tag Metadata
Choose ONE of these methods:
Option A: Automatic Update (Recommended)
- Navigate to "Configure tag names" in the 'Server-side monitoring' section of the configuration page.
- Click "Start bulk editing"
- Follow the guided process to update your container via API
Option B: Manual Update
For each tag in your container:
- Expand "Advanced Settings"
- Check "Include tag name" under "Additional Tag Metadata"
- Set the key name to "name"
Step 5: Deploy and Verify
5.1 Publish Changes
- Submit and publish your workspace
- Select the appropriate environment (typically production)
5.2 Verification
- Open the Tag Monitor dashboard in Code Cube portal
- Check that data is flowing in from your container
- Verify that tag names are displaying correctly
Troubleshooting
Problem | Possible Solution |
No data in dashboard | Check that trigger conditions are met; verify sampling rate isn't too low |
Missing tag names | Ensure metadata is configured for all tags |
Performance issues | Consider reducing sampling rate if server performance is affected |
Template import fails | Download template again; check for browser extensions blocking import |