Deploy using an HTML Tag

Deploy using an HTML Tag

Get your private data stream endpoint url

Before digging into the integration of the agent you need to get your private data stream endpoint url we will use to push our agent data. Ask your dedicated ScaleDynamics account team to get one. This URL is referred to as <PRIVATE_URL> in the following documentation.

Note that this url has been generated only for one report and you must treat it as confidential and do not share it publicly.

Adding an HTML Tag

To monitor a page, insert the following HTML snippet.

<script 
  type="module" 
  async
  src="https://agent.scaledynamics.com/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>

Optional configuration

JSON configuration file

You can define optional configurations of your endpoint server in a JSON file. Before deploying send it to your dedicated account team, so your private endpoint data server will know how and where to apply the data collection for your report.

Note that by default without any JSON file, all domains/paths are monitored and no conversion is detected.

Example of a full private data stream endpoint server JSON configuration:

{
  "conversion": {
    "regexps": [ "...", "..." ]
  },
  "domain": {
    "includes": [ "...", "..." ],
    "excludes": [ "...", "..." ]
  }
}

Configure the conversion detection

This step is optional, only if you want to get the conversion rate per BDP and correlate your business outcomes with hardware performance. In that case you need to add some configuration.

If you want that data the agent needs to detect successful user conversions (e.g., checkouts, sign-ups).. You can configure this detection via URL pattern matching on our side, or by sending direct events from your code.

Using URL pattern matching

Each time an url matches a conversion pattern, we consider it as a conversion.

The URL pattern matching is done by your private data stream endpoint server. In order to use conversion url pattern matching, you need to identify which urls should be categorized as a conversion and define a list of regular expressions. A URL is considered a conversion if it matches at least one of these expressions. You have to put all these regular expressions in a JSON array in your private data stream endpoint server JSON configuration, so we can configure the detection on your private data stream endpoint server.

{
  "conversion": {
    "regexps": [ "...", "..." ]
  }
}

Using conversion events

To send a conversion event, use the code snippet below each time a conversion happens in your application code:

sdAgent.send('conversion_done');

Domains/Subdomains filtering

According to your CI/CD, build or deployment process, the agent could be deployed in multiple running domains/subdomains. For example you would like to get only data for your production environment, and not beta/dev/staging ones.

Note that if you deployed using Goggle Tag Manager you can use Exceptions to exclude specific pages without requiring to this configuration. See Deployment step 4 of Deploy with Google Tag Manager

Using CI/CD variable

To control when the agent should be active or inactive in your deployments, you can use a CI/CD variable for the <PRIVATE_URL>. When that variable is “” or undefined, the agent is disabled automatically. Otherwise the agent initializes and pushes data.

Using private data stream endpoint server JSON configuration

To avoid capturing useless data in order to get a reliable report, you can indicate which domain/sub domains to include or exclude for monitoring using regular expressions by adding it in your private data stream endpoint server JSON configuration as below.

{
  "domain": {
    "includes": [ "...", "..." ],
    "excludes": [ "...", "..." ]
  }
}

A domain is monitored if and only if it matches at least one regular expression in .includes AND does not match any regular expression in .excludes. Exclusion rules always take precedence over inclusion rules.

.includes: Optional. A list of regular expressions defining the domains to monitor. Defaults to matching all. .excludes: Optional. A list of regular expressions defining the domains to ignore. The default is no exclusion.