This page describes the Server SDK appendIdentityToUrl method. For the Web SDK, see appendIdentityToUrl.
The appendIdentityToUrl method adds the visitor’s identity to a URL as a query string parameter named adobe_mc. When the visitor follows the URL to another domain that you own, the Web SDK or the Server SDK on that domain reads the parameter and keeps the same Experience Cloud ID (ECID). This prevents the visitor from being counted twice in datasets that include both domains.
On a server, a common use is to add the visitor’s identity to a redirect to another domain:
const visitor = alloy.forRequest({ request: req, cookie: visitorCookies });
const { url } = await visitor.appendIdentityToUrl({
url: "https://shop.example.net/checkout"
});
res.writeHead(302, { Location: url });
res.end();
The resulting URL looks similar to the following:
https://shop.example.net/checkout?adobe_mc=TS%3D1792711449%7CMCMID%3D34567890123456789012345678901234567890%7CMCORGID%3DADB3LETTERSANDNUMBERS%2540AdobeOrg
If the SDK doesn’t have the visitor’s ECID yet, it requests one from the Edge Network first. That request is unauthenticated. See Set the datastream access type.
If the visitor has opted out, or defaultConsent is "out" and the visitor hasn’t opted in, the method returns the URL unchanged. It also returns the URL unchanged, instead of rejecting, if it can’t get the visitor’s identity, for example because of a network error. When debugging is on, the SDK logs a warning that includes Unable to append identity to url.
Options options
The appendIdentityToUrl method accepts an object with the following properties:
url: Required. The URL to add the visitor’s identity to.edgeConfigOverrides: A datastream configuration override object for this request.
Result object result
The appendIdentityToUrl method returns a promise. When it resolves, the result object contains url, the URL with the adobe_mc query string parameter added.