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.

Previous pageGet User IDs and Regions From a DCS Response
Next pageMaking Server-to-Server DCS API Calls

Audience Manager