API Reference

📦

at.js Reference

at.js is Adobe Target's JavaScript implementation library. It must be present on your page for Target activities to function. This reference covers the key functions and settings relevant to VEC Custom Code authors.

What is at.js?

at.js handles communication with Target's delivery API, applies experiences, and fires conversion beacons. Experience Lab-generated code runs inside the context established by at.js and does not require any direct calls to it, but understanding at.js helps debug execution timing issues.

📝at.js 2.x vs 1.x
at.js 2.x is the current version and is required for Single Page Application (SPA) support. at.js 1.x is legacy. Experience Lab generates code compatible with both, but at.js 2.x is recommended for all new implementations.

Execution timing

at.js fires a request to Target's delivery API on page load. When the response is received, it applies the VEC modifications — including your Custom Code — to the DOM. This means your modal script executes after at.js has received and applied the activity. The generated script uses a waitForBody() polling approach to ensure document.body exists before injecting the modal, making it safe regardless of when exactly at.js applies the experience.

Key functions

adobe.target.getOffer()

Requests an offer from Target. Used when you want to retrieve offer content programmatically outside the automatic page-load request.

javascript
adobe.target.getOffer({
  mbox: "target-global-mbox",
  params: { "user.category": "premium" },
  success: function(offers) {
    adobe.target.applyOffer({ mbox: "target-global-mbox", offer: offers });
  },
  error: function(status, error) {
    console.error("Target getOffer error:", status, error);
  }
});

adobe.target.applyOffer()

Applies offer content returned by getOffer() to the DOM.

javascript
adobe.target.applyOffer({
  mbox: "target-global-mbox",
  offer: offers  // the array returned by getOffer success callback
});

adobe.target.trackEvent()

Fires a conversion event. Call this in your Experience Lab-generated script when the user takes the desired action — e.g., clicks the CTA button.

javascript
// Fire a click conversion — call from your CTA click handler
adobe.target.trackEvent({
  mbox: "target-global-mbox",
  params: { "event": "cta-click" }
});

adobe.target.getOffers() — on-device decisioning (at.js 2.x)

at.js 2.x supports on-device decisioning — evaluating targeting rules locally without a network request.

javascript
adobe.target.getOffers({
  request: {
    execute: {
      mboxes: [{
        index: 0,
        name: "target-global-mbox"
      }]
    }
  }
}).then(response => {
  // handle response
}).catch(err => {
  console.error(err);
});

at.js settings reference

SettingDefaultDescription
clientCodeYour Target client code. Required.
serverDomainclientcode.tt.omtrdc.netThe Target edge domain.
timeout3000Request timeout in ms. Increase on slow networks.
globalMboxAutoCreatetrueAuto-fires global mbox on page load.
visitorApiTimeout2000Timeout for Visitor API requests (ECID).
defaultContentHidingStylebody { opacity: 0 }Anti-flicker hiding style applied before Target responds.
deviceIdLifetime63244800000Duration (ms) to persist device ID in localStorage.

Anti-flicker

When at.js loads asynchronously, visitors may briefly see the original page before Target applies the experience. The standard mitigation hides body until at.js finishes rendering, then reveals it.

anti-flicker-snippet.html
<!-- Place immediately before the at.js script tag -->
<style>body { opacity: 0 !important }</style>
<script>
  var startTime = Date.now();
  var prehidingStyle = document.querySelector('style');
  function removeFlicker() {
    if (prehidingStyle) prehidingStyle.remove();
  }
  // Safety net: reveal after 3s even if at.js hasn't responded
  setTimeout(removeFlicker, 3000);
</script>
💡For modals, anti-flicker is optional
A modal appearing slightly late (after page load) is acceptable UX. Anti-flicker is more critical when your experiment modifies above-the-fold content that visitors see immediately.

at.js vs Web SDK — which is on your site?

Open DevTools → Network tab → filter by tt.omtrdc on page load. If you see requests, you're on at.js. If you see requests to adobedc.net, you're on Web SDK.

⚠️They cannot coexist
at.js and Web SDK are mutually exclusive. Running both on the same page causes conflicts. If you see both in your network requests, escalate to your engineering team immediately.

🔄 Still on at.js? Let's plan your migration.

Web SDK is Adobe's modern standard and at.js is in maintenance mode. Experience Lab can help you migrate without breaking existing activities — datastream config, XDM schema, and cutover strategy included.

Talk to us