Google Tag Manager (GTM)
Before beginning the integration for either phase, you must obtain your private data stream endpoint URL from your dedicated ScaleDynamics account team. This URL is unique to your report and must remain confidential. In the code snippets below, replace <PRIVATE_URL> with this exact endpoint.
Phase 1: The 24-Hour Audit (sd-agent.js)
Deploy the passive telemetry agent to gather hardware insights across your traffic without altering your user experience.
Step 1: Deploy the Core Agent
- Create a New Tag: Log in to your Google Tag Manager workspace, navigate to Tags, and click New. Name your tag (e.g.,
ScaleDynamics - Agent). - Configure the Tag Type: Select Custom HTML.
- Insert the Script: Paste the following configuration:
<script
type="module"
async
src="https://cdn.scaledynamics.com/libs/2/sd-agent.js">
</script>
<script>
window.sdAgent = window.sdAgent || {
_q: [],
send: function() {
window.sdAgent._q.push([Date.now(), window.location.href, arguments])
},
config: function () { window.sdAgent._c = arguments },
};
sdAgent.config({
// Replace <PRIVATE_URL> with your actual agent URL.
endpoint: '<PRIVATE_URL>',
});
</script>- Define Triggers:
- Set the trigger to All Pages.
- (Optional) To exclude specific areas like a checkout, click Add Exception, create a new trigger for Some Page Views (e.g.,
Page URL contains /checkout), and save it.
- Save and Publish: Save the tag. Use GTM's Preview mode to verify it fires correctly, then click Submit and Publish.
Step 2 (Optional): Install Conversion Detection
To correlate hardware performance (like the BDP score) with your actual business outcomes, you can configure an optional conversion event.
- Create a New Tag: Name it
ScaleDynamics - Conversionand select Custom HTML. - Insert the Script:
<script>
sdAgent.send('conversion_done');
</script>- Set Tag Sequencing: Click Advanced Settings at the bottom of the configuration box. Check Fire a tag before ScaleDynamics - Conversion fires and select your main
ScaleDynamics - Agenttag from the dropdown. This ensures the conversion script never fires before the main agent is loaded. - Define Triggers: Assign this tag to trigger strictly on your conversion pages, confirmation buttons, or successful checkout elements.
- Save and Publish.
Have a look to sd-agent.js API Reference to get a description of all available APIs.
Phase 2: Production Integration (sd-metrics.js)
Once your 24-hour audit is complete, replace the passive agent with the active execution engine to use the hardware scores for dynamic logic or ad monetization.
(Note: Ensure you pause or delete your Phase 1 sd-agent.js tags before publishing Phase 2).
Step 1: Deploy the Active Engine
- Create a New Tag: Name it
ScaleDynamics - Metricsand select Custom HTML. - Insert the Script: Paste the following module script. It initializes the engine and provides listeners to capture the specific metrics you wish to utilize.
<script type="module">
import { SdMetrics } from 'https://cdn.scaledynamics.com/libs/1/sd-metrics.js';
window.sd = new SdMetrics({
// Replace <PRIVATE_URL> with your actual agent URL.
endpoint: '<PRIVATE_URL>',
});
// use sd-metrics API
...
</script>Have a look to sd-metrics.js API Reference to get a description of all available APIs.
- Define Triggers: Set the trigger to All Pages (or ideally, Initialization - All Pages to ensure the hardware scores are evaluated before your other scripts and tags execute).
- Save and Publish: Use GTM Preview mode to ensure the metrics output successfully to your browser console, then Submit and Publish to production.