Skip to content
Last updated: 2026-04-06
Reference

Tag Manager JavaScript reference

The Dxtra Tag Manager is a server-side, privacy-first tag management system. Unlike traditional client-side tag managers that expose a JavaScript API for firing events, Tag Manager uses a rule-based execution engine — tags fire based on rules and conditions configured in the Tag Manager dashboard, not through client-side function calls.

This page describes how the Tag Manager client-side script works and how it interacts with the rule engine.

The tm.js script

Tag Manager serves a single JavaScript file per application. This script is loaded from the Tag Manager Edge service:

HTML
<script async src="https://tagmanager-edge.dxtra.ai/edge/{YOUR_APP_ID}/tm.js"></script>

The tm.js script is a self-contained bundle generated for your specific application. It contains the rules, conditions, and tag configurations you have set up in the Tag Manager dashboard. There is no global dxtra() function or client-side event API — tag execution is driven entirely by the rule engine.

No client-side JavaScript API

Tag Manager does not expose a dxtra() global function, a data layer push API, or client-side event tracking methods. If you have seen references to these in other documentation, they are incorrect. All tag behavior is configured through the Tag Manager UI.

How tm.js executes

When the script loads on a page:

  1. Rules are evaluated — The script evaluates the conditions configured in the Tag Manager dashboard (page URL, DOM state, timing, etc.)
  2. Consent is checked — Tags only fire when the visitor's consent status satisfies the consent conditions attached to each tag or rule
  3. Tags execute — Tags that pass both rule conditions and consent checks are injected or executed on the page

This entire process is driven by the configuration baked into tm.js at build time. You manage this configuration through the Tag Manager UI, not through JavaScript calls.

Content Security Policy

If your site uses a Content Security Policy, add the Tag Manager Edge domain to your directives:

Text Only
Content-Security-Policy:
  script-src 'self' https://tagmanager-edge.dxtra.ai;
  connect-src 'self' https://tagmanager-edge.dxtra.ai;

You may also need to allow domains for any third-party tags that Tag Manager injects (e.g., Google Analytics, Meta Pixel).

Consent enforcement is built into the Tag Manager rule engine. When you configure a tag in the dashboard, you attach consent conditions that specify which consent categories must be granted before the tag fires.

  • Tags with no consent conditions fire unconditionally (use this only for strictly necessary functionality)
  • Tags with consent conditions are blocked until the visitor's consent status matches
  • Consent state is evaluated at rule execution time — if consent is later withdrawn, tags will not fire on subsequent page loads

This means your client-side code does not need to manage consent checks. The rule engine handles it.

Conditional script loading

If you want to prevent the tm.js script from loading entirely before consent (for strict GDPR interpretations where even loading a script is considered processing), you can conditionally insert the script tag:

JavaScript
function loadTagManager(appId) {
  const script = document.createElement('script');
  script.async = true;
  script.src = `https://tagmanager-edge.dxtra.ai/edge/${appId}/tm.js`;
  document.head.appendChild(script);
}

// Call loadTagManager('{YOUR_APP_ID}') when the visitor grants consent

Privacy characteristics

Tag Manager is designed for privacy compliance:

  • No cookies by default — The tm.js script does not set browser cookies unless a tag it manages explicitly does so
  • No cross-site tracking — Tag Manager does not perform cross-domain tracking on its own
  • Server-side rule engine — Tag configurations are compiled server-side; the client script executes pre-built rules
  • Consent-aware execution — Tags only fire when consent conditions configured in the dashboard are satisfied
  • No PII collection — The script does not automatically collect names, emails, or other PII

Managing tags

All tag management is done through the Tag Manager UI at tagmanager.dxtra.ai:

  • Create tags — Define what scripts or pixels to load
  • Set rules and conditions — Control when tags fire (page URL, events, timing)
  • Attach consent conditions — Require specific consent categories before a tag executes
  • Test and publish — Preview changes before deploying to production

For details on tag configuration, see Tag configuration.

Platform installation examples

Since tm.js is a standard <script> tag, installation follows the same pattern across all platforms.

Next.js (App Router)

TSX
// app/layout.tsx
import Script from 'next/script'

export default function RootLayout({ children }) {
  return (
    <html>
      <head>
        <Script
          src="https://tagmanager-edge.dxtra.ai/edge/{YOUR_APP_ID}/tm.js"
          strategy="afterInteractive"
        />
      </head>
      <body>{children}</body>
    </html>
  )
}

Static HTML

HTML
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Your Page</title>
  <script async src="https://tagmanager-edge.dxtra.ai/edge/{YOUR_APP_ID}/tm.js"></script>
</head>
<body>
  ...
</body>
</html>

WordPress

Add the script tag via your theme's header.php or a "Header Scripts" plugin. No additional JavaScript configuration is needed — the script is self-contained.

Shopify

Go to Online Store > Themes > Edit Code and add the script tag to the <head> section of your theme.liquid file.

Troubleshooting

Tags not firing — Verify the script is loading by checking the Network tab in browser developer tools for a request to tagmanager-edge.dxtra.ai/edge/{id}/tm.js. Check that your rule conditions match the current page. Verify consent status if the tag has consent conditions.

Script blocked — Check for ad blockers or Content Security Policy restrictions. Add the Tag Manager Edge domain to your CSP if needed.

Changes not reflected — After updating tag configuration in the Tag Manager dashboard, the tm.js bundle must be rebuilt. Check that your changes have been published.


Not legal advice

This documentation provides technical reference for the Dxtra Tag Manager. AI-generated content does not constitute legal advice. Consult a qualified legal professional for advice specific to your jurisdiction and business context.