Show Menu
TOPICS×

Get User IDs and Regions Through the Experience Cloud ID Service

ID service customers should refer to this section for information on how to read the visitor cookie for the IDs required to make DCS API calls.

Working With getMarketingCloudVisitorID

Another way to get the visitor ID is with the getMarketingCloudVisitorID function. When invoked, this function queries the ID service and returns an ID. getMarketingCloudVisitorID accepts the optional callback argument as shown:
var analyticsID = visitor.getAnalyticsVisitorID(callback)

Callback Usage and Purpose

callback is optional. This function works without it, but returns an ID only when a visitor has a Experience Cloud cookie in their browser. If the visitor cookie is missing, or a visitor doesn't have an ID, the function returns an empty () object. This can happen even after the page loads and the visitor receives a new ID. To avoid this, callback forces this function to check for a visitor ID after the page loads. Without callback , the visitor ID function won't return an ID even if it's written to the visitor's browser later.

Next Steps

Once you have the user and region ID, you can start sending and receiving DCS data. See Making DCS API Calls .