appendIdentityToUrl
The appendIdentityToUrl
command allows you to add a user identifier to the URL as a query string. This action allows you to carry a visitor’s identity between domains, preventing duplicate visitor counts for datasets that include both domains or channels. It is available on Web SDK versions 2.11.0 or later.
The query string generated and appended to the URL is adobe_mc
. If the Web SDK cannot find an ECID, it calls the /acquire
endpoint to generate one.
Append identity to URL using the Web SDK extension extension
Appending an identity to a URL is performed as an action within a rule in the Adobe Experience Platform Data Collection tags interface.
- Log in to experience.adobe.com using your Adobe ID credentials.
- Navigate to Data Collection > Tags.
- Select the desired tag property.
- Navigate to Rules, then select the desired rule.
- Under Actions, select an existing action or create an action.
- Set the Extension dropdown field to Adobe Experience Platform Web SDK, and set the Action Type to Redirect with identity.
- Click Keep Changes, then run your publishing workflow.
This command is typically used with a specific rule that listens for clicks and checks desired domains.
Triggers when an anchor tag with an href
property is clicked.
- Extension: Core
- Event type: Click
- When the user clicks on: Specific elements
- Elements matching the CSS selector:
a[href]
Triggers only on desired domains.
- Logic type: Regular
- Extension: Core
- Condition Type: Value Comparison
- Left Operand:
%this.hostname%
- Operator: Matches Regex
- Right Operand: A regular expression that matches the desired domains. For example,
adobe.com$|behance.com$
Append the identity to the URL.
- Extension: Adobe Experience Platform Web SDK
- Action Type: Redirect with identity
Append identity to URL using the Web SDK JavaScript library
Run the appendIdentityToUrl
command with a URL as a parameter. The method returns a URL with the identifier appended as a query string.
alloy("appendIdentityToUrl",document.location);
You can add an event listener for all clicks received on the page and check to see if the URL matches any desired domains. If it does, append the identity to the URL and redirect the user.
document.addEventListener("click", event => {
// Check if the click was a link
const anchor = event.target.closest("a");
if (!anchor || !anchor.href) return;
// Check if the link points to the desired domain
const url = new URL(anchor.href);
if (!url.hostname.endsWith(".adobe.com") && !url.hostname.endsWith(".behance.com")) return;
// Append the identity to the URL, then direct the user to the URL
event.preventDefault();
alloy("appendIdentityToUrl", {url: anchor.href}).then(result => {document.location = result.url;});
});
Response object
If you decide to handle responses with this command, the response object contains url
, the new URL with identity information added as a query string parameter.