getIdentity
When you run the sendEvent command, the Web SDK automatically obtains the visitor’s identity if one is not already present.
The getIdentity command allows you to obtain a visitor ID without sending event data.
If you require separate calls to generate a visitor ID and send data, you can use this command.
The getIdentity command goes through the following flow to retrieve the ECID.
- You use the Web SDK to call either
getIdentityorappendIdentityToUrl. - Web SDK waits for consent information to be provided.
- Web SDK checks whether the
ECIDnamespace was requested on the call. By default, theECIDnamespace is always included. - Web SDK reads the
kndctrcookie and returns its value asECID, if it exists. This only returns theECIDvalue, but not theregionId. - If the
kndctridentity cookie is not set or the"CORE"namespace was requested, Web SDK makes a request to the Edge Network. - The Edge Network returns both the
ECIDand theregionId(and theCORE ID, if requested).
Get identity using the Web SDK tag extension
The Web SDK tag extension does not offer this command through the tag extension UI. Use the custom code editor using JavaScript library syntax.
Get identity using the Web SDK JavaScript library
Run the getIdentity command when calling your configured instance of the Web SDK. The following options are available when configuring this command:
-
namespaces: An array of namespaces. The default value is["ECID"]. Other supported values include:["CORE"]["ECID","CORE"]nullundefined
You can request ECID and CORE ID at the same time. Example:
"namespaces": ["ECID","CORE"]. -
edgeConfigOverrides: A datastream configuration override object.
alloy("getIdentity",{
"namespaces": ["ECID","CORE"] //this command retrieves both ECID and CORE IDs.
});
Response object
If you decide to handle responses with this command, the following properties are available in the response object:
identity.ECID: A string containing the visitor’s ECID.identity.CORE: A string containing the visitor’s CORE ID.edge.regionID: An integer that represents the Edge Network region that the browser hit when acquiring an identity. It is the same as the legacy Audience Manager location hint.