Is this in Sitecore Context or outside the context (aka a raw call to xConnect)
In Sitecore Context
Habitat has a good example of this https://github.com/Sitecore/Habitat/blob/2d3ee809fa4035a46a410d0438ed41e1c7f8a3b1/src/Foundation/SitecoreExtensions/code/Services/TrackerService.cs#L100
OutcomeDefinitionManager comes from DI IDefinitionManager<IOutcomeDefinition> outcomeDefinitionManager
public void TrackOutcome(Guid outComeDefinitionId)
{
Assert.ArgumentNotNull(outComeDefinitionId, nameof(outComeDefinitionId));
if (!this.IsActive || Tracker.Current.Contact == null)
{
return;
}
var outcomeDefinition = this.OutcomeDefinitionManager.Get(outComeDefinitionId, CultureInfo.InvariantCulture);
if (outcomeDefinition == null)
{
Log.Warn($"Cannot find outcome: {outComeDefinitionId}", this);
return;
}
Tracker.Current.CurrentPage.RegisterOutcome(outcomeDefinition, "USD", 0);
}
Raw xConnect
This Sitecore doco has the code you need. https://doc.sitecore.com/developers/90/sitecore-experience-platform/en/add-interaction-events.html
using (Sitecore.XConnect.Client.XConnectClient client = Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.GetClient())
{
try
{
var contact = new Sitecore.XConnect.Contact();
var channel = Guid.NewGuid(); // Use real channel ID from Sitecor
var interaction = new Interaction(contact, InteractionInitiator.Brand, channel, "iTunes/9.0.3 (Macintosh; U; Intel Mac OS X 10_6_2; en-ca)"); // Agent is iTunes
Guid outcomeId = Guid.Parse("{21EC2020-3AEA-4069-A2DD-08002B30309D}"); // ID of outcome item
var outcome = new Sitecore.XConnect.Outcome(outcomeId, DateTime.UtcNow, "USD", 100.00m);
interaction.Events.Add(outcome);
client.AddContact(contact);
client.AddInteraction(interaction);
await client.SubmitAsync();
}
catch (XdbExecutionException ex)
{
// Handle exception
}
}
Look in SQL
You can look in SQL to see your custom interaction with the custom outcome on the event. You just need the contact Id from the code.
SELECT TOP (1000) [InteractionId]
,[LastModified]
,[Created]
,[ConcurrencyToken]
,[ContactId]
,[StartDateTime]
,[EndDateTime]
,[Initiator]
,[DeviceProfileId]
,[ChannelId]
,[VenueId]
,[CampaignId]
,[Events]
,[UserAgent]
,[EngagementValue]
,[Percentile]
FROM [Xdb.Collection.Shard0].[xdb_collection].[Interactions]
WHERE ContactId = 'A86801E3-A35E-0000-0000-058CDEB592D7'