Google Tag Manager (GTM)
Before beginning the integration, 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 private data stream endpoint URL
endpoint: '<PRIVATE_URL>',
});
</script>- Define Triggers:
- Set the trigger to All Pages.
- (Optional) To exclude specific areas like an admin back-office, click Add Exception, create a new trigger for Some Page Views (e.g.,
Page URL contains /admin), and save it.
- Save and Publish: Save the tag. Use GTM's Preview mode to verify it fires correctly, then click Submit 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 private data stream endpoint URL
endpoint: '<PRIVATE_URL>',
});
// use sd-metrics API, e.g. const bdp = await window.sd.bdp.get();
// ...
</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 verify it fires correctly, then Submit and Publish to production.