Created
November 13, 2020 20:08
-
-
Save dsolovay/4ac71aec4126ec8f490270b1d596758d to your computer and use it in GitHub Desktop.
Get xConnect Contact ID (for use in Experience Profile, etc.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Page Language="C#" AutoEventWireup="true" %> | |
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head runat="server"> | |
<title>Session Info</title> | |
</head> | |
<body> | |
<h1>Session Info</h1> | |
<form id="form1" runat="server"> | |
<div> | |
<p>Analytics Cookie Value</p> | |
<%= Sitecore.Analytics.Tracker.Current.Contact.ContactId %> | |
<p>Main Contact ID</p> | |
<% using (var client = Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.GetClient()) { %> | |
<% | |
var reference = new Sitecore.XConnect.IdentifiedContactReference("xDB.Tracker", Sitecore.Analytics.Tracker.Current.Contact.ContactId.ToString("N")); | |
var contact = client.GetAsync<Sitecore.XConnect.Contact>(reference, new Sitecore.XConnect.ContactExecutionOptions(new | |
Sitecore.XConnect.ContactExpandOptions() { }), System.Threading.CancellationToken.None).Result;%> | |
<% Response.Write("contact.Id);%> | |
<% } %> | |
</div> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment